活动:寻宝骑兵-每日物资
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { UserOrderModelType } from '../../db/UserOrder';
|
||||
import { ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHuntShop';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
/************************************************************/
|
||||
@@ -41,6 +41,11 @@ export class TreasureHuntShopItem {
|
||||
}
|
||||
this.buyCount = 0;
|
||||
}
|
||||
|
||||
public getConsume() {
|
||||
let index = this.consume.findIndex(obj => { return obj && obj.count === this.buyCount + 1 });
|
||||
return (index != -1) ? this.consume[index].consume : '';
|
||||
}
|
||||
}
|
||||
|
||||
// 商店数据
|
||||
@@ -48,11 +53,25 @@ export class TreasureHuntShopData {
|
||||
name: string = '';//页签名字
|
||||
list: Array<TreasureHuntShopItem> = [];//商品
|
||||
|
||||
public getItem(cellIndex: number): TreasureHuntShopItem {
|
||||
let index = this.list.findIndex(obj => { return obj && obj.cellIndex === cellIndex })
|
||||
return (index != -1) ? this.list[index] : null;
|
||||
}
|
||||
|
||||
public setPlayerRecords(record: ActivityTreasureHuntShopModelType) {
|
||||
if (!record) {
|
||||
return;
|
||||
}
|
||||
for (let item of this.list) {
|
||||
let buyRecords = record.records.filter(obj => { obj.id === item.cellIndex });
|
||||
item.buyCount = buyRecords.length;
|
||||
}
|
||||
}
|
||||
|
||||
public initData(data: any) {
|
||||
this.name = data.name;
|
||||
let arr = data.data;
|
||||
for (let obj of arr) {
|
||||
console.log(JSON.stringify(obj))
|
||||
this.list.push(new TreasureHuntShopItem(obj))
|
||||
}
|
||||
}
|
||||
@@ -122,6 +141,8 @@ export class TreasureHuntData extends ActivityBase {
|
||||
roundIndex = 0;//周期数
|
||||
shop: TreasureHuntShopData = null;
|
||||
|
||||
|
||||
|
||||
public initData(data: any) {
|
||||
let dataObj = JSON.parse(data);
|
||||
this.name = dataObj.name;
|
||||
|
||||
Reference in New Issue
Block a user