fix: instantly finish free dojo decos (e.g. obstacle course gates) (#1321)
All checks were successful
Build / build (20) (push) Successful in 42s
Build / build (18) (push) Successful in 1m12s
Build / build (22) (push) Successful in 1m18s
Build Docker image / docker (push) Successful in 37s

Reviewed-on: #1321
This commit is contained in:
Sainan 2025-03-25 03:26:32 -07:00
parent 3ba58114b9
commit 31c1fc245f

View File

@ -24,17 +24,25 @@ export const placeDecoInComponentController: RequestHandler = async (req, res) =
}
component.Decos ??= [];
component.Decos.push({
_id: new Types.ObjectId(),
Type: request.Type,
Pos: request.Pos,
Rot: request.Rot,
Name: request.Name
});
const deco =
component.Decos[
component.Decos.push({
_id: new Types.ObjectId(),
Type: request.Type,
Pos: request.Pos,
Rot: request.Rot,
Name: request.Name
}) - 1
];
const meta = Object.values(ExportDojoRecipes.decos).find(x => x.resultType == request.Type);
if (meta && meta.capacityCost) {
component.DecoCapacity -= meta.capacityCost;
if (meta) {
if (meta.capacityCost) {
component.DecoCapacity -= meta.capacityCost;
}
if (meta.price == 0 && meta.ingredients.length == 0) {
deco.CompletionTime = new Date();
}
}
await guild.save();