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