新武将活动:修改字段以及ur武将处理
This commit is contained in:
@@ -6,12 +6,10 @@ import { ActivityBase } from './activityField';
|
||||
/******* 存在数据库里的数据 *******/
|
||||
interface NewHeroGkWarInDb {
|
||||
warId: number; // 关卡id
|
||||
icon: string; // 图标文件名
|
||||
startDay: number; // 活动第几天开启
|
||||
}
|
||||
|
||||
interface NewHeroGkDataInDb {
|
||||
bg: string; // 背景图
|
||||
wars: NewHeroGkWarInDb[]; // 关卡
|
||||
}
|
||||
|
||||
@@ -19,13 +17,11 @@ interface NewHeroGkDataInDb {
|
||||
// 每日关卡活动数据
|
||||
export class NewHeroGachaWar {
|
||||
warId: number; // 关卡id
|
||||
icon: string; // 图标文件名
|
||||
startTime: number; // 活动第几天开启,13位时间戳
|
||||
isSuccess: boolean = false; // 是否成功
|
||||
|
||||
constructor(data: NewHeroGkWarInDb, beginTime: number) {
|
||||
this.warId = data.warId;
|
||||
this.icon = data.icon;
|
||||
this.startTime = <number>getTimeFunM(beginTime).getAfterDayWithHour(data.startDay - 1);
|
||||
}
|
||||
|
||||
@@ -35,7 +31,6 @@ export class NewHeroGachaWar {
|
||||
}
|
||||
|
||||
export class NewHeroGKData extends ActivityBase {
|
||||
bg: string; // 背景图
|
||||
wars: NewHeroGachaWar[] = []; // 关卡
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
@@ -45,7 +40,6 @@ export class NewHeroGKData extends ActivityBase {
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj: NewHeroGkDataInDb = JSON.parse(data);
|
||||
this.bg = dataObj.bg;
|
||||
let arr = dataObj.wars||[];
|
||||
for (let obj of arr) {
|
||||
this.wars.push(new NewHeroGachaWar(obj, this.beginTime))
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import moment = require('moment');
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityNewHeroGiftModelType } from '../../db/ActivityNewHeroGift';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
/******* 存在数据库里的数据 *******/
|
||||
interface NewHeroGiftExplain {
|
||||
index: number;
|
||||
explain: string;
|
||||
}
|
||||
|
||||
interface NewHeroGiftRewardInDb {
|
||||
index: number; // 下标
|
||||
cover: string; // 翻牌背面的图片文件名
|
||||
reward: string; // 奖励 type&id&count
|
||||
countMax: number; // 最多抽出次数
|
||||
}
|
||||
|
||||
interface NewHeroGiftDataInDb {
|
||||
hid: number; // 左侧的立绘武将
|
||||
position: string; // 位置 x&y
|
||||
explain: NewHeroGiftExplain[]; // 玩法说明
|
||||
startTaskTime: string; // 开始计算任务积分的时间 hh:mm:ss
|
||||
rewards: NewHeroGiftRewardInDb[]; // 奖励
|
||||
consumePoint: number; // 每转一次消耗的点数
|
||||
}
|
||||
@@ -26,14 +19,12 @@ interface NewHeroGiftDataInDb {
|
||||
/******* 返回给客户端的数据 *******/
|
||||
class NewHeroGiftReward {
|
||||
index: number; // 下标
|
||||
cover: string; // 翻牌背面的图片文件名
|
||||
reward: string; // 奖励 type&id&count
|
||||
countMax: number; // 最多抽出次数
|
||||
buyCount: number = 0; // 转出的次数
|
||||
|
||||
constructor(data: NewHeroGiftRewardInDb) {
|
||||
this.index = data.index;
|
||||
this.cover = data.cover;
|
||||
this.reward = data.reward;
|
||||
this.countMax = data.countMax;
|
||||
}
|
||||
@@ -44,11 +35,9 @@ class NewHeroGiftReward {
|
||||
}
|
||||
|
||||
export class NewHeroGiftData extends ActivityBase {
|
||||
hid: number; // 左侧的立绘武将
|
||||
position: string; // 位置 x&y
|
||||
consumePoint: number; // 每转一次消耗的点数
|
||||
explain: NewHeroGiftExplain[]; // 玩法说明
|
||||
rewards: NewHeroGiftReward[] = []; // 奖励
|
||||
startTaskTime: number; // 开始计算任务积分的时间 时间戳
|
||||
|
||||
totalPoint: number = 0; // 已获得的点数
|
||||
consumeTotalPoint: number = 0; // 总消耗的点数
|
||||
@@ -60,14 +49,12 @@ export class NewHeroGiftData extends ActivityBase {
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj: NewHeroGiftDataInDb = JSON.parse(data);
|
||||
this.hid = dataObj.hid;
|
||||
this.position = dataObj.position;
|
||||
this.consumePoint = dataObj.consumePoint;
|
||||
this.explain = dataObj.explain
|
||||
let arr = dataObj.rewards||[];
|
||||
for (let obj of arr) {
|
||||
this.rewards.push(new NewHeroGiftReward(obj))
|
||||
}
|
||||
this.startTaskTime = moment(moment(this.beginTime).format(`YYYY-MM-DD ${dataObj.startTaskTime}`)).valueOf();
|
||||
}
|
||||
|
||||
public findItem(index: number) {
|
||||
@@ -88,4 +75,7 @@ export class NewHeroGiftData extends ActivityBase {
|
||||
}
|
||||
}
|
||||
|
||||
public canRecordTaskPoint() {
|
||||
return Date.now() >= this.startTaskTime && Date.now() <= this.endTime
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user