新将活动:活动格式
This commit is contained in:
@@ -1,104 +1,68 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityNewHeroGKModelType } from '../../db/ActivityNewHeroGK';
|
||||
import { getTimeFunM } from '../../pubUtils/timeUtil';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
// 每日配置数据
|
||||
export class NewHeroGKItem {
|
||||
pageIndex: number;
|
||||
begin: number; // 第几天开始,从1开始,1表示第一天0点开始
|
||||
end: number; // 第几天结束,2表示第二天24点结束
|
||||
index: number; // 下标
|
||||
gk: number; // 关卡
|
||||
name: string; // 名称
|
||||
reward: string; // 奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
|
||||
isSuccess: boolean; //是否成功
|
||||
|
||||
constructor(data: any, pageIndex: number) {
|
||||
this.pageIndex = pageIndex;
|
||||
this.begin = data.begin;
|
||||
this.end = data.end;
|
||||
this.index = data.index;
|
||||
this.gk = data.gk;
|
||||
this.name = data.name;
|
||||
this.reward = data.reward;
|
||||
this.isSuccess = false;
|
||||
}
|
||||
/******* 存在数据库里的数据 *******/
|
||||
interface NewHeroGkWarInDb {
|
||||
warId: number; // 关卡id
|
||||
icon: string; // 图标文件名
|
||||
startDay: number; // 活动第几天开启
|
||||
}
|
||||
|
||||
|
||||
// 每日配置数据
|
||||
export class NewHeroGKPage {
|
||||
items: Array<NewHeroGKItem> = [];
|
||||
pageIndex: number; // 页码
|
||||
name: string; // 名称
|
||||
hid: number; //武将id
|
||||
title: string = '';//客户端用说明文字
|
||||
|
||||
constructor(data: any) {
|
||||
this.pageIndex = data.pageIndex;
|
||||
this.name = data.name;
|
||||
this.hid = data.hid;
|
||||
this.title = data.title;
|
||||
this.items = [];
|
||||
for (let obj of data.items) {
|
||||
this.items.push(new NewHeroGKItem(obj, this.pageIndex))
|
||||
}
|
||||
}
|
||||
interface NewHeroGkDataInDb {
|
||||
bg: string; // 背景图
|
||||
wars: NewHeroGkWarInDb[]; // 关卡
|
||||
}
|
||||
|
||||
|
||||
// 每日关卡活动数据
|
||||
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);
|
||||
}
|
||||
|
||||
setPlayerRecord(isSuccess: boolean) {
|
||||
this.isSuccess = isSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
export class NewHeroGKData extends ActivityBase {
|
||||
list: Array<NewHeroGKPage> = [];
|
||||
name: string; // 名称
|
||||
|
||||
public findItemByGK(pageIndex: number, gk: number) {
|
||||
for (let pageData of this.list) {
|
||||
if (pageData.pageIndex == pageIndex) {
|
||||
let index = pageData.items.findIndex(obj => { return obj.gk == gk })
|
||||
return (index != -1) ? pageData.items[index] : null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public findNewHeroGKItem(pageIndex: number, dayIndex: number) {
|
||||
for (let pageData of this.list) {
|
||||
if (pageData.pageIndex == pageIndex) {
|
||||
let index = pageData.items.findIndex(obj => { return obj.begin <= dayIndex && obj.end >= dayIndex })
|
||||
return (index != -1) ? pageData.items[index] : null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//解析玩家记录
|
||||
public setPlayerRecords(data: ActivityNewHeroGKModelType) {
|
||||
if (!data)
|
||||
return;
|
||||
let records = data.records ? data.records : [];
|
||||
for (let pageData of this.list) {
|
||||
for (let item of pageData.items) {
|
||||
let index = records.findIndex(obj => { return pageData.pageIndex == obj.pageIndex && item.index == obj.index })
|
||||
if (index != -1) {
|
||||
item.isSuccess = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj = JSON.parse(data);
|
||||
this.name = dataObj.name;
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new NewHeroGKPage(obj))
|
||||
}
|
||||
}
|
||||
bg: string; // 背景图
|
||||
wars: NewHeroGachaWar[] = []; // 关卡
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
public findItemByGK(warId: number) {
|
||||
return this.wars.find(cur => cur.warId == warId);
|
||||
}
|
||||
|
||||
//解析玩家记录
|
||||
public setPlayerRecords(data: ActivityNewHeroGKModelType) {
|
||||
if (!data) return;
|
||||
let records = data.records||[];
|
||||
for (let data of records) {
|
||||
let item = this.findItemByGK(data.warId);
|
||||
if(item) item.setPlayerRecord(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +1,52 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityNewHeroGachaModelType } from '../../db/ActivityNewHeroGacha';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
import { parseGoodStr, splitString } from '../../pubUtils/util';
|
||||
import { UserGachaType } from '../../db/UserGacha';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
// 每个英雄的奖池配置数据
|
||||
export class NewHeroGachaItem {
|
||||
selected: boolean = false;//选中武将
|
||||
floorCount: number = 0;//保底最大的次数,一定会出现一次
|
||||
count: number = 0;//多少次没有抽中
|
||||
hasGetFloor: boolean = false; // 是否有抽到保底,伪随机算法,抽到后未到保底次数强制不给
|
||||
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)
|
||||
commonReward: string = "";//固定奖 格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
|
||||
constructor(data: any) {
|
||||
this.hid = data.hid;
|
||||
this.name = data.name;
|
||||
this.floorCount = data.floorCount;
|
||||
this.commonReward = data.commonReward;
|
||||
this.cost = parseGoodStr(data.cost);
|
||||
this.percent = [];
|
||||
this.floorReward = data.floorReward - 1;
|
||||
this.count = 0;
|
||||
this.selected = false;
|
||||
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,
|
||||
})
|
||||
}
|
||||
}
|
||||
interface NewHeroGachaItemInDb {
|
||||
hid: number;
|
||||
position: string; // x&y
|
||||
}
|
||||
|
||||
|
||||
interface NewHeroGachaDataInDb {
|
||||
gachaId: number; // dic_zyz_gacha表的id,卡池的概率,消耗都通过这个表读取
|
||||
icon: string; // 大地图的icon图片文件名
|
||||
heroes: NewHeroGachaItemInDb[]; // 本期活动pick的武将
|
||||
bg: string; // 首页背景图片
|
||||
uiType: number; // 布局格式,具体什么代表什么含义由策划和客户端定
|
||||
}
|
||||
|
||||
// 每日关卡活动数据
|
||||
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) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
for (let item of this.list) {
|
||||
item.count = data.count ? data.count : 0;
|
||||
item.hasGetFloor = data.hasGetFloor||false;
|
||||
item.selected = (data && data.selectedHid == item.hid);
|
||||
}
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj = JSON.parse(data);
|
||||
let arr = dataObj;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new NewHeroGachaItem(obj))
|
||||
}
|
||||
|
||||
}
|
||||
gachaId: number;
|
||||
icon: string;
|
||||
heroes: NewHeroGachaItemInDb[];
|
||||
bg: string;
|
||||
uiType: number;
|
||||
pickHero: number = 0;
|
||||
pullCnt: number = 0;
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public findItem(hid: number) {
|
||||
return this.heroes.find(obj => { return obj && obj.hid == hid })
|
||||
}
|
||||
|
||||
//解析玩家记录
|
||||
public setPlayerRecords(data: UserGachaType) {
|
||||
if (!data) return;
|
||||
this.pickHero = data.pickHero;
|
||||
this.pullCnt = data.pullCnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,37 +2,75 @@ import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityNewHeroGiftModelType } from '../../db/ActivityNewHeroGift';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 礼包的内容
|
||||
export class NewHeroGiftItem {
|
||||
index: number; // 下标
|
||||
reward: string; //任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
countMax: number = 0; //可购买的最大次数,0表示不限制
|
||||
name: string; //名字
|
||||
consumePoint: number; //消耗点数
|
||||
/******* 存在数据库里的数据 *******/
|
||||
interface NewHeroGiftExplain {
|
||||
index: number;
|
||||
explain: string;
|
||||
}
|
||||
|
||||
buyCount: number = 0; //兑换过的次数
|
||||
interface NewHeroGiftRewardInDb {
|
||||
index: number; // 下标
|
||||
cover: string; // 翻牌背面的图片文件名
|
||||
reward: string; // 奖励 type&id&count
|
||||
countMax: number; // 最多抽出次数
|
||||
}
|
||||
|
||||
constructor(data: any) {
|
||||
interface NewHeroGiftDataInDb {
|
||||
hid: number; // 左侧的立绘武将
|
||||
position: string; // 位置 x&y
|
||||
explain: NewHeroGiftExplain[]; // 玩法说明
|
||||
rewards: NewHeroGiftRewardInDb[]; // 奖励
|
||||
consumePoint: number; // 每转一次消耗的点数
|
||||
}
|
||||
|
||||
/******* 返回给客户端的数据 *******/
|
||||
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;
|
||||
this.name = data.name;
|
||||
this.consumePoint = data.consumePoint;
|
||||
this.buyCount = 0;
|
||||
}
|
||||
|
||||
addBuyCount() {
|
||||
this.buyCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// 新将礼包数据
|
||||
export class NewHeroGiftData extends ActivityBase {
|
||||
name: string = '';//活动名称
|
||||
list: Array<NewHeroGiftItem> = [];//礼包列表
|
||||
totalPoint: number = 0;//获得总点数
|
||||
consumeTotalPoint: number = 0;//消耗总点数
|
||||
explain: { index: number, explain: string }[] = [];//客户端用的说明文字信息
|
||||
hid: number; // 左侧的立绘武将
|
||||
position: string; // 位置 x&y
|
||||
consumePoint: number; // 每转一次消耗的点数
|
||||
explain: NewHeroGiftExplain[]; // 玩法说明
|
||||
rewards: NewHeroGiftReward[] = []; // 奖励
|
||||
|
||||
totalPoint: number = 0; // 已获得的点数
|
||||
consumeTotalPoint: number = 0; // 总消耗的点数
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj: NewHeroGiftDataInDb = JSON.parse(data);
|
||||
this.hid = dataObj.hid;
|
||||
this.position = dataObj.position;
|
||||
this.explain = dataObj.explain
|
||||
let arr = dataObj.rewards||[];
|
||||
for (let obj of arr) {
|
||||
this.rewards.push(new NewHeroGiftReward(obj))
|
||||
}
|
||||
}
|
||||
|
||||
public findItem(index: number) {
|
||||
let itemIndex = this.list.findIndex(obj => { return obj && obj.index === index });
|
||||
return (itemIndex != -1) ? this.list[itemIndex] : null;
|
||||
return this.rewards.find(obj => { return obj && obj.index === index });
|
||||
}
|
||||
|
||||
//解析玩家购买记录
|
||||
@@ -40,32 +78,13 @@ export class NewHeroGiftData extends ActivityBase {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
this.totalPoint = data.totalPoint ? data.totalPoint : 0;
|
||||
let records = data.records ? data.records : [];
|
||||
for (let item of this.list) {
|
||||
let buyRecords = records.filter(obj => { return obj && obj.index === item.index });
|
||||
item.buyCount = buyRecords.length;
|
||||
}
|
||||
this.totalPoint = data.totalPoint||0;
|
||||
let records = data.records||[];
|
||||
for (let obj of records) {
|
||||
let item = this.findItem(obj.index);
|
||||
if(item) item.addBuyCount();
|
||||
this.consumeTotalPoint += obj.point;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj = JSON.parse(data);
|
||||
this.name = dataObj.name;
|
||||
this.totalPoint = 0;
|
||||
this.consumeTotalPoint = 0;
|
||||
this.explain = dataObj.explain;
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new NewHeroGiftItem(obj))
|
||||
}
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user