抽卡:修改抽卡奖池逻辑
This commit is contained in:
@@ -4,9 +4,8 @@ import { prop } from '@typegoose/typegoose';
|
||||
import { UserGachaType } from '../../db/UserGacha';
|
||||
import { getTimeFun } from '../../pubUtils/timeUtil';
|
||||
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
|
||||
import { GACHA_CONTENT_TYPE, } from '../../consts';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { getFloorStatus } from '../../pubUtils/util';
|
||||
import { getGachaRemainFloor } from '../../pubUtils/util';
|
||||
|
||||
|
||||
// 抽卡数据
|
||||
@@ -85,11 +84,12 @@ export class Turntable {
|
||||
*/
|
||||
export class GachaListReturn {
|
||||
gachaId: number; // dicGacha里的id
|
||||
gachaType: number;
|
||||
freeCount: number = 0; // 免费次数
|
||||
refFreeTime: number = 0; // 免费次数下次刷新时间
|
||||
count: number = 0; // 整体已抽卡次数
|
||||
guideResultCount: number = 0; // 引导已抽卡次数
|
||||
floor: {id: number, count: number}[] = []; // 整体保底
|
||||
remainFloor: number = 0; // 还剩多少次可以保底
|
||||
hope: Hope[] = []; // 心愿单
|
||||
point: number = 0; // 积分
|
||||
turntable: Turntable[] = []; // 转盘记录
|
||||
@@ -97,6 +97,7 @@ export class GachaListReturn {
|
||||
|
||||
constructor(dicGacha: DicGacha, userGacha: UserGachaType) {
|
||||
this.gachaId = dicGacha.id;
|
||||
this.gachaType = dicGacha.gachaType;
|
||||
|
||||
if (userGacha) {
|
||||
this.freeCount = userGacha.freeCount;
|
||||
@@ -105,21 +106,19 @@ export class GachaListReturn {
|
||||
this.refFreeTime = <number>f.getAfterDayWithHour(dicGacha.free.day);
|
||||
}
|
||||
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;
|
||||
this.guideResultCount = userGacha.guideResultCount||0;
|
||||
} else {
|
||||
this.floor = getFloorStatus(dicGacha.id, []);
|
||||
this.remainFloor = getGachaRemainFloor(this.gachaId, userGacha.floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class GachaResult {
|
||||
export class GachaResultIndb {
|
||||
@prop({ required: true })
|
||||
contentId: number; // 抽卡内容id
|
||||
planId: number = 0; // 计划id
|
||||
@prop({ required: true })
|
||||
hid: number = 0; // 武将id
|
||||
@prop({ required: true })
|
||||
@@ -128,52 +127,19 @@ export class GachaResult {
|
||||
id: number = 0; // 道具id
|
||||
@prop({ required: true })
|
||||
count: number = 0; // 道具数量
|
||||
pickHero: number = 0;
|
||||
|
||||
constructor(contentId: number, id?: number) {
|
||||
this.contentId = contentId;
|
||||
if(id) this.pickHero = id;
|
||||
constructor(gachaResult: Partial<GachaResultIndb>) {
|
||||
this.planId = gachaResult.planId;
|
||||
this.hid = gachaResult.hid;
|
||||
this.isTransfer = gachaResult.isTransfer;
|
||||
this.id = gachaResult.id;
|
||||
this.count = gachaResult.count;
|
||||
}
|
||||
|
||||
setContentId(contentId: number, id?: number) {
|
||||
this.contentId = contentId;
|
||||
if(id) this.pickHero = id;
|
||||
}
|
||||
|
||||
setHidOrGid(id: number, count: number) {
|
||||
let dicGachaContent = gameData.gachaContent.get(this.contentId);
|
||||
if(!dicGachaContent) return;
|
||||
|
||||
if(dicGachaContent.type == GACHA_CONTENT_TYPE.HERO) {
|
||||
this.setHero(id, count);
|
||||
} else {
|
||||
this.setItem(id, count||dicGachaContent.count);
|
||||
}
|
||||
}
|
||||
|
||||
setHero(hid: number, count: number) {
|
||||
this.hid = hid;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
setItem(id: number, count: number) {
|
||||
this.id = id;
|
||||
if(count) this.count = count;
|
||||
}
|
||||
|
||||
transferToPiece(id: number, count: number) {
|
||||
this.isTransfer = true;
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
copy() {
|
||||
let result = new GachaResult(this.contentId);
|
||||
result.hid = this.hid;
|
||||
result.isTransfer = this.isTransfer;
|
||||
result.id = this.id;
|
||||
result.count = this.count;
|
||||
result.pickHero = this.pickHero;
|
||||
return result
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user