弹出礼包:购买

This commit is contained in:
陆莹
2022-03-15 21:01:21 +08:00
parent 319d4cf454
commit d9b907e80b
4 changed files with 72 additions and 67 deletions
+15 -1
View File
@@ -103,7 +103,7 @@ export class PopUpShopData extends ActivityBase {
}
}
private findPackageById(id: number) {
public findPackageById(id: number) {
let index = this.packageMap.get(id);
return this.packages[index];
}
@@ -119,6 +119,13 @@ export class PopUpShopData extends ActivityBase {
let item = pkg.findItemByProductID(productID);
return item.updateItem(dataItem);
}
public updateRecordById(data: ActivityPopUpShopModelType, id: number) {
let pkg = this.findPackageById(data.id);
let dataItem = data.items.find(cur => cur.id == id);
let item = pkg.findItemById(id);
return item.updateItem(dataItem);
}
}
// 同一礼包类型为一组,共享cd,档位
@@ -135,6 +142,7 @@ export class PopUpShopPackage {
items: PopShopItem[] = []; // 礼包
keyItem: PopUpShopKeyItem[] = []; // 关键资源限制,refreshDay内可以获得Y个
private itemByProductID: Map<string, number> = new Map(); // productID => index
private itemById: Map<number, number> = new Map();
private parent: PopUpShopData;
// setPlayerRecord的时候处理的数据
@@ -159,6 +167,7 @@ export class PopUpShopPackage {
let obj = new PopShopItem(item, this);
this.items.push(obj);
this.itemByProductID.set(obj.productID, this.items.length - 1);
this.itemById.set(obj.id, this.items.length - 1);
}
for(let key of data.keyItem) {
this.keyItem.push(new PopUpShopKeyItem(key));
@@ -175,6 +184,11 @@ export class PopUpShopPackage {
return this.items[index];
}
public findItemById(id: number) {
let index = this.itemById.get(id);
return this.items[index];
}
public addPlayerRecord(data: ActivityPopUpShopModelType) {
let now = new Date();
this.hasPushCnt++;