新武将活动:修改字段以及ur武将处理

This commit is contained in:
luying
2022-10-12 10:35:14 +08:00
parent eccd9f0051
commit 9f5771e923
16 changed files with 79 additions and 69 deletions
@@ -1,33 +1,34 @@
import { ActivityModelType } from '../../db/Activity';
import { UserGachaType } from '../../db/UserGacha';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { RewardInter } from '../../pubUtils/interface';
import { ActivityBase } from './activityField';
interface NewHeroGachaItemInDb {
hid: number;
position: string; // x&y
isDefault: boolean;
}
interface NewHeroGachaDataInDb {
gachaId: number; // dic_zyz_gacha表的id,卡池的概率,消耗都通过这个表读取
icon: string; // 大地图的icon图片文件名
heroes: NewHeroGachaItemInDb[]; // 本期活动pick的武将
bg: string; // 首页背景图片
uiType: number; // 布局格式,具体什么代表什么含义由策划和客户端定
}
class NewHeroGachaItem {
hid: number;
isDefault: boolean;
constructor(hero: NewHeroGachaItemInDb) {
this.hid = hero.hid;
this.isDefault = hero.isDefault;
}
}
// 每日关卡活动数据
export class NewHeroGachaData extends ActivityBase {
gachaId: number;
icon: string;
heroes: NewHeroGachaItemInDb[];
bg: string;
uiType: number;
heroes: NewHeroGachaItem[] = [];
pickHero: number = 0;
count: number = 0;
isFree: boolean = false; // 免费次数
cost: RewardInter[] = []; // 消耗
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
super(activityData, createTime, serverTime)
@@ -37,25 +38,30 @@ export class NewHeroGachaData extends ActivityBase {
public initData(data: string) {
let dataObj: NewHeroGachaDataInDb = JSON.parse(data);
this.gachaId = dataObj.gachaId;
this.icon = dataObj.icon;
this.heroes = dataObj.heroes;
this.bg = dataObj.bg;
this.uiType = dataObj.uiType;
let heroes = dataObj.heroes||[];
for(let hero of heroes) {
this.heroes.push(new NewHeroGachaItem(hero))
}
}
public findItem(hid: number) {
return this.heroes.find(obj => { return obj && obj.hid == hid })
}
public getDefaultHero() {
let hero = this.heroes.find(obj => obj.isDefault)||this.heroes[0];
return hero?.hid||0;
}
//解析玩家记录
public setPlayerRecords(data: UserGachaType, dic: DicGacha) {
if(dic) this.cost = dic.cost;
if (data) {
this.pickHero = data.pickHero;
this.count = data.count;
this.isFree = data.freeCount < dic?.free.count;
}
}
public isPickHero(hid: number) {
return this.heroes.findIndex(cur => cur.hid == hid) != -1;