feat(重阳集会): 更新

This commit is contained in:
zhangxk
2023-09-12 20:14:41 +08:00
parent 742d48267a
commit ed8912e440
3 changed files with 24 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ interface ChongYangDataReturn extends ChongYangSceneDataInDb {
buyCnt: number; // 累积到现在已经购买了的次数buyCnt < maxBuyCnt 的时候才能购买
playCnt: number; // 累计到现在游戏的次数
maxPlayCnt: number; // 累计到现在可以游戏的最大次数
isPushBuyRecord?: boolean; //
}
@@ -43,7 +44,7 @@ export class ChongYangData extends ActivityBase {
const { dayIndex, dailyFreeCnt, dailyBuyCnt } = obj;
let maxFreeCnt = dailyFreeCnt;
this.sceneMap.set(dayIndex, { ...obj, buyCnt: 0, playCnt: 0, maxPlayCnt: maxFreeCnt });
this.sceneMap.set(dayIndex, { ...obj, buyCnt: 0, playCnt: 0, maxPlayCnt: maxFreeCnt, isPushBuyRecord: true });
}
}
@@ -54,23 +55,29 @@ export class ChongYangData extends ActivityBase {
public updatePlayerRecord(playerData: ActivityChongYangRecModelType) {
if (!playerData) return;
let dayIndexUnlockAndSuccess = 1;
let buyRecordMap = new Map<number, ChongYangBuyRecord>()
if (playerData.buyRecords) buyRecordMap = playerData.buyRecords.reduce((map, cur) => { map.set(cur.dayIndex, { ...cur }); return map; }, new Map<number, ChongYangBuyRecord>());
if (playerData.gameRecords) {
this.gameRecords = playerData.gameRecords;
for (let data of playerData.gameRecords) {
let { isSuccess, dayIndex } = data;
for (const { isSuccess, dayIndex } of playerData.gameRecords) {
if (isSuccess) {
dayIndexUnlockAndSuccess = Math.max(dayIndexUnlockAndSuccess, dayIndex);
let scene = this.sceneMap.get(dayIndex);
scene.buyCnt = buyRecordMap.get(dayIndex)?.buyCnt || 0;
scene.playCnt += 1;
scene.maxPlayCnt = scene.buyCnt + scene.dailyFreeCnt;
this.sceneMap.set(dayIndex, scene);
};
this.dayIndexUnlock = Math.max(this.dayIndexUnlock, dayIndex);
}
}
if (playerData.buyRecords) {
for (const { dayIndex, buyCnt = 0 } of playerData.buyRecords) {
let scene = this.sceneMap.get(dayIndex);
scene.isPushBuyRecord = false;
scene.buyCnt = buyCnt;
scene.maxPlayCnt = scene.buyCnt + scene.dailyFreeCnt;
this.sceneMap.set(dayIndex, scene);
}
}
if (this.todayIndex > this.dayIndexUnlock && this.dayIndexUnlock == dayIndexUnlockAndSuccess) {
this.dayIndexUnlock += 1;