活动:修改30天任务的数据结构

This commit is contained in:
qiaoxin
2021-06-01 18:35:10 +08:00
parent c49e861209
commit 8195913389
11 changed files with 78 additions and 57 deletions
@@ -1,9 +1,6 @@
import { ACTIVITY_RESOURCES_TYPE } from '../../consts';
import { ActivityModelType } from '../../db/Activity';
import { ActivityDailyGiftsModelType } from '../../db/ActivityDailyGifts';
import { RewardInter } from '../../pubUtils/interface';
import { parseGoodStrWithType, parseHeroStrWithType, parseResStr } from '../../pubUtils/util';
import { CreateHeroParam } from '../roleField/hero';
import { parseResStr } from '../../pubUtils/util';
import { ConsumeResParam } from '../activityField/consumeField';
import { ActivityBase } from './activityField';
@@ -69,7 +69,7 @@ export class DailyRMBGiftsData extends ActivityBase {
}
}
this.isBuy = data.isBuy;
this.isBuy = data.isBuy ? data.isBuy : false;
this.unReceiveCount = unReceiveCount;
if (this.isBuy && !isOver) {
this.unReceiveCount += 1;
@@ -1,3 +1,4 @@
import moment = require("moment");
import { ACTIVITY_TYPE } from "../../consts";
import { ActivityPopUpShopModelType } from "../../db/ActivityPopUpShop";
@@ -21,6 +22,8 @@ export class PopUpShopData {
isBuy: boolean = false; //购买过
beginTime: Date = null;//开始时间
endTime: Date = null;//结束时间
beginTimeStamp: number = 0;//开始时间
endTimeStamp: number = 0;//结束时间
//解析玩家开启的商店记录
public setPlayerRecords(data: ActivityPopUpShopModelType) {
@@ -30,6 +33,8 @@ export class PopUpShopData {
this.isBuy = data.isBuy ? data.isBuy : false;
this.beginTime = data.beginTime;
this.endTime = data.endTime;
this.beginTimeStamp = moment(data.beginTime).valueOf();
this.endTimeStamp = moment(data.endTime).valueOf();
this.totalCount = data.totalCount;
}
+14 -11
View File
@@ -1,10 +1,7 @@
import { ACTIVITY_RESOURCES_TYPE } from '../../consts';
import { ActivityModelType } from '../../db/Activity';
import { ActivityThirtyDaysModelType } from '../../db/ActivityThirtyDays';
import { ActivityThirtyDaysPointRewardModelType } from '../../db/ActivityThirtyDaysPointReward';
import { RewardInter } from '../../pubUtils/interface';
import { parseGoodStrWithType, parseHeroStrWithType, splitString } from '../../pubUtils/util';
import { CreateHeroParam } from '../roleField/hero';
import { splitString } from '../../pubUtils/util';
import { ActivityBase } from './activityField';
// 30天目标每个点兑换奖励的数据
@@ -58,11 +55,13 @@ export class ThirtyDaysPointItem {
// 30天目标每个奖励的数据
export class ThirtyDaysItem {
tab: number; // id
pageIndex: number; // 第几页,从1开始
cellIndex: number; // 第几个,从1开始
name: string; //名称
taskType: number; // 任务类型 dic_zyz_taskType.json
taskParam: string; //任务数据 dic_zyz_taskType.json
condition: number; //任务条件
taskParamArray: Array<number>; //任务数据 dic_zyz_taskType.json
reward: string; //任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
point: number; // 任务达成获得的奖励点,只在当前活动中有用,虚拟
@@ -71,12 +70,14 @@ export class ThirtyDaysItem {
isComplete: boolean = false; //是否完成任务
isReceive: boolean = false; //是否领取过奖励
constructor(data: any, pageIndex: number) {
constructor(data: any, pageIndex: number, cellIndex: number) {
this.tab = data.tab;
this.pageIndex = pageIndex;
this.cellIndex = data.cellIndex;
this.cellIndex = cellIndex;
this.name = data.name;
this.taskType = data.taskType;
this.taskParam = data.taskParam;
this.condition = data.condition;
this.reward = data.reward;
this.point = data.point;
@@ -98,7 +99,9 @@ export class ThirtyDaysPage {
this.name = data.name;
this.item = [];
for (let obj of data.item) {
this.item.push(new ThirtyDaysItem(obj, data.pageIndex));
for (let cellData of obj.taskList) {
this.item.push(new ThirtyDaysItem(cellData, data.pageIndex, obj.cellIndex));
}
}
}
}
@@ -195,10 +198,10 @@ export class ThirtyDaysData extends ActivityBase {
}
//完成的任务奖励内容
public findThirtyDaysItem(pageIndex: number, cellIndex: number): ThirtyDaysItem {
public findThirtyDaysItem(pageIndex: number, cellIndex: number, tab: number): ThirtyDaysItem {
let listIndex = this.list.findIndex(obj => { return obj && obj.pageIndex == pageIndex });
if (listIndex != -1) {
let itemIndex = this.list[listIndex].item.findIndex(obj => { return obj && obj.cellIndex == cellIndex });
let itemIndex = this.list[listIndex].item.findIndex(obj => { return obj && obj.cellIndex == cellIndex && obj.tab == tab });
if (itemIndex != -1) {
return this.list[listIndex].item[itemIndex];
}
@@ -223,10 +226,10 @@ export class ThirtyDaysData extends ActivityBase {
public setPlayerRecords(data: ActivityThirtyDaysModelType[]) {
this.totalPoint = 0;
for (let record of data) {
let itemData = this.findThirtyDaysItem(record.pageIndex, record.cellIndex)
let itemData = this.findThirtyDaysItem(record.pageIndex, record.cellIndex, record.tab)
if (itemData) {
itemData.isReceive = record.isReceive === true;
itemData.isComplete = record.totalCount >= itemData.taskParamArray[0];
itemData.isComplete = record.totalCount >= itemData.condition;
if (itemData.isReceive) {
this.totalPoint += itemData.point;
}