活动:成长活动修改数据结构

This commit is contained in:
qiaoxin
2021-04-21 19:20:14 +08:00
parent 68e38609d0
commit bc40d90f00
4 changed files with 75 additions and 26 deletions

View File

@@ -1,11 +1,11 @@
import { prop } from '@typegoose/typegoose';
import { ActivityModelType } from '../../db/Activity';
import { ActivitySevenDaysModelType } from '../../db/ActivitySevenDays';
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
import { ActivityBase } from './activityField';
// 每日配置数据
export class SevenDayItem {
export class GrowthItem {
dayIndex: number = 0;
cellIndex: number = 0;
count: number = 0;
@@ -22,13 +22,13 @@ export class SevenDayItem {
}
// 七天乐活动数据
export class SevenDaysData extends ActivityBase {
items: Array<SevenDayItem> = [];
// 成长活动数据
export class GrowthData extends ActivityBase {
list: Array<GrowthItem> = [];
//解析玩家领取记录
public setPlayerRecords(data: ActivitySevenDaysModelType[]) {
for (let obj of this.items) {
public setPlayerRecords(data: ActivityGrowthModelType[]) {
for (let obj of this.list) {
let index = data.findIndex(record => { return obj.dayIndex == record.dayIndex && obj.cellIndex == record.cellIndex })
if (index != -1) {
obj.count = data[index].count;
@@ -39,7 +39,7 @@ export class SevenDaysData extends ActivityBase {
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));
this.list.push(new GrowthItem(obj.dayIndex, obj.cellIndex, obj.count, 0, false));
}
}