🐞 fix(活动): 修复宴请百家免费次数累计问题
This commit is contained in:
@@ -64,14 +64,32 @@ export class EntertainHandler {
|
||||
if(!randResult) return resResult(STATUS.ACTIVITY_ENTERTAIN_NO_NUM);
|
||||
|
||||
let rewards = stringToRewardParam(randResult.reward);
|
||||
let playerRecord = await ActivityEntertainRecModel.record(serverId, activityId, playerData.roundIndex, roleId, { todayIndex: playerData.todayIndex, id: randResult.id, hid: randResult.hid, index: randResult.index, time: new Date(), reward: randResult.reward })
|
||||
let todayIndex = playerData.todayIndex; // 免费挑战算在第几天
|
||||
if(playerData.todayPlayCnt >= playerData.freeCntDaily && playerData.playCnt < playerData.freeCnt) {
|
||||
let playerRecord = await ActivityEntertainRecModel.findData(serverId, activityId, playerData.roundIndex, roleId);
|
||||
let records = playerRecord?.record||[];
|
||||
for(let i = 1; i <= todayIndex; i++) {
|
||||
let times = records.filter(cur => cur.todayIndex == i).length;
|
||||
playerData.playCnt += times;
|
||||
if(times < playerData.freeCntDaily) {
|
||||
todayIndex = i; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let playerRecord = await ActivityEntertainRecModel.record(serverId, activityId, playerData.roundIndex, roleId, { todayIndex, id: randResult.id, hid: randResult.hid, index: randResult.index, time: new Date(), reward: randResult.reward })
|
||||
let { goods } = await addReward(roleId, roleName, sid, serverId, rewards, ITEM_CHANGE_REASON.ACT_ENTERTAIN);
|
||||
randResult.incNum();
|
||||
playerData.updateBuyCnt(playerRecord);
|
||||
playerData.todayPlayCnt = 0;
|
||||
playerData.playCnt = 0;
|
||||
playerData.freeCnt = playerData.freeCntDaily * playerData.todayIndex;
|
||||
playerData.setPlayerRecords(playerRecord)
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
activityId,
|
||||
todayPlayCnt: playerData.todayPlayCnt,
|
||||
playCnt: playerData.playCnt,
|
||||
freeCnt: playerData.freeCnt,
|
||||
curHero: randResult.getShowResult(),
|
||||
goods
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user