From b1af8ad204b35bb364dc07bd58d82f588f837ef8 Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 13 Jul 2023 16:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E6=B4=BB=E5=8A=A8):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=B4=E8=AF=B7=E7=99=BE=E5=AE=B6=E5=85=8D?= =?UTF-8?q?=E8=B4=B9=E6=AC=A1=E6=95=B0=E7=B4=AF=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/handler/entertainHandler.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/game-server/app/servers/activity/handler/entertainHandler.ts b/game-server/app/servers/activity/handler/entertainHandler.ts index 6d5e67785..31121682d 100644 --- a/game-server/app/servers/activity/handler/entertainHandler.ts +++ b/game-server/app/servers/activity/handler/entertainHandler.ts @@ -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 });