活动:添加新的任务统计
This commit is contained in:
@@ -2,10 +2,9 @@ import { TASK_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
|
||||
import { ActivityGrowthPointModelType } from '../../db/ActivityGrowthPoint';
|
||||
import { HeroType } from '../../db/Hero';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
import { parseGoodStrWithType, parseHeroStrWithType } from '../../pubUtils/util';
|
||||
import { CreateHeroParam } from '../roleField/hero';
|
||||
import { splitString } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
@@ -40,6 +39,7 @@ export class GrowthItem {
|
||||
condition: number; //任务数据条件 dic_zyz_taskType.jsonT
|
||||
point: number; // 任务达成获得的奖章数量,只在当前活动中有用,虚拟
|
||||
reward: string; // 任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
taskParamArray: number[];
|
||||
|
||||
totalCount: number = 0; //完成任务累计次数
|
||||
receiveRewardCount: number = 0; //领取奖励次数
|
||||
@@ -55,26 +55,8 @@ export class GrowthItem {
|
||||
this.reward = data.reward;
|
||||
this.totalCount = 0;
|
||||
this.receiveRewardCount = 0;
|
||||
}
|
||||
this.taskParamArray = splitString(data.taskParam, '&')
|
||||
|
||||
public heroReward(): CreateHeroParam[] {
|
||||
let rewardArray = [];
|
||||
let rewardData = this.reward.split('|').filter(obj => { return obj && obj != '' });
|
||||
for (let objStr of rewardData) {
|
||||
let reward = parseHeroStrWithType(objStr);
|
||||
rewardArray.push(reward);
|
||||
}
|
||||
return rewardArray.filter(obj => { return obj && obj.type == ACTIVITY_RESOURCES_TYPE.HERO })
|
||||
}
|
||||
|
||||
public goodReward(): RewardInter[] {
|
||||
let rewardArray = [];
|
||||
let rewardData = this.reward.split('|').filter(obj => { return obj && obj != '' });
|
||||
for (let objStr of rewardData) {
|
||||
let reward = parseGoodStrWithType(objStr);
|
||||
rewardArray.push(reward);
|
||||
}
|
||||
return rewardArray.filter(obj => { return obj && obj.type == ACTIVITY_RESOURCES_TYPE.GOODS })
|
||||
}
|
||||
|
||||
public canReceive(): boolean {
|
||||
@@ -146,7 +128,6 @@ export class GrowthData extends ActivityBase {
|
||||
|
||||
//第几天的奖章兑换
|
||||
public findPointItem(id: number) {
|
||||
console.log('ddddddddddd', JSON.stringify(this.pointRewardList), id)
|
||||
let index = this.pointRewardList.findIndex(obj => { return obj && obj.id === id })
|
||||
return (index != -1) ? this.pointRewardList[index] : null;
|
||||
}
|
||||
@@ -162,7 +143,7 @@ export class GrowthData extends ActivityBase {
|
||||
})
|
||||
}
|
||||
|
||||
//解析玩家领取记录
|
||||
//解析玩家积分兑换记录
|
||||
public setPlayerPointRecord(data: ActivityGrowthPointModelType) {
|
||||
if (!data) {
|
||||
return;
|
||||
@@ -176,17 +157,21 @@ export class GrowthData extends ActivityBase {
|
||||
}
|
||||
|
||||
//解析玩家领取记录
|
||||
public async setPlayerRecords(data: ActivityGrowthModelType[], roleId: string) {
|
||||
public async setPlayerRecords(data: ActivityGrowthModelType[], roleId: string, userHeroes: HeroType[]) {
|
||||
let { heroNum } = await RoleModel.findByRoleId(roleId);
|
||||
for (let obj of this.list) {
|
||||
let index = data.findIndex(record => { return obj.dayIndex == record.dayIndex && obj.cellIndex == record.cellIndex })
|
||||
if (index != -1) {
|
||||
obj.totalCount = data[index].totalCount ? data[index].totalCount : 0;
|
||||
|
||||
obj.receiveRewardCount = data[index].receiveRewardCount ? data[index].receiveRewardCount : 0;
|
||||
}
|
||||
if (obj.taskType === TASK_TYPE.HERO_NUM) {
|
||||
obj.totalCount = heroNum;
|
||||
} else if (obj.taskType === TASK_TYPE.HERO_LV) {
|
||||
obj.taskParam
|
||||
let lv = obj.taskParamArray[1];
|
||||
let heroes = userHeroes.filter(hero => { return hero.lv >= lv })
|
||||
obj.totalCount = heroes.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityBuyRecordsModelType } from '../../db/ActivityBuyRecords';
|
||||
import { ActivityGrowthFundModelType } from '../../db/ActivityGrowthFund';
|
||||
import { splitString } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
@@ -15,7 +16,7 @@ export class GrowthFundItem {
|
||||
condition: number; //0
|
||||
reward: string; // 任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
isComplete: boolean //是否完成任务
|
||||
|
||||
taskParamArray: number[]//
|
||||
// isReceive: boolean = false; //是否领取过奖励
|
||||
|
||||
constructor(data: any) {
|
||||
@@ -28,6 +29,8 @@ export class GrowthFundItem {
|
||||
this.condition = data.conditon;
|
||||
this.isComplete = false;
|
||||
// this.isReceive = false;
|
||||
this.taskParamArray = splitString(data.taskParam, '&')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,14 +73,14 @@ export class GrowthFundData extends ActivityBase {
|
||||
switch (this.type) {
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_MAIN:
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_MAIN_VIP: {
|
||||
if (!this.isReceive(page.pageIndex, item.cellIndex) && item.condition == condition) {
|
||||
if (!this.isReceive(page.pageIndex, item.cellIndex) && item.taskParamArray[1] == condition) {
|
||||
item.isComplete = true;
|
||||
items.push(Object.assign(item, { pageIndex: page.pageIndex, activityId: this.activityId }))
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_MAIN:
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_MAIN_VIP:
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_TOWER:
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_TOWER_VIP:
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE:
|
||||
case ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE_VIP: {
|
||||
if (!this.isReceive(page.pageIndex, item.cellIndex) && item.condition <= condition) {
|
||||
|
||||
Reference in New Issue
Block a user