Something went wrong. Try again.
Web client for TLE Community.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363import moment from 'moment';import Server from './server.js';import Captcha from './captcha.js';import { DATE_FORMAT } from './../constants.js';import { Route } from '../interfaces.js';import Body from './body.js';
let selfDestructActive = 0;let selfDestructDate = '';
const KNOWN_EMPIRES = [ { id: 1, name: 'Rome' }, { id: 2001, name: 'Carthage' }, { id: 2002, name: 'Carthaginian Remnant' }, { id: 2003, name: 'Macedon' }, { id: 2004, name: 'Parthia' },];
let sitters: Array<{ id: number; name: string; expiry: string }> = [ { id: 2003, name: 'Macedon', expiry: moment().add(12, 'days').format(DATE_FORMAT) },];
const sitterExpiry = () => moment().add(30, 'days').format(DATE_FORMAT);
const Empire: Route = { create(req, res) { return { empire_id: 1, }; },
update_species(req, res) { return { update_species: 1, }; },
redefined_species(req, res) { return { status: Empire.get_status(req, res), }; },
found(req, res) { return { session_id: 'this-is-a-session-id', welcome_message_id: 5, status: Empire.get_status(req, res), }; },
get_status(req, res) { return { empire: this.status_block(req, res), server: Server.status_block(req, res), body: Body.status_block(req, res), }; },
fetch_captcha(req, res) { return Captcha.fetch(req, res); },
login(req, res) { return { session_id: 'this-is-a-session-id', status: Empire.get_status(req, res), }; },
logout(req, res) { return { logout: 1, }; },
status_block(req, res) { const colonies = [];
for (let i = 1; i <= 40; i++) { colonies.push({ id: i, name: `Planet #${i}`, x: 0, y: 0, orbit: 1, type: `p${i}`, empire_name: 'Rome', empire_id: 1, zone: '0|0', }); }
return { id: 1, bodies: { colonies, mystations: [ { id: 200, name: 'Death Star', x: 100, y: -50, orbit: 2, empire_name: 'Rome', empire_id: 1, zone: '0|0', type: 'station', }, ], ourstations: [ { id: 300, name: 'Hubble', x: 150, y: 500, orbit: 5, empire_name: 'Star Explorers', empire_id: 2, zone: '0|1', type: 'station', }, ], babies: { 'Taylor Swift': { bodies: [ { id: 500, name: 'Red', x: 15, y: -27, orbit: 8, empire_name: 'Taylor Swift', empire_id: 3, zone: '0|-1', type: 'p5', }, ], }, }, }, colonies: { 1: 'Earth', 3: 'Mars', }, rpc_count: 250, insurrect_value: 100000, is_isolationist: 0, name: 'Rome', status_message: 'Making the Lacuna Expanse a better Expanse', home_planet_id: 1, has_new_messages: 4, latest_message_id: 4, essentia: 521, next_colony_cost: 100000, next_station_cost: 1000000, planets: { 1: 'Earth', 2: 'Death Star', 3: 'Mars', }, tech_level: 30, self_destruct_active: selfDestructActive, self_destruct_date: selfDestructDate, stations: { 2: 'Death Star', }, primary_embassy_id: 100, }; },
get_invite_friend_url(req, res) { return { referral_url: 'https://demo.lacunaexpanse.com/', status: Empire.get_status(req, res), }; },
view_profile(req, res) { return this.get_own_profile(req, res); },
get_own_profile(req, res) { return { profile: { id: 1234, name: 'Rome', description: 'A test empire', status_message: 'Making the Lacuna Expanse a better expanse', medals: [ { id: 1234, name: 'Built Level 1 Building', image: 'building1', date: '2013 01 31 12:34:45 +0600', public: 1, times_earned: 10, }, { id: 12345, name: 'Built Level 2 Building', image: 'building2', date: '2013 01 31 12:34:45 +0600', public: 0, times_earned: 4, }, ], city: '', country: '', notes: 'Just keep building...', skype: '', player_name: '', skip_happiness_warnings: 0, skip_resource_warnings: 0, skip_pollution_warnings: 0, skip_medal_messages: 0, skip_facebook_wall_posts: 0, skip_found_nothing: 0, skip_excavator_resources: 0, skip_excavator_glyph: 0, skip_excavator_plan: 0, skip_spy_recovery: 0, skip_probe_detected: 0, skip_attack_messages: 0, email: 'hello@example.com', sitter_password: '', }, status: Empire.get_status(req, res), }; },
invite_friend(req, res) { return { sent: [], not_sent: [], status: Empire.get_status(req, res), }; },
view_boosts(req, res) { return this.get_boosts(req, res); },
get_boosts(req, res) { return { boosts: { food: moment().add(1, 'week').format(DATE_FORMAT), ore: moment().add(1, 'week').format(DATE_FORMAT), energy: moment().add(1, 'week').format(DATE_FORMAT), water: moment().add(1, 'week').format(DATE_FORMAT), happiness: moment().add(2, 'days').format(DATE_FORMAT), storage: moment().add(1, 'hour').format(DATE_FORMAT), building: moment().add(1, 'hour').format(DATE_FORMAT), ship_build: moment().add(1, 'hour').format(DATE_FORMAT), ship_speed: moment().subtract(2, 'days').format(DATE_FORMAT), spy_training: moment().subtract(2, 'days').format(DATE_FORMAT), }, status: Empire.get_status(req, res), }; },
edit_profile(req, res) { return Empire.get_own_profile(req, res); },
find(req, res) { const name = String(req.body?.name ?? '');
return { empires: KNOWN_EMPIRES.filter((empire) => empire.name.toLowerCase().startsWith(name.toLowerCase()) ), status: Empire.get_status(req, res), }; },
view_authorized_sitters(req, res) { return { sitters, status: Empire.get_status(req, res), }; },
authorize_sitters(req, res) { const params = req.body ?? {}; const rejected_ids: Array<number | string> = [];
if (params.revalidate_all) { sitters = sitters.map((sitter) => ({ ...sitter, expiry: sitterExpiry() })); }
const requested: Array<number | string> = params.empires ?? [];
if (params.allied) { requested.push(2001); }
requested.forEach((idOrName) => { const empire = KNOWN_EMPIRES.find( (candidate) => candidate.id === Number(idOrName) || candidate.name === idOrName );
if (!empire || empire.id === 1) { rejected_ids.push(idOrName); return; }
sitters = [ ...sitters.filter((sitter) => sitter.id !== empire.id), { ...empire, expiry: sitterExpiry() }, ]; });
return { sitters, rejected_ids, status: Empire.get_status(req, res), }; },
deauthorize_sitters(req, res) { const params = req.body ?? {}; const ids: number[] = (params.empires ?? []).map(Number);
sitters = params.deauthorize_all ? [] : sitters.filter((sitter) => !ids.includes(sitter.id));
return { sitters, status: Empire.get_status(req, res), }; },
send_password_reset_message(req, res) { return { sent: 1, }; },
reset_password(req, res) { return Empire.login(req, res); },
enable_self_destruct(req, res) { selfDestructActive = 1; selfDestructDate = moment().add(24, 'hours').format(DATE_FORMAT);
return { status: Empire.get_status(req, res), }; },
disable_self_destruct(req, res) { selfDestructActive = 0; selfDestructDate = '';
return { status: Empire.get_status(req, res), }; },};
export default Empire;