From 16831516bda4a8ca07cc6ed6563d401bbfc44847 Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 25 Oct 2022 19:07:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E9=80=9A=E7=94=A8=E4=B8=B9)?= =?UTF-8?q?:=20=E4=BF=AE=E6=94=B9=E9=80=9A=E7=94=A8=E4=B8=B9=E6=B6=88?= =?UTF-8?q?=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/role/checkMaterial.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/game-server/app/services/role/checkMaterial.ts b/game-server/app/services/role/checkMaterial.ts index ad62481d3..8e21d073b 100644 --- a/game-server/app/services/role/checkMaterial.ts +++ b/game-server/app/services/role/checkMaterial.ts @@ -86,11 +86,13 @@ export class CheckMeterial { this.pushToNotEnoughItems(id, count - this.itemsIndb.get(id)); this.consumes.push({ id, count: this.itemsIndb.get(id) }); + this.itemsIndb.set(id, 0); return count - this.itemsIndb.get(id); + } else { + this.itemsIndb.set(id, this.itemsIndb.get(id) - count); + this.consumes.push({ id, count }); + return 0 } - this.itemsIndb.set(id, this.itemsIndb.get(id) - count); - this.consumes.push({ id, count }); - return 0 } private async checkReplaceItem(id: number, count: number) { @@ -120,6 +122,7 @@ export class CheckMeterial { if(this.itemsIndb.get(this.goldId) < goldCost) { this.pushToNotEnoughItems(this.goldId, goldCost - this.itemsIndb.get(this.goldId)); this.consumes.push({ id: this.goldId, count: this.itemsIndb.get(this.goldId) }); + this.itemsIndb.set(this.goldId, 0); return false; } this.itemsIndb.set(this.goldId, this.itemsIndb.get(this.goldId) - goldCost); @@ -138,6 +141,7 @@ export class CheckMeterial { if(this.itemsIndb.get(this.coinId) < coinCost) { this.pushToNotEnoughItems(this.coinId, coinCost - this.itemsIndb.get(this.coinId)); this.consumes.push({ id: this.coinId, count: this.itemsIndb.get(this.coinId) }); + this.itemsIndb.set(this.coinId, 0); return false; } this.itemsIndb.set(this.coinId, this.itemsIndb.get(this.coinId) - coinCost);