🐞 fix(辜月集会): 修改菜谱随机,修改游戏次数、购买次数均与菜谱无关
This commit is contained in:
@@ -5,34 +5,42 @@ import { ActivityBase } from './activityField';
|
||||
|
||||
// 后台格式
|
||||
interface NovemberDataInDb {
|
||||
dayIndex: number; // 天数
|
||||
menuId: number; // 菜谱id
|
||||
buyCost: string; // 对应菜谱购买一次次数的消耗,type&id&count
|
||||
dailyBuyCnt: number; // 对应菜谱每天可以购买的次数
|
||||
dailyFreeCnt: number; // 对应菜谱每天可以免费的次数
|
||||
successRewards: string;// 对应菜谱每局的成功奖励 type&id&count
|
||||
failRewards: string; // 对应菜谱每局的失败安慰奖励 type&id&count
|
||||
menuIds: number[]; // 菜谱id
|
||||
buyCost: string; // 购买一次次数的消耗,type&id&count
|
||||
dailyBuyCnt: number; // 每天可以购买的次数
|
||||
dailyFreeCnt: number; // 每天可以免费的次数
|
||||
successRewards: string;// 每局的成功奖励 type&id&count
|
||||
failRewards: string; // 每局的失败安慰奖励 type&id&count
|
||||
};
|
||||
|
||||
|
||||
interface NovemberDataReturn {
|
||||
dayIndex: number; // 第几天
|
||||
menuId: number; // 菜谱id
|
||||
buyCost: string; // 对应菜谱购买一次的消耗,type&id&count
|
||||
buyCnt: number; // 对应菜谱累积到现在已经购买了的次数
|
||||
maxBuyCnt: number; // 对应菜谱累积到现在可购买的次数,buyCnt<maxBuyCnt的时候才能购买
|
||||
playCnt: number; // 对应菜谱累计到现在游戏的次数
|
||||
maxPlayCnt: number; // 对应菜谱累计到现在可游戏的最大次数(免费+购买 playCnt<maxPlayCnt可游戏)
|
||||
successRewards: string; // 对应菜谱每局的成功奖励 type&id&count
|
||||
failRewards: string; // 对应菜谱每局的失败安慰奖励 type&id&count
|
||||
// interface NovemberDataReturn {
|
||||
// buyCost: string; // 购买一次次数的消耗,type&id&count
|
||||
// maxBuyCnt: number; // 累积到现在可以购买的次数
|
||||
// buyCnt: number; // 累积到现在已经购买了的次数,buyCnt < maxBuyCnt 的时候才能购买
|
||||
// freeCnt: number; // 累计到现在可以免费玩的次数
|
||||
// todayPlayCnt: number; // 今天的次数,todayPlayCnt>0时才可以扫荡
|
||||
// playCnt: number; // 总共的次数,playCnt < freeCnt + buyCnt的时候才能玩新的
|
||||
|
||||
isPushBuyRec?: boolean; //
|
||||
}
|
||||
// menuIds: number[]; // 菜谱id
|
||||
// successRewards: string;// 每局的成功奖励 type&id&count
|
||||
// failRewards: string; // 每局的失败安慰奖励 type&id&count
|
||||
// }
|
||||
|
||||
|
||||
export class NovemberData extends ActivityBase {
|
||||
buyCost: string; // 购买一次次数的消耗,type&id&count
|
||||
maxBuyCnt: number = 0; // 累积到现在可以购买的次数
|
||||
buyCnt: number = 0; // 累积到现在已经购买了的次数,buyCnt < maxBuyCnt 的时候才能购买
|
||||
freeCnt: number = 0; // 累计到现在可以免费玩的次数
|
||||
todayPlayCnt: number = 0; // 今天的次数,todayPlayCnt>0时才可以扫荡
|
||||
playCnt: number = 0; // 总共的次数,playCnt < freeCnt + buyCnt的时候才能玩新的
|
||||
|
||||
menuIds: number[] = []; // 菜谱id
|
||||
successRewards: string;// 每局的成功奖励 type&id&count
|
||||
failRewards: string; // 每局的失败安慰奖励 type&id&count
|
||||
|
||||
records: NovemberRecord[] = [];
|
||||
menuMap = new Map<number, NovemberDataReturn>();
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
@@ -40,19 +48,18 @@ export class NovemberData extends ActivityBase {
|
||||
}
|
||||
|
||||
public initData(data: string): void {
|
||||
let novemberData: NovemberDataInDb[] = JSON.parse(data);
|
||||
if (!novemberData || novemberData.length == 0) return;
|
||||
for (const obj of novemberData) {
|
||||
let buyCost = obj?.buyCost || '&';
|
||||
let buyCnt = 0;
|
||||
let maxBuyCnt = this.todayIndex * (obj?.dailyBuyCnt || 0);
|
||||
let playCnt = 0;
|
||||
let maxPlayCnt = this.todayIndex * (obj?.dailyFreeCnt || 0);
|
||||
let successRewards = obj?.successRewards || '&';
|
||||
let failRewards = obj?.failRewards || '&'
|
||||
this.menuMap.set(obj.menuId, { dayIndex: obj.dayIndex, menuId: obj.menuId, buyCost, buyCnt, maxBuyCnt, playCnt, maxPlayCnt, successRewards, failRewards, isPushBuyRec: true })
|
||||
}
|
||||
let novemberData: NovemberDataInDb = JSON.parse(data);
|
||||
if (!novemberData) return;
|
||||
|
||||
this.buyCost = novemberData.buyCost || '&';
|
||||
this.maxBuyCnt = (novemberData.dailyBuyCnt || 0) * this.todayIndex;
|
||||
this.buyCnt = 0;
|
||||
this.freeCnt = (novemberData.dailyFreeCnt) * this.todayIndex;
|
||||
this.todayPlayCnt = 0;
|
||||
this.playCnt = 0;
|
||||
this.menuIds = novemberData.menuIds || [];
|
||||
this.successRewards = novemberData.successRewards || '&';
|
||||
this.failRewards = novemberData.failRewards || '&';
|
||||
}
|
||||
|
||||
public setPlayerRecords(playerData: ActivityNovemberRecModelType) {
|
||||
@@ -61,23 +68,13 @@ export class NovemberData extends ActivityBase {
|
||||
|
||||
public updatePlayerRecord(playerData: ActivityNovemberRecModelType) {
|
||||
if (!playerData) return;
|
||||
this.buyCnt = playerData?.buyCnt || 0
|
||||
if (playerData.records) {
|
||||
this.records = playerData.records;
|
||||
for (const { menuId, isPass } of playerData.records) {
|
||||
if (!isPass) continue;
|
||||
let menu = this.menuMap.get(menuId);
|
||||
menu.playCnt += 1;
|
||||
this.menuMap.set(menuId, menu);
|
||||
|
||||
}
|
||||
}
|
||||
if (playerData.buyRec) {
|
||||
for (const { menuId, buyCnt } of playerData.buyRec) {
|
||||
let menu = this.menuMap.get(menuId);
|
||||
menu.buyCnt += buyCnt;
|
||||
menu.maxPlayCnt += buyCnt;
|
||||
menu.isPushBuyRec = false;
|
||||
this.menuMap.set(menuId, menu);
|
||||
this.records = playerData?.records || [];
|
||||
for (const data of playerData.records) {
|
||||
let { todayIndex, isSuccess, hasPass } = data;
|
||||
if (todayIndex == this.todayIndex && isSuccess) this.todayPlayCnt++;
|
||||
if (hasPass) this.playCnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +82,15 @@ export class NovemberData extends ActivityBase {
|
||||
public getShowResult() {
|
||||
return {
|
||||
...this.getBaseKeys(),
|
||||
menus: [...this.menuMap.values()]
|
||||
buyCost: this.buyCost,
|
||||
maxBuyCnt: this.maxBuyCnt,
|
||||
buyCnt: this.buyCnt,
|
||||
freeCnt: this.freeCnt,
|
||||
todayPlayCnt: this.todayPlayCnt,
|
||||
playCnt: this.playCnt,
|
||||
menuIds: this.menuIds,
|
||||
successRewards: this.successRewards,
|
||||
failRewards: this.failRewards,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user