fix 镇念塔挂机奖励无法获取

This commit is contained in:
luying
2020-12-30 14:35:45 +08:00
parent 76d3b30886
commit f6bf60b384
2 changed files with 9 additions and 9 deletions

View File

@@ -91,7 +91,7 @@ export class TowerBattleHandler {
let num = HANG_UP_CONSTS.MAX_SPD_UP_CNT - hangUpSpdUpCnt + 1;
let nextCostGold = calculateNum(GOLD_COST_RATIO.TOWER_HANG_SPDUP, {num}, 50);
return resResult(STATUS.SUCCESS, {startTime, hangUpPassTime: Math.floor(deltaTime/1000), hangUpSpdUpCnt, nextCostGold, rewards: timeReward.map(cur => {return {id: cur.gid, count: cur.count}})});
return resResult(STATUS.SUCCESS, {startTime, hangUpPassTime: Math.floor(deltaTime/1000), hangUpSpdUpCnt, nextCostGold, rewards: timeReward});
}
async recHangUpRewards(msg: {}, session: BackendSession) {

View File

@@ -150,16 +150,16 @@ export async function calcuHangUpReward(roleId: string, speedUp = false, speedUp
let notReceivedGoods = notReceivedGoodsList.find(cur => cur.cnt == cnt );
goods = notReceivedGoods?notReceivedGoods.goods:[];
}
for(let {gid, count} of baseReward) {
for(let {id, count} of baseReward) {
let newCount = cal.mul(count, multi);
let oldGoods = goods.find(cur => cur.gid == gid);
let oldGoods = goods.find(cur => cur.gid == id);
if(oldGoods) newCount = cal.add(newCount, oldGoods.count);
let roundCount = Math.floor(newCount);
if(newCount > roundCount) {
needReceiveGoods.push({gid, count: cal.sub(newCount, roundCount)});
needReceiveGoods.push({gid: id, count: cal.sub(newCount, roundCount)});
}
if(roundCount > 0) {
timeReward.push({gid, count: roundCount})
timeReward.push({id, count: roundCount})
}
}
}
@@ -170,16 +170,16 @@ export async function calcuHangUpReward(roleId: string, speedUp = false, speedUp
let multi = Math.floor(deltaTime / HANG_UP_CONSTS.UNIT_TIME); // 结算奖励的倍数,受最大时间限制
// console.log(deltaTime, multi, baseReward);
for(let {gid, count} of baseReward) {
for(let {id, count} of baseReward) {
let newCount = cal.mul(count, multi);
let oldGoods = notReceivedGoods.find(cur => cur.gid == gid);
let oldGoods = notReceivedGoods.find(cur => cur.gid == id);
if(oldGoods) newCount = cal.add(newCount, oldGoods.count);
let roundCount = Math.floor(newCount);
if(newCount > roundCount) {
needReceiveGoods.push({gid, count: cal.sub(newCount, roundCount)});
needReceiveGoods.push({gid: id, count: cal.sub(newCount, roundCount)});
}
if(roundCount > 0) {
timeReward.push({gid, count: roundCount})
timeReward.push({id, count: roundCount})
}
}
}