抽卡:提供内部接口

This commit is contained in:
luying
2021-04-23 20:48:03 +08:00
parent 5c24e28d06
commit 2df7a9f1a0
4 changed files with 37 additions and 24 deletions

View File

@@ -2,10 +2,11 @@ import { ActivityModelType } from '../../db/Activity';
import { ActivityBase } from './activityField';
import { prop } from '@typegoose/typegoose';
import { UserGachaType } from '../../db/UserGacha';
import { getSeconds, getAfterDateByDay } from '../../pubUtils/timeUtil';
import { getAfterDateByDay } from '../../pubUtils/timeUtil';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { getFloorStatus } from '../../services/gachaService';
import { GACHA_OCCUPY_HID } from '../../consts';
import { gameData } from '../../pubUtils/data';
// 抽卡数据
@@ -13,12 +14,29 @@ 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) {
this.refFreeTime = getAfterDateByDay(userGacha.refFreeTime, dicGacha.free.day);
}
this.count = userGacha.count;
this.floor = userGacha.floor;
}
constructor(activityData: ActivityModelType) {
super(activityData)
}
@@ -78,7 +96,9 @@ export class GachaListReturn {
if(userGacha) {
this.freeCount = userGacha.freeCount;
this.refFreeTime = getAfterDateByDay(userGacha.refFreeTime, dicGacha.free.day);
if(dicGacha.free.count > 0) {
this.refFreeTime = getAfterDateByDay(userGacha.refFreeTime, dicGacha.free.day);
}
this.count = userGacha.count;
this.floor = getFloorStatus(dicGacha.id, userGacha.floor);
this.hope = userGacha.hope;