import { ActivityModelType } from '../../db/Activity'; import { ActivityBase } from './activityField'; import { prop } from '@typegoose/typegoose'; import { UserGachaType } from '../../db/UserGacha'; import { getSeconds } from '../../pubUtils/timeUtil'; import { DicGacha } from '../../pubUtils/dictionary/DicGacha'; import { getFloorStatus } from '../../services/gachaService'; // 抽卡数据 export class GachaData extends ActivityBase { gachaId: number = 0; heroes: Array = []; public initData(data: string) { let obj = JSON.parse(data); this.gachaId = obj.gachaId; this.heroes = obj.heroes; } constructor(activityData: ActivityModelType) { super(activityData) } } /** * @description 保底记录 * @memberof UserGacha */ export class Floor { @prop({ required: true }) id: number; // 保底类型 1-紫将保底 2-金将保底 3-指定将保底 @prop({ required: true }) count: number; // 抽卡次数 } /** * @description 心愿单 * @memberof UserGacha */ export class Hope { @prop({ required: true }) id: number; // 位置 @prop({ required: true }) hid: number; // 武将id @prop({ required: true }) hasGet: boolean; // 是否得到 } /** * @description 转盘记录 * @memberof UserGacha */ export class Turntable { @prop({ required: true }) quality: number; // 品质 @prop({ required: true }) hasGet: boolean; // 是否得到 } /** * @description 获取抽卡界面的返回参数 */ export class GachaListReturn { gachaId: number; // dicGacha里的id freeCount: number = 0; // 免费次数 refFreeTime: number = 0; // 免费次数下次刷新时间 count: number = 0; // 整体已抽卡次数 floor: Floor[] = []; // 整体保底 hope: Hope[] = []; // 心愿单 point: number = 0; // 积分 turntable: Turntable[]; // 转盘记录 pickHero: number = 0; // 玩家选择的武将 constructor(dicGacha: DicGacha, userGacha: UserGachaType) { this.gachaId = dicGacha.id; if(userGacha) { this.freeCount = dicGacha.free.count - userGacha.freeCount; this.refFreeTime = getSeconds(userGacha.refFreeTime); this.count = userGacha.count; this.floor = getFloorStatus(dicGacha.id, userGacha.floor); this.hope = userGacha.hope; this.point = userGacha.point; this.turntable = userGacha.turntable; this.pickHero = userGacha.pickHero; } else { this.floor = getFloorStatus(dicGacha.id, []); } } }