✨ feat(抽卡): 宝物抽卡逻辑
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { resResult, shouldRefresh, getRandSingleEelm, getGachaRemainFloor } from "../../../pubUtils/util";
|
||||
import { STATUS, GACHA_TYPE, HERO_QUALITY_TYPE, TASK_TYPE, ITEM_CHANGE_REASON, } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { gameData, getDefArtifactByGid } from "../../../pubUtils/data";
|
||||
import { UserGachaModel } from "../../../db/UserGacha";
|
||||
import { refreshGacha, getGachaList, getVisitedHeroList, GachaPull, GachaResults, getDicGachaByGachaCnt, getNormalGachaId, getDicGachas } from "../../../services/activity/gachaService";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
@@ -144,18 +144,26 @@ export class GachaHandler {
|
||||
async setHope(msg: { gachaId: number, hope: { id: number, hid: number }[] }, session: BackendSession) {
|
||||
const { gachaId, hope } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
let dicGacha = gameData.gacha.get(gachaId);
|
||||
if (!dicGacha) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
for (let { hid } of hope) {
|
||||
if (hid != 0) {
|
||||
if (dicGacha.gachaType == GACHA_TYPE.NORMAL && hid != 0) {
|
||||
let dicRecruit = gameData.recruit.get(hid);
|
||||
if (!dicRecruit || !dicRecruit.canHope) {
|
||||
return resResult(STATUS.GACHA_HOPE_NOT_GOLD);
|
||||
}
|
||||
}
|
||||
if (dicGacha.gachaType == GACHA_TYPE.ARTIFACT && hid != 0) {
|
||||
let dicArtifact = getDefArtifactByGid(hid);
|
||||
if (!dicArtifact || !dicArtifact.canHope) {
|
||||
return resResult(STATUS.GACHA_HOPE_NOT_GOLD);
|
||||
}
|
||||
}
|
||||
}
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, 0);
|
||||
let { hope: userHope = []} = await refreshGacha(gameData.gacha.get(gachaId), userGacha);
|
||||
for (let { id, hid } of hope) {
|
||||
for (let { id, hid = 0 } of hope) {
|
||||
let curHope = userHope.find(cur => cur.id == id);
|
||||
if(curHope) {
|
||||
if(curHope.hasGet) {
|
||||
|
||||
Reference in New Issue
Block a user