500抽:活动格式
This commit is contained in:
@@ -57,6 +57,7 @@ export enum ACTIVITY_TYPE {
|
||||
TASK_PASS = 42, // 战令活动
|
||||
GUILD_PAY = 43, // 军团充值人数
|
||||
SHOP = 44, // 限时商店
|
||||
GUIDE_GACHA = 45, // 500抽
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,4 +218,9 @@ export enum DAILY_COIN_BOX_STATUS {
|
||||
CAN_NOT_OPEN = 0, // 不可打开
|
||||
CAN_OPEN = 1, // 可以打开
|
||||
RECEIVED = 2, // 已领取
|
||||
}
|
||||
|
||||
export enum GUIDE_GACHA_STAGE {
|
||||
PULL = 1, // 抽卡阶段
|
||||
DECIDE = 2, // 决定阶段
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { getZeroPointD } from '../pubUtils/timeUtil';
|
||||
import { RECRUIT } from '../pubUtils/dicParam';
|
||||
import { Candidate, SimpleResult } from '../domain/activityField/guideGachaField';
|
||||
|
||||
export class Floor {
|
||||
@prop({ required: true })
|
||||
@@ -36,28 +37,6 @@ class Turntable {
|
||||
hasGet: boolean; // 是否得到
|
||||
}
|
||||
|
||||
export class SimpleResult {
|
||||
@prop({ required: true })
|
||||
planId: number;
|
||||
@prop({ required: true })
|
||||
hid: number;
|
||||
@prop({ required: true })
|
||||
isTransfer: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 特殊引导候选列表
|
||||
* @memberof UserGacha
|
||||
*/
|
||||
class Candidate {
|
||||
@prop({ required: true })
|
||||
id: number; // 列表id
|
||||
@prop({ required: true })
|
||||
guideCount: number; // 引导次数
|
||||
@prop({ required: true, type: SimpleResult, _id: false })
|
||||
list: SimpleResult[]; // 是否得到
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家抽卡表
|
||||
**/
|
||||
@@ -115,15 +94,12 @@ export default class UserGacha extends BaseModel {
|
||||
|
||||
// 初始特殊引导
|
||||
@prop({ required: true, default: 0 })
|
||||
guideCount: number; // 预抽卡次数
|
||||
pullCnt: number; // 预抽卡次数
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
guideResultCount: number; // 预抽卡次数
|
||||
|
||||
@prop({ required: true, type: SimpleResult, default: [], _id: false })
|
||||
@prop({ required: true, type: () => SimpleResult, default: [], _id: false })
|
||||
guideResultList: SimpleResult[]; // 预抽卡结果
|
||||
|
||||
@prop({ required: true, type: Candidate, default: [], _id: false })
|
||||
@prop({ required: true, type: () => Candidate, default: [], _id: false })
|
||||
candidates: Candidate[]; // 预抽卡候选
|
||||
|
||||
public static async findAllByRole(roleId: string) {
|
||||
|
||||
@@ -1,47 +1,9 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityBase } from './activityField';
|
||||
import { prop } from '@typegoose/typegoose';
|
||||
import { UserGachaType } from '../../db/UserGacha';
|
||||
import { getTimeFun } from '../../pubUtils/timeUtil';
|
||||
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { getGachaRemainFloor } from '../../pubUtils/util';
|
||||
|
||||
|
||||
// 抽卡数据
|
||||
export class GachaData extends ActivityBase {
|
||||
gachaId: number = 0;
|
||||
heroes: Array<number> = [];
|
||||
|
||||
pickHero: number;
|
||||
freeCount: number;
|
||||
refFreeTime: number = 0;
|
||||
count: number;
|
||||
floor: Floor[];
|
||||
|
||||
public initData(data: string) {
|
||||
let obj = JSON.parse(data);
|
||||
this.gachaId = obj.gachaId;
|
||||
this.heroes = obj.heroes;
|
||||
}
|
||||
|
||||
public setUserGacha(userGacha: UserGachaType) {
|
||||
let dicGacha = gameData.gacha.get(this.gachaId);
|
||||
this.pickHero = userGacha.pickHero;
|
||||
this.freeCount = userGacha.freeCount;
|
||||
if (dicGacha.free.count > 0) {
|
||||
let f = getTimeFun(userGacha.refFreeTime);
|
||||
this.refFreeTime = <number>f.getAfterDayWithHour(dicGacha.free.day);
|
||||
}
|
||||
this.count = userGacha.count;
|
||||
this.floor = userGacha.floor;
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 保底记录
|
||||
* @memberof UserGacha
|
||||
@@ -88,7 +50,6 @@ export class GachaListReturn {
|
||||
freeCount: number = 0; // 免费次数
|
||||
refFreeTime: number = 0; // 免费次数下次刷新时间
|
||||
count: number = 0; // 整体已抽卡次数
|
||||
guideResultCount: number = 0; // 引导已抽卡次数
|
||||
remainFloor: number = 0; // 还剩多少次可以保底
|
||||
hope: Hope[] = []; // 心愿单
|
||||
point: number = 0; // 积分
|
||||
@@ -110,7 +71,6 @@ export class GachaListReturn {
|
||||
this.point = userGacha.point;
|
||||
this.turntable = userGacha.turntable;
|
||||
this.pickHero = userGacha.pickHero;
|
||||
this.guideResultCount = userGacha.guideResultCount||0;
|
||||
}
|
||||
this.remainFloor = getGachaRemainFloor(this.gachaId, userGacha?.floor||[]);
|
||||
}
|
||||
|
||||
67
shared/domain/activityField/guideGachaField.ts
Normal file
67
shared/domain/activityField/guideGachaField.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityBase } from './activityField';
|
||||
import { prop } from '@typegoose/typegoose';
|
||||
import { getTimeFunM } from '../../pubUtils/timeUtil';
|
||||
import { UserGachaType } from '../../db/UserGacha';
|
||||
import { GUIDE_GACHA_STAGE } from '../../consts';
|
||||
|
||||
|
||||
|
||||
export class SimpleResult {
|
||||
@prop({ required: true })
|
||||
planId: number;
|
||||
@prop({ required: true })
|
||||
hid: number;
|
||||
@prop({ required: true })
|
||||
isTransfer: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 特殊引导候选列表
|
||||
* @memberof UserGacha
|
||||
*/
|
||||
export class Candidate {
|
||||
@prop({ required: true })
|
||||
id: number; // 列表id
|
||||
@prop({ required: true })
|
||||
isChosen: boolean; // 是否被选中
|
||||
@prop({ required: true })
|
||||
pullCnt: number; // 引导第几次保存的
|
||||
@prop({ required: true, type: () => SimpleResult, _id: false })
|
||||
list: SimpleResult[]; // 列表
|
||||
}
|
||||
|
||||
interface GuideGachaDataInDb {
|
||||
gachaId: number; // 抽卡卡池id
|
||||
chooseTime: number; // 开始后几天内可以选卡
|
||||
}
|
||||
|
||||
// 抽卡数据
|
||||
export class GuideGachaData extends ActivityBase {
|
||||
gachaId: number = 0;
|
||||
stage: GUIDE_GACHA_STAGE = GUIDE_GACHA_STAGE.PULL;
|
||||
chooseTime: number = 0;
|
||||
pullCnt: number = 0;
|
||||
hasChoosen: boolean = false;
|
||||
candidates: Candidate[] = [];
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime);
|
||||
this.initData(activityData.data);
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let obj: GuideGachaDataInDb = JSON.parse(data);
|
||||
this.gachaId = obj.gachaId;
|
||||
this.chooseTime = <number>getTimeFunM(this.beginTime).getAfterDayWithHour(obj.chooseTime);
|
||||
this.stage = Date.now() < this.chooseTime? GUIDE_GACHA_STAGE.PULL: GUIDE_GACHA_STAGE.DECIDE;
|
||||
}
|
||||
|
||||
public setPlayerData(userGacha: UserGachaType) {
|
||||
if(userGacha) {
|
||||
this.pullCnt = userGacha.pullCnt;
|
||||
this.candidates = userGacha.candidates;
|
||||
this.hasChoosen = userGacha.candidates.findIndex(cur => cur.isChosen) != -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user