diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts index fae95cfbb..694a07c7c 100644 --- a/game-server/app/servers/gm/handler/gmRoleHandler.ts +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -113,6 +113,64 @@ export class GmRoleHandler { return resResult(STATUS.SUCCESS); } + /** + * 升级英雄装备至限制内的最高级 + * + * @param {{ roleId: string, hid: number }} msg + * @param {BackendSession} session + * @return {*} + * @memberof GmRoleHandler + */ + async upgradeHeroEPlace(msg: { roleId: string, hid: number }, session: BackendSession) { + let { roleId, hid } = msg; + let hero = await HeroModel.findByHidAndRole(hid, roleId); + if (!hero) return resResult(STATUS.HERO_NOT_FIND); + /* + * 通过 + * dic_zyz_equipQuality.json + * dic_zyz_equipStar.json + * dic_zyz_equipStrength.json + * dic_zyz_artifactQuality.json + * 配置文件得出: + * maxLevel: 100 + * maxQuality: 5 (金) + * maxStar: 12 + * + * 限制: + * 装备等级不能超过hero等级 + * maxQuality限制等级最大值: 金 最大lv 100 + */ + const MAX_LV = 100; + const MAX_STAR = 12; + const MAX_QUALITY = 5; + // 装备升级、升星、升品(注意升级限制) + let ePlaceIds: number[] = []; + hero.ePlace.forEach((ePlaceItem) => { + // 升级 - 最大等级100 + ePlaceItem.lv = hero.lv; // 英雄等级肯定小于MAX_LV + // 升品 - 金 + ePlaceItem.quality = MAX_QUALITY; + ePlaceItem.qualityStage = 0; + // 生星 - 最高12 + ePlaceItem.star = MAX_STAR; + ePlaceItem.starStage = 0; + + ePlaceIds.push(ePlaceItem.id); + }); + + // 战力重算 + let { sid } = await getRoleOnlineInfo(roleId); + hero.ePlace.forEach(async (ePlaceItem) => { + // 装备升品 + await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_QUALITY, roleId, hero.serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId: ePlaceItem.id }); + // 装备升星 + await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STAR, roleId, hero.serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId: ePlaceItem.id, skinId: hero.skinId }); + }); + // 装备强化 + const { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, roleId, hero.serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceIds }); + // 返回强化,升星,升品后的hero数据 + return resResult(STATUS.SUCCESS, { curHero }); + } async deleteHero(msg: { roleId: string, hid: number }, session: BackendSession) { let { roleId, hid } = msg; diff --git a/game-server/test/gm.test.ts b/game-server/test/gm.test.ts new file mode 100644 index 000000000..78423f673 --- /dev/null +++ b/game-server/test/gm.test.ts @@ -0,0 +1,59 @@ +import { Client } from './Client'; +import 'mocha'; +import { PinusWSClient } from 'pinus-robot-plugin'; +import { expect } from 'chai'; +import { addItemsIfNotEnough, checkSuccessResponse } from './CheckPatten'; +import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE, AUCTION_STAGE, DIVIDEND_STATUS, LOT_STATUS } from '../app/consts'; + +describe('gm测试', function () { + let pinusClient: PinusWSClient; + let roleInfo; + // 装备最大等级 + const MAX_LV = 100; + // 装备最大star + const MAX_STAR = 12; + // 装备最大品质 + const MAX_QUALITY = 5; + + before(function (done) { + const c = new Client(); + const timer = setInterval(() => { + if (c.client) { + pinusClient = c.client; + roleInfo = c.roleInfo; + clearInterval(timer); + done(); + } + }, 500); + }); + + after(function (done) { + pinusClient.disconnect(); + // disconnect 后等待 500ms,供服务器清理环境、退出频道等 + setTimeout(() => { + done(); + }, 500); + }); + + // 请修改 gm/filter/tokenFilter 中的代码,将鉴权的代码注释掉,接口就能调用了 + it.skip('武将装备强化-升品-升星-到当前最高', function (done) { + // 测试参数: roleId: "6inQ1FHeSb"; rid:19 + const roleId = roleInfo.roleId, hid = 19; + pinusClient.request('gm.gmRoleHandler.upgradeHeroEPlace', { roleId, hid }, (res) => { + checkSuccessResponse(res); + expect(res.data.curHero.ePlace).to.be.an('array'); + res.data.curHero.ePlace.forEach(element => { + expect(element.stones).to.be.an('array'); + // 小于等于最大lv + expect(element.lv).to.lte(MAX_LV); + // 等于最大quality + expect(element.quality).to.eq(MAX_QUALITY); + // 等于最大star + expect(element.star).to.eq(MAX_STAR); + }); + + done(); + }); + }); + +}); diff --git a/shared/resource/jsons/dic_api.json b/shared/resource/jsons/dic_api.json index 45a35fe5f..73a706c58 100644 --- a/shared/resource/jsons/dic_api.json +++ b/shared/resource/jsons/dic_api.json @@ -943,5 +943,12 @@ "name": "更新服务器开服时间", "module": "sys", "type": "update" + }, + { + "id": 136, + "api": "gm.gmRoleHandler.upgradeHeroEPlace", + "name": "武将所有装备强化、升品、升星到当前最高", + "module": "user", + "type": "update" } ] \ No newline at end of file