活动:寻宝骑兵添加首页奖励内容

This commit is contained in:
qiaoxin
2021-06-03 15:55:40 +08:00
parent b628f0704a
commit fff8ef153d
7 changed files with 176 additions and 139 deletions

View File

@@ -1,9 +1,41 @@
import { random } from 'underscore';
import { ActivityModelType } from '../../db/Activity';
import { ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHuntShop';
import { ActivityTreasureHuntTaskModelType } from '../../db/ActivityTreasureHuntTask';
import { ActivityTreasureHuntTreasureShopModelType } from '../../db/ActivityTreasureHuntTreasureShop';
import { ActivityTreasureHuntFirstPageModelType } from '../../db/ActivityTreasureHuntFirstPage';
import { splitString } from '../../pubUtils/util';
import { ActivityBase } from './activityField';
// 进入活动首页的数据
export class TreasureHuntFirstPageData {
name: string = '';//页签名字
index: number = 0;//下标
reward: string = '';//奖励
isReceive: boolean = false;//是否领取
public setPlayerFirstPageRecord(record: ActivityTreasureHuntFirstPageModelType) {
this.isReceive = false;
if (!record) {
return;
}
this.isReceive = record.isReceive ? record.isReceive : false;
}
public initData(data: any) {
this.name = data.name;
this.index = data.index;
this.reward = data.reward;
this.isReceive = false;
}
constructor(data: any) {
this.initData(data)
}
}
/************************************************************/
//购买价格
export class ConsumeData {
@@ -160,15 +192,21 @@ export class TreasureHuntChallengeData {
name: string = '';//页签名字
index: number = 0;//下标
consume: string = '';//消耗
count: number = 0;//碎片需求量
fixReward: string = '';//消耗
jackpotReward: string = '';//消耗
warid: string = '';//随机的关卡号
fixReward: string = '';//客户端显示奖励
jackpotReward: string = '';//客户端显示奖励
public randomGK() {
let gkArray = splitString(this.warid, '&');
let index = random(gkArray.length - 1);
return gkArray[index];
}
public initData(data: any) {
this.name = data.name;
this.index = data.index;
this.consume = data.consume;
this.count = data.count;
this.warid = data.warid;
this.fixReward = data.fixReward;
this.jackpotReward = data.jackpotReward;
}
@@ -247,6 +285,7 @@ export class TreasureHuntData extends ActivityBase {
name: string = '';//活动名字
day: string = '';//活动持续时间
roundIndex = 0;//周期数
firstPage: TreasureHuntFirstPageData = null;//首页奖励
shop: TreasureHuntShopData = null; //每日物资
tasks: TreasureHuntTaskData = null; //寻宝备战
challenge: TreasureHuntChallengeData = null;//寻宝大冒险
@@ -259,10 +298,26 @@ export class TreasureHuntData extends ActivityBase {
this.day = dataObj.day;
let arr = dataObj.data;
this.shop = new TreasureHuntShopData(arr[0]);
this.tasks = new TreasureHuntTaskData(arr[1]);
this.challenge = new TreasureHuntChallengeData(arr[2]);
this.treasureShop = new TreasureHuntTreasureShopData(arr[3]);
{
let index = arr.findIndex(obj => { return obj.index === 1 });
this.firstPage = new TreasureHuntFirstPageData(arr[index]);
}
{
let index = arr.findIndex(obj => { return obj.index === 2 });
this.shop = new TreasureHuntShopData(arr[index]);
}
{
let index = arr.findIndex(obj => { return obj.index === 3 });
this.tasks = new TreasureHuntTaskData(arr[index]);
}
{
let index = arr.findIndex(obj => { return obj.index === 4 });
this.challenge = new TreasureHuntChallengeData(arr[index]);
}
{
let index = arr.findIndex(obj => { return obj.index === 5 });
this.treasureShop = new TreasureHuntTreasureShopData(arr[index]);
}
}
constructor(activityData: ActivityModelType) {