🐞 fix(副将): pvp系统添加只设置副将的接口
This commit is contained in:
@@ -424,6 +424,44 @@ export class PvpHandler {
|
||||
return resResult(STATUS.SUCCESS, pick(result, ['attack', 'oppPlayers', 'buyAttackCnt', 'setAttackCnt', 'challengeCnt', 'challengeRefTime']));
|
||||
}
|
||||
|
||||
|
||||
// 只保存副将
|
||||
async saveAttackSub(msg: { heroes: { actorId: number, order: number, subHid: number }[] }, session: BackendSession) {
|
||||
let { heroes } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let serverId = session.get('serverId');
|
||||
|
||||
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
||||
if(!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
||||
|
||||
// 更新挑战阵容
|
||||
let oldAttack = pvpDefense.attack?.heroes||[];
|
||||
let scores: number[] = [];
|
||||
for(let { actorId, order, subHid } of heroes) {
|
||||
let oldData = oldAttack.find(cur => cur.actorId == actorId);
|
||||
if(!oldData || oldData.order != order) return resResult(STATUS.PVP_CAN_NOT_CHANGE_HERO);
|
||||
|
||||
if(isHeroHidden(actorId)) return resResult(STATUS.HERO_IS_HIDDEN);
|
||||
let heroScore = pvpDefense.heroScores.find(cur => cur.hid == actorId);
|
||||
if(heroScore) {
|
||||
scores.push(heroScore.score);
|
||||
}
|
||||
let dicHero = gameData.hero.get(actorId);
|
||||
if(subHid && (!dicHero || dicHero.urType != 1)) return resResult(STATUS.HERO_CAN_NOT_SET_SUB);
|
||||
if(subHid && heroes.findIndex(hero => hero.actorId == subHid) != -1) return resResult(STATUS.HERO_SUB_DUPLICATE);
|
||||
}
|
||||
let attack = new Attack(heroes, scores);
|
||||
let lineupCe = await generPvpLineupCe(roleId, pvpDefense.lineupCe, attack.heroes, pvpDefense.defense?.heroes??[], []);
|
||||
// 保存
|
||||
pvpDefense = await PvpDefenseModel.updateInfoAndInclude(roleId, { attack, lineupCe });
|
||||
// 返回
|
||||
let result = new PvpDataReturn();
|
||||
result.setPvpDefense(pvpDefense);
|
||||
|
||||
return resResult(STATUS.SUCCESS, pick(result, ['attack']));
|
||||
}
|
||||
|
||||
|
||||
// 获取存档列表
|
||||
async getSaveData(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
@@ -735,6 +735,7 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
break;
|
||||
}
|
||||
case "battle.pvpHandler.saveAttack":
|
||||
case "battle.pvpHandler.saveAttackSub":
|
||||
{
|
||||
let { heroes } = msg;
|
||||
if (!checkNaturalArray(heroes)) return false;
|
||||
|
||||
@@ -194,6 +194,7 @@ export const STATUS = {
|
||||
PVP_BUY_ATTACK_CNT_NOT_ENOUGH: { code: 20808, simStr: '购买挑战阵容次数不足' },
|
||||
PVP_SEASON_NOT_OPEN: { code: 20809, simStr: 'pvp赛季未开启' },
|
||||
PVP_CAN_NOT_SAVE_DEFENSE: { code: 20810, simStr: '结算期不可保存防守阵容' },
|
||||
PVP_CAN_NOT_CHANGE_HERO: { code: 20811, simStr: '只可用于设置副将不可变更武将' },
|
||||
|
||||
// 军团 20900-20999
|
||||
GUILD_AUTH_NOT_ENOUGH: { code: 20900, simStr: '权限不足' },
|
||||
|
||||
Reference in New Issue
Block a user