Skip to content

Commit

Permalink
fix: More precise intermediate travel steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Aug 14, 2024
1 parent 7b567e5 commit 03af890
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/job/job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class JobService extends MongooseRepository<Job> {
const fleet = await this.fleetService.find(job.fleet);
const ships = await this.shipService.findAll({fleet: new Types.ObjectId(job.fleet)});
const systems = await this.systemService.findAll({_id: {$in: job.path}});
if (!fleet || !ships) {
if (!fleet || !ships.length) {
continue;
}
const slowestShipSpeed = this.systemLogicService.getSlowestShipSpeed(fleet, ships, empire);
Expand All @@ -197,11 +197,11 @@ export class JobService extends MongooseRepository<Job> {
for (let i = 1; i < job.path.length; i++) {
const fromSystem = systems.find(system => system._id.equals(job.path![i - 1]));
const toSystem = systems.find(system => system._id.equals(job.path![i]));

if (!fromSystem || !toSystem) {
continue;
}
linkTimeSum += Math.round(this.systemLogicService.getLinkTime(fromSystem, toSystem, slowestShipSpeed)!);

linkTimeSum += this.systemLogicService.getLinkTime(fromSystem, toSystem, slowestShipSpeed)!;

if (job.progress + 1 >= linkTimeSum) {
fleet.location = toSystem._id;
Expand Down

0 comments on commit 03af890

Please sign in to comment.