寻宝:协助次数&匹配范围修改
This commit is contained in:
@@ -117,58 +117,6 @@ export class WarReward {
|
||||
}
|
||||
}
|
||||
|
||||
private async handlerBlueprtReward(num: number) {
|
||||
const refTime = getZeroPointD();
|
||||
const battleBlueprtDrop = await BattleBlueprtDropModel.findByTime(this.roleId, refTime);
|
||||
if(battleBlueprtDrop) {
|
||||
let { getNum = 0, curCostAp = 0, getSum = 0, costAp = 0 } = battleBlueprtDrop;
|
||||
for(let i = 0; i < num; i ++) {
|
||||
let flag = false; // 是否可以获得
|
||||
if( curCostAp >= BLUEPRT_CONST.PER_AP) {
|
||||
curCostAp = curCostAp - BLUEPRT_CONST.PER_AP; getNum = 0;
|
||||
}
|
||||
costAp += this.costAp; curCostAp += this.costAp;
|
||||
if(getNum == 0) {
|
||||
let r = Math.random();
|
||||
console.log(r, 1/BLUEPRT_CONST.PER_AP*curCostAp);
|
||||
if(r <= 1/BLUEPRT_CONST.PER_AP*curCostAp || (curCostAp >= BLUEPRT_CONST.PER_AP) ) {
|
||||
flag = true; // 独立概率随机
|
||||
}
|
||||
}
|
||||
if(getSum >= BLUEPRT_CONST.DAILY_CNT) {
|
||||
flag = false;
|
||||
}
|
||||
if(flag) {
|
||||
getNum ++; getSum++;
|
||||
const obj = await this.randomBlueprt();
|
||||
if(obj) {
|
||||
this.rewards.push({type: BATTLE_REWARD_TYPE.RANDOM_REWARD, times: i +1, ...obj});
|
||||
}
|
||||
}
|
||||
}
|
||||
await BattleBlueprtDropModel.updateByTime(this.roleId, refTime, {
|
||||
getNum, curCostAp, getSum, costAp
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async randomBlueprt() {
|
||||
const { lv } = await RoleModel.findByRoleId(this.roleId);
|
||||
const dicPossibility = gameData.blueprtPossibility;
|
||||
|
||||
const result = dicPossibility.find(cur => {return cur.min <= lv && cur.max >= lv});
|
||||
|
||||
if(result) {
|
||||
const {dic: {id}} = getRandEelmWithWeight(result.possibility);
|
||||
|
||||
const blueprtList = gameData.blueprt.get(id);
|
||||
const gid = getRandSingleEelm(blueprtList);
|
||||
return {id: gid, count:1}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
public async saveReward(num: number, combine: boolean = false) {
|
||||
this.rewards = new Array();
|
||||
// let warType = this.warInfo.warType;
|
||||
|
||||
Reference in New Issue
Block a user