🐞 fix(通用丹): 当第一阶消耗够第二阶不足时会多扣除道具
This commit is contained in:
@@ -52,7 +52,11 @@ export class CheckMeterial {
|
||||
console.log('##### notEnoughCount', id, notEnoughCount, this.canReplace)
|
||||
if(notEnoughCount > 0) {
|
||||
let isEnough = await this.checkReplaceItem(id, notEnoughCount);
|
||||
if(!isEnough) return false;
|
||||
if(isEnough) {
|
||||
this.consumes.push({ id, count: count - notEnoughCount });
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +87,10 @@ export class CheckMeterial {
|
||||
this.itemsIndb.set(id, item.count);
|
||||
}
|
||||
if(this.itemsIndb.get(id) < count) {
|
||||
this.pushToNotEnoughItems(id, count - this.itemsIndb.get(id));
|
||||
|
||||
this.consumes.push({ id, count: this.itemsIndb.get(id) });
|
||||
let notEnoughCount = count - this.itemsIndb.get(id);
|
||||
this.pushToNotEnoughItems(id, notEnoughCount);
|
||||
this.itemsIndb.set(id, 0);
|
||||
return count - this.itemsIndb.get(id);
|
||||
return notEnoughCount;
|
||||
} else {
|
||||
this.itemsIndb.set(id, this.itemsIndb.get(id) - count);
|
||||
this.consumes.push({ id, count });
|
||||
@@ -121,7 +124,6 @@ export class CheckMeterial {
|
||||
let goldCost = gold.reduce((pre, cur) => { return pre + cur.count }, 0);
|
||||
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;
|
||||
}
|
||||
@@ -140,7 +142,6 @@ export class CheckMeterial {
|
||||
let coinCost = coin.reduce((pre, cur) => pre + cur, 0);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user