Fix bug with building not showing requirements error

This commit is contained in:
Aelita4 2024-09-25 13:59:17 +02:00
parent 32671fc1d5
commit 37097bb361
Signed by: Aelita4
GPG Key ID: E44490C2025906C1
2 changed files with 2 additions and 2 deletions

View File

@ -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}` };
}
};

View File

@ -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 }
)
}