Skip to content

Commit

Permalink
fix: Disallow building ships with build_time=0 and document that
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Aug 6, 2024
1 parent 52bc3a2 commit 1e310c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/job/job-logic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ export class JobLogicService {
throw new BadRequestException('Ship type and fleet id are required for this job type.');
}
const ship = SHIP_TYPES[dto.ship as ShipTypeName] ?? notFound(dto.ship as ShipTypeName);
const time = this.empireLogicService.getShipTime(empire, ship);
if (!time) {
throw new BadRequestException('This ship type is not unlocked yet (build_time=0).');
}
return {
...this.empireLogicService.getShipCost(empire, ship),
time: this.empireLogicService.getShipTime(empire, ship),
time,
};
}
case JobType.TRAVEL: {
Expand Down
4 changes: 3 additions & 1 deletion src/job/job.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export class Job extends GlobalSchema {
@Prop({type: String})
@ApiPropertyOptional({
example: 'explorer',
description: 'Ship type name for the job. Required for type=ship.',
description: 'Ship type name for the job. Required for type=ship.\n\n' +
'Note that if the ship type build_time variable is 0 for this empire, the ship cannot be built.\n' +
'In this case, a technology is required to unlock the ship type.',
enum: SHIP_NAMES,
})
@ValidateIf((job, value) => value || job.type === JobType.SHIP)
Expand Down

0 comments on commit 1e310c9

Please sign in to comment.