✨ feat(诸子列传): 添加功能
This commit is contained in:
@@ -36,7 +36,7 @@ export class CheckMeterial {
|
||||
this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count);
|
||||
}
|
||||
|
||||
private getNotEnoughItems() {
|
||||
public getNotEnoughItems() {
|
||||
let map = new Map<number, number>();
|
||||
for(let [ id, count ] of this.notEnoughItems) {
|
||||
map.set(id, count);
|
||||
@@ -74,6 +74,27 @@ export class CheckMeterial {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 当消耗不足的时候,不提前返回,也不去算元宝和铜币
|
||||
public async decreaseItemsContinue(goods: {id: number, count: number}[]) {
|
||||
this.tempConsumes.splice(0, this.tempConsumes.length);
|
||||
this.notEnoughItems.clear();
|
||||
let { items } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let itemIsEnough = true;
|
||||
for(let { id, count} of items) {
|
||||
let notEnoughCount = await this.decreaseItem(id, count);
|
||||
if(notEnoughCount > 0) {
|
||||
let isEnough = await this.checkReplaceItem(id, notEnoughCount);
|
||||
if(isEnough) {
|
||||
this.tempConsumes.push({ id, count: count - notEnoughCount });
|
||||
} else {
|
||||
itemIsEnough = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.consumes.push(...this.tempConsumes);
|
||||
return itemIsEnough;
|
||||
}
|
||||
|
||||
public setCanReplace(canReplace: boolean) {
|
||||
this.canReplace = canReplace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user