diff --git a/game-server/app/servers/activity/handler/gachaHandler.ts b/game-server/app/servers/activity/handler/gachaHandler.ts index 5747e93f7..81209cb1e 100644 --- a/game-server/app/servers/activity/handler/gachaHandler.ts +++ b/game-server/app/servers/activity/handler/gachaHandler.ts @@ -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) { diff --git a/game-server/app/services/activity/gachaService.ts b/game-server/app/services/activity/gachaService.ts index 22f745158..355484fe8 100644 --- a/game-server/app/services/activity/gachaService.ts +++ b/game-server/app/services/activity/gachaService.ts @@ -118,7 +118,7 @@ class PlayerGachaRecord { let userHope = this.hope.find(cur => cur.hid == hid); if(userHope && !userHope.hasGet) userHope.hasGet = true; } - + public getUserGachaParam() { return { hope: this.hope, floor: this.floor } } @@ -464,7 +464,7 @@ export class GachaPull { // 心愿单 private processHope() { - if(this.gachaType != GACHA_TYPE.NORMAL) return; + if(this.gachaType != GACHA_TYPE.NORMAL && this.gachaType != GACHA_TYPE.ARTIFACT) return; for(let gachaResult of this.result.list) { if(gachaResult.heroQuality != HERO_QUALITY_TYPE.GOLD) continue; // 只有橙将 let { dic: { id: randHopePosition } } = getRandEelmWithWeight(gameData.gachaHope); diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 83f6d87bb..e25701e72 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -969,6 +969,7 @@ export enum GACHA_TYPE { GUIDE = 4, // 限时 ACTIVITY = 5, // 新武将活动 TAUTOR = 6, // 百家争鸣祈灵 + ARTIFACT = 7, // 宝物招募 } export enum GACHA_PLAN_TYPE { diff --git a/shared/pubUtils/dictionary/DicArtifact.ts b/shared/pubUtils/dictionary/DicArtifact.ts index 3268ec2cc..039a1ca02 100644 --- a/shared/pubUtils/dictionary/DicArtifact.ts +++ b/shared/pubUtils/dictionary/DicArtifact.ts @@ -30,6 +30,8 @@ export interface DicArtifact { readonly lvAttrPlan: number; // 升品配置方案 readonly qualityAttrPlan: number; + // 是否可以许愿 + readonly canHope: number; } type KeysEnum = { [P in keyof Required]: true }; @@ -47,6 +49,7 @@ const DicArtifactKeys: KeysEnum = { seids: true, lvAttrPlan: true, qualityAttrPlan: true, + canHope: true } export const dicArtifact = new Map(); export const dicArtifactByGid = new Map();