Fix bug with building not showing requirements error
This commit is contained in:
parent
32671fc1d5
commit
37097bb361
|
@ -52,7 +52,7 @@ export default class Building {
|
|||
const playerResearch = this.manager.planet.manager.owner.research;
|
||||
let playerResearchCanBuild = { canBuild: true, missing: "" };
|
||||
for(const researchReq of this.data.requirements.research) {
|
||||
if(playerResearch.research.find((research) => research.id === researchReq.id)?.level ?? 0 < researchReq.level) {
|
||||
if((playerResearch.research.find((research) => research.id === researchReq.id)?.level ?? 0) < researchReq.level) {
|
||||
playerResearchCanBuild = { canBuild: false, missing: `${researchReq.id} level ${researchReq.level} required, found ${playerResearch.research.find((research) => research.id === researchReq.id)?.level ?? 0}` };
|
||||
}
|
||||
};
|
||||
|
|
|
@ -67,7 +67,7 @@ export const POST: APIRoute = async({ request }) => {
|
|||
JSON.stringify({
|
||||
code: 400,
|
||||
message: "Bad Request",
|
||||
error: requirements.error + " | " + resources ? "" : "Not enough resources"
|
||||
error: `${requirements.error} | ${resources ? "" : "Not enough resources"}`
|
||||
}), { status: 400 }
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue