活动:新武将抽卡活动
This commit is contained in:
@@ -14,6 +14,7 @@ export class LandItem {
|
||||
saveMax: number //银行存钱最大数额
|
||||
takeOutMax: number //银行取钱最大次数
|
||||
shopActivityId: number //商店对应的商店id
|
||||
shoppingCountMax: number //逛商店次数
|
||||
|
||||
record: any[] = []; //历史操作
|
||||
stopCount: number //停留次数
|
||||
@@ -27,6 +28,7 @@ export class LandItem {
|
||||
this.saveMax = data.saveMax;
|
||||
this.takeOutMax = data.takeOutMax;
|
||||
this.shopActivityId = data.shopActivityId;
|
||||
this.shoppingCountMax = data.shoppingCountMax;
|
||||
this.record = [];
|
||||
this.stopCount = 0;
|
||||
}
|
||||
|
||||
72
shared/domain/activityField/newHeroGachaField.ts
Normal file
72
shared/domain/activityField/newHeroGachaField.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityNewHeroGachaModelType } from '../../db/ActivityNewHeroGacha';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
import { parseGoodStr, splitString } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
// 每个英雄的奖池配置数据
|
||||
export class NewHeroGachaItem {
|
||||
floorCount: number = 0;//保底最大的次数,一定会出现一次
|
||||
count: number = 0;//多少次没有抽中
|
||||
hid: number = 0;//武将id
|
||||
name: string = '';//名字
|
||||
cost: RewardInter[];//每次抽卡消耗资源
|
||||
floorReward: number = 0;//保底奖励,percent下标+1
|
||||
percent: { id: number, weight: number, goodId: number }[];//奖品百分比 contentId & percent & id(英雄hid,物品id)
|
||||
|
||||
constructor(data: any) {
|
||||
this.hid = data.hid;
|
||||
this.name = data.name;
|
||||
this.floorCount = data.floorCount;
|
||||
this.cost = parseGoodStr(data.cost);
|
||||
this.percent = [];
|
||||
this.floorReward = data.floorReward;
|
||||
this.count = 0;
|
||||
let arr = data.percent.split('|').filter(obj => { return obj && obj != '' });
|
||||
for (let obj of arr) {
|
||||
let numArr = splitString(obj, '&');
|
||||
this.percent.push({
|
||||
id: numArr[0],
|
||||
weight: numArr[1],
|
||||
goodId: numArr.length > 2 ? numArr[2] : 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 每日关卡活动数据
|
||||
export class NewHeroGachaData extends ActivityBase {
|
||||
list: NewHeroGachaItem[] = [];
|
||||
|
||||
public findItem(hid: number) {
|
||||
let index = this.list.findIndex(obj => { return obj && obj.hid == hid })
|
||||
return (index != -1) ? this.list[index] : null;
|
||||
}
|
||||
|
||||
//解析玩家记录
|
||||
public setPlayerRecords(data: ActivityNewHeroGachaModelType[]) {
|
||||
for (let item of this.list) {
|
||||
let index = data.findIndex(obj => { return obj.hid == item.hid });
|
||||
if (index != -1) {
|
||||
item.count = data[index].count ? data[index].count : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj = JSON.parse(data);
|
||||
let arr = dataObj;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new NewHeroGachaItem(obj))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
super(activityData)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
}
|
||||
@@ -58,11 +58,11 @@ export class RefreshShopData extends ActivityBase {
|
||||
nextRefreshTime: number;//下次刷新时间
|
||||
roundIndex: number = 1;//周期数从1开始
|
||||
|
||||
public findItemByProductID(productID: string) {
|
||||
public findItemByProductID(productID: string): RefreshShopItem {
|
||||
for (let pageData of this.list) {
|
||||
let index = pageData.items.findIndex(obj => { return obj && obj.productID === productID });
|
||||
if (index != -1) {
|
||||
this.list[index]
|
||||
return pageData.items[index]
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user