活动:成长活动修改数据结构
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import { prop } from '@typegoose/typegoose';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivitySevenDaysModelType } from '../../db/ActivitySevenDays';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
// 每日配置数据
|
||||
export class SevenDayItem {
|
||||
dayIndex: number = 0;
|
||||
cellIndex: number = 0;
|
||||
count: number = 0;
|
||||
total: number = 0;
|
||||
isReceive: boolean = false;
|
||||
|
||||
constructor(dayIndex: number, cellIndex: number, count: number, total: number, isReceive: boolean) {
|
||||
this.dayIndex = dayIndex;//第几天奖励
|
||||
this.cellIndex = cellIndex;//某天第几个奖励
|
||||
this.count = count;//已经领取奖励的次数
|
||||
this.total = total;//总共可领取奖励次数
|
||||
this.isReceive = isReceive;//是否领取
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 七天乐活动数据
|
||||
export class SevenDaysData extends ActivityBase {
|
||||
items: Array<SevenDayItem> = [];
|
||||
|
||||
//解析玩家领取记录
|
||||
public setPlayerRecords(data: ActivitySevenDaysModelType[]) {
|
||||
for (let obj of this.items) {
|
||||
let index = data.findIndex(record => { return obj.dayIndex == record.dayIndex && obj.cellIndex == record.cellIndex })
|
||||
if (index != -1) {
|
||||
obj.count = data[index].count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let arr = JSON.parse(data);
|
||||
for (let obj of arr) {
|
||||
this.items.push(new SevenDayItem(obj.dayIndex, obj.cellIndex, obj.count, 0, false));
|
||||
}
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
super(activityData)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user