抽卡:免费抽卡次数

This commit is contained in:
luying
2022-08-03 11:27:20 +08:00
parent a77304b271
commit e1e9da4a80
7 changed files with 29 additions and 25 deletions

View File

@@ -3,6 +3,7 @@ import { UserGachaType } from '../../db/UserGacha';
import { getTimeFun } from '../../pubUtils/timeUtil';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { getGachaRemainFloor } from '../../pubUtils/util';
import { RewardInter } from '../../pubUtils/interface';
/**
* @description 保底记录
@@ -47,8 +48,8 @@ export class Turntable {
export class GachaListReturn {
gachaId: number; // dicGacha里的id
gachaType: number;
freeCount: number = 0; // 免费次数
refFreeTime: number = 0; // 免费次数下次刷新时间
isFree: boolean = false; // 免费次数
cost: RewardInter[] = []; // 消耗
count: number = 0; // 整体已抽卡次数
remainFloor: number = 0; // 还剩多少次可以保底
hope: Hope[] = []; // 心愿单
@@ -59,13 +60,10 @@ export class GachaListReturn {
constructor(dicGacha: DicGacha, userGacha: UserGachaType) {
this.gachaId = dicGacha.id;
this.gachaType = dicGacha.gachaType;
this.cost = dicGacha.cost;
if (userGacha) {
this.freeCount = userGacha.freeCount;
if (dicGacha.free.count > 0) {
let f = getTimeFun(userGacha.refFreeTime);
this.refFreeTime = <number>f.getAfterDayWithHour(dicGacha.free.day);
}
this.isFree = userGacha.freeCount < dicGacha.free.count;
this.count = userGacha.count;
this.hope = userGacha.hope;
this.point = userGacha.point;

View File

@@ -1,5 +1,7 @@
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 {
@@ -24,7 +26,8 @@ export class NewHeroGachaData extends ActivityBase {
uiType: number;
pickHero: number = 0;
count: number = 0;
freeCount: number = 0;
isFree: boolean = false; // 免费次数
cost: RewardInter[] = []; // 消耗
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
super(activityData, createTime, serverTime)
@@ -45,11 +48,13 @@ export class NewHeroGachaData extends ActivityBase {
}
//解析玩家记录
public setPlayerRecords(data: UserGachaType) {
if (!data) return;
this.pickHero = data.pickHero;
this.count = data.count;
this.freeCount = data.freeCount;
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) {