Skip to content

Commit 1e310c9

Browse files
committed
fix: Disallow building ships with build_time=0 and document that
1 parent 52bc3a2 commit 1e310c9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/job/job-logic.service.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ export class JobLogicService {
111111
throw new BadRequestException('Ship type and fleet id are required for this job type.');
112112
}
113113
const ship = SHIP_TYPES[dto.ship as ShipTypeName] ?? notFound(dto.ship as ShipTypeName);
114+
const time = this.empireLogicService.getShipTime(empire, ship);
115+
if (!time) {
116+
throw new BadRequestException('This ship type is not unlocked yet (build_time=0).');
117+
}
114118
return {
115119
...this.empireLogicService.getShipCost(empire, ship),
116-
time: this.empireLogicService.getShipTime(empire, ship),
120+
time,
117121
};
118122
}
119123
case JobType.TRAVEL: {

src/job/job.schema.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ export class Job extends GlobalSchema {
9898
@Prop({type: String})
9999
@ApiPropertyOptional({
100100
example: 'explorer',
101-
description: 'Ship type name for the job. Required for type=ship.',
101+
description: 'Ship type name for the job. Required for type=ship.\n\n' +
102+
'Note that if the ship type build_time variable is 0 for this empire, the ship cannot be built.\n' +
103+
'In this case, a technology is required to unlock the ship type.',
102104
enum: SHIP_NAMES,
103105
})
104106
@ValidateIf((job, value) => value || job.type === JobType.SHIP)

0 commit comments

Comments
 (0)