You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncupdateGame(game: Game){constempires=awaitthis.empireService.findAll({game: game._id});constsystems=awaitthis.systemService.findAll({game: game._id});constwars=awaitthis.warService.findAll({game: game._id});// TODO Optimize the fleet filter.// We are only interested in fleets that are at war with another fleet or system,// or fleets that are located in their owner's systems with shipyards for healing.// (The fleets are not the problem, but the potentially large amount of ships they contain.)// The first condition in SQL:// SELECT * FROM fleets as attacker, wars as war, fleets as defender WHERE attacker.owner = war.attacker AND defender.owner = war.defender// The second condition in SQL:// SELECT * FROM fleets as fleet, systems as system WHERE fleet.owner = system.owner AND 'building' IN system.buildingsconstfleets=awaitthis.fleetService.findAll({game: game._id});constships=awaitthis.shipService.findAll({fleet: {$in: fleets.map(f=>f._id)}});awaitthis.jobService.deleteMany({game: game._id,$expr: {$gte: ['$progress','$total']}});constjobs=awaitthis.jobService.findAll({game: game._id},{sort: {priority: 1,createdAt: 1}});awaitthis.updateEmpires(empires,systems,jobs,ships);awaitthis.updateFleets(empires,systems,fleets,ships,wars);awaitthis.empireService.saveAll(empires);awaitthis.systemService.saveAll(systems);awaitthis.jobService.saveAll(jobs);awaitthis.shipService.saveAll(ships);// We save all ships first to notify clients of 0HP with an updated event followed by the deleted event.awaitthis.deleteDestroyedShipsAndFleets(fleets,ships);awaitthis.deleteEmpiresWithoutSystems(empires,systems);}privateasyncupdateEmpires(empires: EmpireDocument[],systems: SystemDocument[],jobs: JobDocument[],ships: ShipDocument[]){for(constempireofempires){constempireSystems=systems.filter(system=>system.owner?.equals(empire._id));constempireJobs=jobs.filter(job=>job.empire.equals(empire._id));constempireShips=ships.filter(ship=>ship.empire?.equals(empire._id));awaitthis.jobService.updateJobs(empire,empireJobs,systems);this.updateEmpire(empire,empireSystems,empireShips);}}updateEmpire(empire: EmpireDocument,systems: SystemDocument[],ships: Ship[],aggregates?: Partial<Record<ResourceName,AggregateResult>>){constvariables=getInitialVariables();calculateVariables(variables,empire);
The text was updated successfully, but these errors were encountered:
We are only interested in fleets that are at war with another fleet or system,
or fleets that are located in their owner's systems with shipyards for healing.
(The fleets are not the problem, but the potentially large amount of ships they contain.)
The first condition in SQL:
SELECT * FROM fleets as attacker, wars as war, fleets as defender WHERE attacker.owner = war.attacker AND defender.owner = war.defender
The second condition in SQL:
SELECT * FROM fleets as fleet, systems as system WHERE fleet.owner = system.owner AND 'building' IN system.buildings
https://github.com/sekassel-research/stp-24-server/blob/350e6943ecfdb4f476744cc44b3531495d8e0cc3/src/game-logic/game-logic.service.ts#L116
The text was updated successfully, but these errors were encountered: