✨ feat(gm): 武将装备升级、升星、升品至最高级
This commit is contained in:
@@ -113,6 +113,64 @@ export class GmRoleHandler {
|
|||||||
return resResult(STATUS.SUCCESS);
|
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) {
|
async deleteHero(msg: { roleId: string, hid: number }, session: BackendSession) {
|
||||||
let { roleId, hid } = msg;
|
let { roleId, hid } = msg;
|
||||||
|
|||||||
59
game-server/test/gm.test.ts
Normal file
59
game-server/test/gm.test.ts
Normal file
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -943,5 +943,12 @@
|
|||||||
"name": "更新服务器开服时间",
|
"name": "更新服务器开服时间",
|
||||||
"module": "sys",
|
"module": "sys",
|
||||||
"type": "update"
|
"type": "update"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 136,
|
||||||
|
"api": "gm.gmRoleHandler.upgradeHeroEPlace",
|
||||||
|
"name": "武将所有装备强化、升品、升星到当前最高",
|
||||||
|
"module": "user",
|
||||||
|
"type": "update"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user