✨ feat(副将): pvp相关副将设置

This commit is contained in:
luying
2023-07-18 20:28:35 +08:00
parent a726681d25
commit c6455de8e4
17 changed files with 157 additions and 44 deletions
@@ -275,7 +275,7 @@ export class LadderHandler {
} }
// 9. 设置防守阵容 // 9. 设置防守阵容
async saveDefense(msg: { warId: number, heroes: { actorId: number, ai: number, dataId: number, order: number }[] }, session: BackendSession) { async saveDefense(msg: { warId: number, heroes: { actorId: number, ai: number, dataId: number, order: number, subHid?: number }[] }, session: BackendSession) {
let { warId, heroes } = msg; let { warId, heroes } = msg;
let roleId = session.get('roleId'); let roleId = session.get('roleId');
@@ -284,6 +284,12 @@ export class LadderHandler {
let hids: number[] = heroes.map(cur => cur.actorId); let hids: number[] = heroes.map(cur => cur.actorId);
if(isHeroHidden(...hids)) return resResult(STATUS.HERO_IS_HIDDEN); if(isHeroHidden(...hids)) return resResult(STATUS.HERO_IS_HIDDEN);
for(let { actorId, subHid } of heroes) {
let dicHero = gameData.hero.get(actorId);
if(!dicHero || dicHero.urType != 1) return resResult(STATUS.HERO_CAN_NOT_SET_SUB);
if(subHid && hids.indexOf(subHid) != -1) return resResult(STATUS.HERO_SUB_DUPLICATE);
}
let dbHeroes = await HeroModel.findByHidRange(hids, roleId, '_id hid ce', true); let dbHeroes = await HeroModel.findByHidRange(hids, roleId, '_id hid ce', true);
let defenseHeroes = heroes.map(cur => { let defenseHeroes = heroes.map(cur => {
@@ -449,7 +449,7 @@ export class PvpHandler {
} }
//3. 保存防守阵容 //3. 保存防守阵容
async saveDefense(msg: { heroes: { actorId: number, dataId: number, order: number, ai: number }[], warId: number, buff: number }, session: BackendSession) { async saveDefense(msg: { heroes: { actorId: number, dataId: number, order: number, ai: number, subHid?: number }[], warId: number, buff: number }, session: BackendSession) {
let { heroes, warId, buff } = msg; let { heroes, warId, buff } = msg;
let roleId = session.get('roleId'); let roleId = session.get('roleId');
if (heroes.length > LINEUP_NUM || heroes.length <= 0) { if (heroes.length > LINEUP_NUM || heroes.length <= 0) {
@@ -467,8 +467,11 @@ export class PvpHandler {
let refChallengeObj = await refChallengeCnt(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonEndTime, roleId, session.get('vipStartTime')); let refChallengeObj = await refChallengeCnt(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonEndTime, roleId, session.get('vipStartTime'));
// 更新防守阵容 // 更新防守阵容
let scores: number[] = [], heroIdMap = new Map<number, string>(), hids: number[] = []; let scores: number[] = [], heroIdMap = new Map<number, string>(), hids: number[] = [];
for(let { actorId } of heroes) { for(let { actorId, subHid } of heroes) {
if(isHeroHidden(actorId)) return resResult(STATUS.HERO_IS_HIDDEN); if(isHeroHidden(actorId)) return resResult(STATUS.HERO_IS_HIDDEN);
let dicHero = gameData.hero.get(actorId);
if(!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 heroScore = pvpDefense.heroScores.find(cur => cur.hid == actorId); let heroScore = pvpDefense.heroScores.find(cur => cur.hid == actorId);
if(heroScore) { if(heroScore) {
@@ -486,6 +489,7 @@ export class PvpHandler {
hids.push(actorId); hids.push(actorId);
} }
} }
let dbHeroes = await HeroModel.findByHidRange(hids, roleId, '_id hid ce', true); let dbHeroes = await HeroModel.findByHidRange(hids, roleId, '_id hid ce', true);
for(let hero of dbHeroes) { for(let hero of dbHeroes) {
heroIdMap.set(hero.hid, hero._id); heroIdMap.set(hero.hid, hero._id);
@@ -7,7 +7,7 @@ import { Application, BackendSession, ChannelService, HandlerService, pinus } fr
import { resResult, genCode, getRandSingleEelm } from "../../../pubUtils/util"; import { resResult, genCode, getRandSingleEelm } from "../../../pubUtils/util";
import { GVGLeagueModel } from '../../../db/GVGLeague'; import { GVGLeagueModel } from '../../../db/GVGLeague';
import { getGroupKey, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService'; import { getGroupKey, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getAllGVGCitiesInfo, leaveCity, refreshTeams, checkEnterCityTime, generNewLineup, getBattleRank, checkSettleStatus, getSpineCnt, getPlayerRanksByCity, getPlayerSettleRanksByCity } from '../../../services/gvg/gvgBattleService'; import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getAllGVGCitiesInfo, leaveCity, refreshTeams, checkEnterCityTime, generNewLineup, getBattleRank, checkSettleStatus, getSpineCnt, getPlayerRanksByCity, getPlayerSettleRanksByCity, checkGVGLineupWhenSave } from '../../../services/gvg/gvgBattleService';
import { getGVGBattleData } from '../../../services/memoryCache/gvgBattleData'; import { getGVGBattleData } from '../../../services/memoryCache/gvgBattleData';
import { GVGBattleRecModel } from '../../../db/GVGBattleRec'; import { GVGBattleRecModel } from '../../../db/GVGBattleRec';
import { getFightTimeByPeriod } from '../../../services/gvg/gvgFightService'; import { getFightTimeByPeriod } from '../../../services/gvg/gvgFightService';
@@ -69,6 +69,9 @@ export class GVGBattleHandler {
let { configId, period } = getGVGPeriodData(); let { configId, period } = getGVGPeriodData();
if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD); if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD);
let checkLineupResult = await checkGVGLineupWhenSave(roleId, index, lineup);
if(checkLineupResult.code != 0) return resResult(checkLineupResult);
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode); let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST); if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
let { leagueCode, name: leagueName } = myLeague; let { leagueCode, name: leagueName } = myLeague;
@@ -78,7 +81,12 @@ export class GVGBattleHandler {
let role = await RoleModel.findByRoleId(roleId, 'lv title'); let role = await RoleModel.findByRoleId(roleId, 'lv title');
let updateParam: SaveTeamUpdateParam = { index, head, spine, frame, roleName, serverId, leagueCode, leagueName, lv: role.lv, title: role.title } let updateParam: SaveTeamUpdateParam = { index, head, spine, frame, roleName, serverId, leagueCode, leagueName, lv: role.lv, title: role.title }
if(lineup) { if(lineup) {
let { isOK, heroes } = await checkBattleHeroesByHid(roleId, lineup.map(cur => cur.actorId)); let hids: number[] = [];
for(let { actorId, subHid } of lineup) {
hids.push(actorId);
if(subHid) hids.push(subHid);
}
let { isOK, heroes } = await checkBattleHeroesByHid(roleId, hids);
if(!isOK) return resResult(STATUS.BATTLE_HERO_NOT_FOUND); if(!isOK) return resResult(STATUS.BATTLE_HERO_NOT_FOUND);
let { newLineup, newLineupCe } = await generNewLineup(roleId, heroes, lineup); let { newLineup, newLineupCe } = await generNewLineup(roleId, heroes, lineup);
updateParam.lineup = newLineup; updateParam.lineup = newLineup;
@@ -87,7 +87,7 @@ export class GVGProduceHandler {
} }
// 编辑阵容 // 编辑阵容
async saveLineup(msg: { vestigeId: number, lineup: [{ actorId: number, dataId: number, order: number, correspondingVar: number }] }, session: BackendSession) { async saveLineup(msg: { vestigeId: number, lineup: [{ actorId: number, dataId: number, order: number, correspondingVar: number, subHid: number }] }, session: BackendSession) {
const roleId = session.get('roleId'); const roleId = session.get('roleId');
const serverId = session.get('serverId'); const serverId = session.get('serverId');
@@ -113,7 +113,7 @@ export class GVGProduceHandler {
let lineup = heroes.map(hero => { let lineup = heroes.map(hero => {
let curHero = dbHeroes.find(cur => cur.hid == hero.actorId); let curHero = dbHeroes.find(cur => cur.hid == hero.actorId);
return { actorId: curHero.hid, dataId: hero.dataId, order: hero.order, correspondingVar: hero.correspondingVar, ce: curHero.ce } return { actorId: curHero.hid, dataId: hero.dataId, order: hero.order, subHid: hero.subHid, correspondingVar: hero.correspondingVar, ce: curHero.ce }
}); });
let vestigeRank = await GVGVestigeRankModel.updateByRoleId(vestigeId, roleId, { lineup, hasDefense: true }); let vestigeRank = await GVGVestigeRankModel.updateByRoleId(vestigeId, roleId, { lineup, hasDefense: true });
@@ -296,7 +296,7 @@ export class GVGProduceHandler {
} }
// 布完阵开始挑战 // 布完阵开始挑战
async checkBattle(msg: { battleCode: string, heroes: [{ actorId: number, dataId: number, order: number }] }, session: BackendSession) { async checkBattle(msg: { battleCode: string, heroes: { actorId: number, dataId: number, order: number, subHid: number }[] }, session: BackendSession) {
const roleId = session.get('roleId'); const roleId = session.get('roleId');
const roleName = session.get('roleName'); const roleName = session.get('roleName');
@@ -778,11 +778,11 @@ export class HeroHandler {
let subHero = await HeroModel.findByHidAndRole(subHid, roleId); let subHero = await HeroModel.findByHidAndRole(subHid, roleId);
if(!subHero) return resResult(STATUS.HERO_NOT_FIND); if(!subHero) return resResult(STATUS.HERO_NOT_FIND);
await LadderMatchModel.removeBySub(roleId, subHid); // await LadderMatchModel.removeBySub(roleId, subHid);
await PvpSaveDataModel.removeBySub(roleId, subHid); // await PvpSaveDataModel.removeBySub(roleId, subHid);
await PvpDefenseModel.removeBySub(roleId, subHid); // await PvpDefenseModel.removeBySub(roleId, subHid);
await GVGVestigeRankModel.removeBySub(roleId, subHid); // await GVGVestigeRankModel.removeBySub(roleId, subHid);
await GVGTeamModel.removeBySub(roleId, subHid, subHero.ce); // await GVGTeamModel.removeBySub(roleId, subHid, subHero.ce);
} else { // 卸下 } else { // 卸下
if(!hero.subHid) return resResult(STATUS.HERO_CAN_NOT_REMOVE_SUB); if(!hero.subHid) return resResult(STATUS.HERO_CAN_NOT_REMOVE_SUB);
@@ -30,6 +30,7 @@ import { ArtifactModel } from "../../db/Artifact";
import { getHeroesAttributes } from "../playerCeService"; import { getHeroesAttributes } from "../playerCeService";
import { CounterModel } from "../../db/Counter"; import { CounterModel } from "../../db/Counter";
import { getGroupIdOfServer } from "../serverService"; import { getGroupIdOfServer } from "../serverService";
import { LineupHero } from "../../domain/roleField/hero";
/** /**
* 获取本联军上周占领的城池 * 获取本联军上周占领的城池
@@ -200,16 +201,18 @@ export async function refreshTeams(configId: number, groupKey: string, roleId: s
return teams return teams
} }
export async function generNewLineup(roleId: string, heroes: HeroType[], lineup: { actorId: number, dataId: number, order: number }[]) { export async function generNewLineup(roleId: string, heroes: HeroType[], lineup: { actorId: number, dataId: number, order: number, subHid?: number }[]) {
let attrByHid = await getHeroesAttributes(roleId); let attrByHid = await getHeroesAttributes(roleId);
let newLineup: GVGHeroInfo[] = [], newLineupCe = 0; let newLineup: GVGHeroInfo[] = [], newLineupCe = 0;
for(let { actorId, dataId, order } of lineup) { for(let { actorId, dataId, order, subHid } of lineup) {
let hero = heroes.find(cur => cur.hid == actorId); let hero = heroes.find(cur => cur.hid == actorId);
if(hero) { if(hero) {
let artifact = hero.artifact? await ArtifactModel.findbySeqId(roleId, hero.artifact): null; let artifact = hero.artifact? await ArtifactModel.findbySeqId(roleId, hero.artifact): null;
let heroInfo = new GVGHeroInfo(); let heroInfo = new GVGHeroInfo();
heroInfo.setHeroInfo(hero, artifact, []); heroInfo.setHeroInfo(hero, artifact, []);
heroInfo.setDataId(dataId, order); heroInfo.setDataId(dataId, order);
let subHero = heroes.find(cur => cur.hid == subHid);
if(subHero) heroInfo.setSubHero(subHero);
let attr = attrByHid.get(actorId); let attr = attrByHid.get(actorId);
if(!attr) continue; if(!attr) continue;
@@ -860,4 +863,36 @@ async function dispatchTeam(groupKey: string, cityId: number) {
let servers = pinus.app.getServersByType('guild'); let servers = pinus.app.getServersByType('guild');
let sid = (await dispatch(redisClient(), `${groupId}_${cityId}`, servers, 'guild'))?.id; let sid = (await dispatch(redisClient(), `${groupId}_${cityId}`, servers, 'guild'))?.id;
return sid; return sid;
}
/**
* 查询队伍中的武将是否可以使用
* @param roleId
* @param index
* @param lineup
* @returns
*/
export async function checkGVGLineupWhenSave(roleId: string, index: number, lineup: LineupHero[]) {
const teams = await GVGTeamModel.findByRole(roleId, '-_id index lineup');
for(let { actorId, subHid } of lineup) {
let dicHero = gameData.hero.get(actorId);
if(!dicHero || dicHero.urType != 1) return STATUS.HERO_CAN_NOT_SET_SUB;
for(let team of teams) {
// 查actorId没有在其他队伍中使用
if(team.index != index) {
let hasActor = team.lineup.find(hero => hero.actorId == actorId);
if(hasActor) return STATUS.GVG_TEAM_HERO_DUPLICATE;
}
// 查actorId没有在其他队伍作为副将
let hasActorIsSubHero = team.lineup.find(hero => hero.subHid == actorId);
if(hasActorIsSubHero) return STATUS.GVG_TEAM_HERO_USED_AS_SUB_HERO;
// 查副将
if(subHid) {
let hasSubHero = team.lineup.find(hero => hero.actorId == subHid);
if(hasSubHero) return STATUS.GVG_TEAM_SUB_HERO_DUPLICATE;
}
}
}
return STATUS.SUCCESS
} }
@@ -156,10 +156,14 @@ export async function getVestigeUsedHeroes(roleId: string, curVestigeId: number)
} }
// 是否在其他遗迹中使用过这个武将 // 是否在其他遗迹中使用过这个武将
export async function checkHeroIsUsedInOtherVestige(roleId: string, curVestigeId: number, heroes: { actorId: number }[]) { export async function checkHeroIsUsedInOtherVestige(roleId: string, curVestigeId: number, heroes: { actorId: number, subHid: number }[]) {
let usedHeroes = await getVestigeUsedHeroes(roleId, curVestigeId); let usedHeroes = await getVestigeUsedHeroes(roleId, curVestigeId);
for(let { actorId } of heroes) { for(let { actorId, subHid } of heroes) {
if(usedHeroes.indexOf(actorId) != -1) return true; if(usedHeroes.indexOf(actorId) != -1) return true;
// 查副将
if(subHid) {
if(usedHeroes.indexOf(subHid) != -1) return true;
}
} }
return false; return false;
} }
@@ -251,7 +255,7 @@ export async function generateAttackInfo(roleId: string, league: GVGLeagueType,
return info; return info;
} }
export async function generateAttackHeroInfo(lineup: { actorId: number, dataId: number, order: number }[], dbHeroes: HeroType[]) { export async function generateAttackHeroInfo(lineup: { actorId: number, dataId: number, order: number, subHid: number }[], dbHeroes: HeroType[]) {
let info = new OppPlayerInfo(); let info = new OppPlayerInfo();
info.setPlayerHeroes(dbHeroes, lineup); info.setPlayerHeroes(dbHeroes, lineup);
return info; return info;
@@ -265,7 +269,11 @@ export async function getOppDetailData(rec: GVGVestigeRecType) {
const dicWar = gameData.war.get(dicLadderDifficultRatio.gkId); const dicWar = gameData.war.get(dicLadderDifficultRatio.gkId);
const dicWarJson = gameData.warJson.get(dicWar.dispatchJsonId); const dicWarJson = gameData.warJson.get(dicWar.dispatchJsonId);
const defenseInfo = rec.defenseInfo.heroes||[]; const defenseInfo = rec.defenseInfo.heroes||[];
const hids = defenseInfo.map(cur => cur.hid); const hids: number[] = [];
for(let { hid, subHid } of defenseInfo) {
hids.push(hid);
if(subHid) hids.push(subHid);
}
const heroes = await HeroModel.findByHidRange(hids, rec.defenseRoleId, 'hid lv quality star colorStar skins ce skinId'); const heroes = await HeroModel.findByHidRange(hids, rec.defenseRoleId, 'hid lv quality star colorStar skins ce skinId');
const artifactSeids = heroes.map(hero => hero.artifact); const artifactSeids = heroes.map(hero => hero.artifact);
const artifacts = await ArtifactModel.findbySeqIds(rec.defenseRoleId, artifactSeids); const artifacts = await ArtifactModel.findbySeqIds(rec.defenseRoleId, artifactSeids);
@@ -299,7 +307,7 @@ export async function updateMyVestigeRank(isChange: boolean, atkData: GVGVestige
if(isChange) { if(isChange) {
if(atkData && !atkData.hasDefense) { // 只有第一次挑战且自己没有主动保存过阵容的时候才会这么保存 if(atkData && !atkData.hasDefense) { // 只有第一次挑战且自己没有主动保存过阵容的时候才会这么保存
let heroes = rec.attackInfo.heroes||[]; let heroes = rec.attackInfo.heroes||[];
let lineup = heroes.map(hero => ({ actorId: hero.hid, dataId: hero.dataId, order: hero.order, ce: hero.ce })); let lineup = heroes.map(hero => ({ actorId: hero.hid, dataId: hero.dataId, order: hero.order, ce: hero.ce, subHid: hero.subHid }));
update.lineup = lineup; update.lineup = lineup;
update.hasDefense = true; update.hasDefense = true;
needUpdate = true; needUpdate = true;
+14 -3
View File
@@ -1,6 +1,6 @@
import { ITEM_CHANGE_REASON, LADDER_OPP_STATUS, LADDER_SERVER_GAP_TIME, LADDER_STATUS, MAIL_TYPE, PUSH_ROUTE, REDIS_KEY, TA_USERSET_TYPE } from "../consts"; import { ITEM_CHANGE_REASON, LADDER_OPP_STATUS, LADDER_SERVER_GAP_TIME, LADDER_STATUS, MAIL_TYPE, PUSH_ROUTE, REDIS_KEY, TA_USERSET_TYPE } from "../consts";
import { ArtifactModel } from "../db/Artifact"; import { ArtifactModel } from "../db/Artifact";
import { HeroType } from "../db/Hero"; import { HeroModel, HeroType } from "../db/Hero";
import { LadderMatchModel, LadderMatchType, LadderUpdateInter } from "../db/LadderMatch"; import { LadderMatchModel, LadderMatchType, LadderUpdateInter } from "../db/LadderMatch";
import { LadderMatchRecModel, LadderMatchRecType } from "../db/LadderMatchRec"; import { LadderMatchRecModel, LadderMatchRecType } from "../db/LadderMatchRec";
import { RoleModel, RoleType } from "../db/Role"; import { RoleModel, RoleType } from "../db/Role";
@@ -270,6 +270,10 @@ export async function generateInitRecInfo(isRobot: boolean, isDefense: boolean,
let artifact = await ArtifactModel.findbySeqId(role.roleId, dbHero.artifact); let artifact = await ArtifactModel.findbySeqId(role.roleId, dbHero.artifact);
hero.setArtifact(artifact); hero.setArtifact(artifact);
} }
if(defenseHero.subHid) {
let subHero = await HeroModel.findByHidAndRole(defenseHero.subHid, role.roleId, 'hid skinId');
hero.setSubHero(subHero)
}
heroes.push(hero); heroes.push(hero);
} }
} }
@@ -419,9 +423,16 @@ export async function getLadderOppDetailData(rec: LadderMatchRecType) {
let hisLadderData = await LadderMatchModel.findByRoleIdAndInclude(rec.roleId2); let hisLadderData = await LadderMatchModel.findByRoleIdAndInclude(rec.roleId2);
let dicWar = gameData.war.get(dicLadderDifficultRatio.gkId); let dicWar = gameData.war.get(dicLadderDifficultRatio.gkId);
let dicWarJson = gameData.warJson.get(dicWar.dispatchJsonId); let dicWarJson = gameData.warJson.get(dicWar.dispatchJsonId);
let artifactSeids = hisLadderData.defense.heroes.map(cur => (<HeroType>cur.hero).artifact); let artifactSeids = [], subHids: number[] = [];
for(let { hero, subHid } of hisLadderData.defense.heroes) {
let dbHero = <HeroType>hero;
if(dbHero) artifactSeids.push(dbHero.artifact);
if(subHid) subHids.push(subHid);
}
let artifacts = await ArtifactModel.findbySeqIds(rec.roleId2, artifactSeids); let artifacts = await ArtifactModel.findbySeqIds(rec.roleId2, artifactSeids);
result.setByPlayer(hisLadderData, dicWarJson, artifacts); let subHeroes = await HeroModel.findByHidRange(subHids, rec.roleId2, 'hid skinId');
result.setByPlayer(hisLadderData, dicWarJson, artifacts, subHeroes);
let attrByHid = await getHeroesAttributes(rec.roleId2); let attrByHid = await getHeroesAttributes(rec.roleId2);
for(let [hid, attribute] of attrByHid) { for(let [hid, attribute] of attrByHid) {
result.setAttribute(hid, attribute.getAttributesToString()); result.setAttribute(hid, attribute.getAttributesToString());
+2 -1
View File
@@ -256,7 +256,8 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos
let ce = attr.calCe(); let ce = attr.calCe();
if(isNaN(ce)) ce = 0; if(isNaN(ce)) ce = 0;
heroInfo.setAttribute(attribute); heroInfo.setAttribute(attribute);
let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce); let subHero = h.subHid? dbHeroes.find(hero => hero.hid == h.subHid): null;
let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce, subHero);
enemy.setOutIndex(h.order); enemy.setOutIndex(h.order);
enemy.initial_ai = h.ai; enemy.initial_ai = h.ai;
heroes.push(enemy); heroes.push(enemy);
+3
View File
@@ -361,6 +361,9 @@ export const STATUS = {
GVG_TECH_HAS_PROGRESS: { code: 21344, simStr: '该科技进度不为0' }, GVG_TECH_HAS_PROGRESS: { code: 21344, simStr: '该科技进度不为0' },
GVG_LV_RESOURCE: { code: 21345, simStr: '该联军等级下该资源已满' }, GVG_LV_RESOURCE: { code: 21345, simStr: '该联军等级下该资源已满' },
GVG_BATTLE_IS_END: { code: 21346, simStr: '激战期已结束' }, GVG_BATTLE_IS_END: { code: 21346, simStr: '激战期已结束' },
GVG_TEAM_HERO_DUPLICATE: { code: 21347, simStr: '您的武将在其他队伍中已使用' },
GVG_TEAM_SUB_HERO_DUPLICATE: { code: 21348, simStr: '该副将在其他队伍中已使用' },
GVG_TEAM_HERO_USED_AS_SUB_HERO: { code: 21349, simStr: '该武将其他队伍中作为副将' },
// GVG征战中原 // GVG征战中原
GVG_VESTIGE_ERR: { code: 21350, simStr: '今日未开放该遗迹' }, GVG_VESTIGE_ERR: { code: 21350, simStr: '今日未开放该遗迹' },
+2
View File
@@ -14,6 +14,8 @@ export class Lineup {
ce: number; // 战力 ce: number; // 战力
@prop({ required: true }) @prop({ required: true })
correspondingVar?: number; correspondingVar?: number;
@prop({ required: true })
subHid: number; // 战力
} }
@index({ day: 1, groupKey: 1, vestigeId: 1, rank: 1 }) @index({ day: 1, groupKey: 1, vestigeId: 1, rank: 1 })
+23 -6
View File
@@ -25,14 +25,17 @@ export class LadderDefenseHero {
hero: Ref<Hero>; hero: Ref<Hero>;
@prop({ required: true }) @prop({ required: true })
ce: number; ce: number;
@prop({ required: false })
subHid: number;
constructor(param: { actorId: number, ai: number, dataId: number, order: number }, heroId: string, ce: number) { constructor(param: { actorId: number, ai: number, dataId: number, order: number, subHid?: number }, heroId: string, ce: number) {
this.actorId = param.actorId; this.actorId = param.actorId;
this.ai = param.ai; this.ai = param.ai;
this.dataId = param.dataId; this.dataId = param.dataId;
this.order = param.order; this.order = param.order;
this.hero = heroId; this.hero = heroId;
this.ce = ce; this.ce = ce;
this.subHid = param.subHid||0;
} }
} }
@@ -80,6 +83,10 @@ export class LadderOppPlayerHeroInfo {
colorStar: number; // 彩星 colorStar: number; // 彩星
@prop({ required: true }) @prop({ required: true })
lv: number; // 等级 lv: number; // 等级
@prop({ required: true })
subHid: number; // 副将
@prop({ required: true })
subActorId: number; // 副将(纯武将)
@prop({ required: true, type: HeroArtifact, _id: false }) @prop({ required: true, type: HeroArtifact, _id: false })
artifact: HeroArtifact[] = []; // 等级 artifact: HeroArtifact[] = []; // 等级
@@ -112,6 +119,11 @@ export class LadderOppPlayerHeroInfo {
setArtifact(artifact: ArtifactModelType) { setArtifact(artifact: ArtifactModelType) {
if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv }); if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv });
} }
setSubHero(hero: HeroType) {
this.subHid = hero?.skinId||0;
this.subActorId = hero?.hid||0;
}
} }
// ladderMatchRec // ladderMatchRec
@@ -180,12 +192,14 @@ export class LadderDefenseHeroReturn {
ai: number; // ai逻辑,1-进攻型 2-防守型 ai: number; // ai逻辑,1-进攻型 2-防守型
dataId: number; dataId: number;
order: number; order: number;
subHid: number;
constructor(defenseHero: LadderDefenseHero) { constructor(defenseHero: LadderDefenseHero) {
this.actorId = defenseHero.actorId; this.actorId = defenseHero.actorId;
this.ai = defenseHero.ai; this.ai = defenseHero.ai;
this.dataId = defenseHero.dataId; this.dataId = defenseHero.dataId;
this.order = defenseHero.order; this.order = defenseHero.order;
this.subHid = defenseHero.subHid||0;
} }
} }
@@ -362,7 +376,7 @@ export class LadderOppDetailHeroReturn {
subActorId: number = 0; subActorId: number = 0;
artifacts: HeroArtifact[] = []; artifacts: HeroArtifact[] = [];
constructor(warJson: DicWarJson, defensHero: LadderDefenseHero, artifacts: ArtifactModelType[]) { constructor(warJson: DicWarJson, defensHero: LadderDefenseHero, artifacts: ArtifactModelType[], subHero: HeroType) {
this.dataId = warJson.dataId; this.dataId = warJson.dataId;
this.relation = warJson.relation; this.relation = warJson.relation;
this.dirction = warJson.dirction; this.dirction = warJson.dirction;
@@ -390,12 +404,14 @@ export class LadderOppDetailHeroReturn {
let skin = hero.skins.find(cur => cur.enable); let skin = hero.skins.find(cur => cur.enable);
if(skin) this.talent = skin.talent; if(skin) this.talent = skin.talent;
this.job = hero.job; this.job = hero.job;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
let artifact = artifacts.find(cur => cur.seqId == hero.artifact); let artifact = artifacts.find(cur => cur.seqId == hero.artifact);
if(artifact) this.artifacts.push({ artifactId: artifact.artifactId, lv: artifact.lv }); if(artifact) this.artifacts.push({ artifactId: artifact.artifactId, lv: artifact.lv });
} }
} }
if(subHero) {
this.subHid = subHero?.skinId||0;
this.subActorId = subHero?.hid||0;
}
} }
setAttribute(attribute: string) { setAttribute(attribute: string) {
@@ -426,7 +442,7 @@ export class LadderOppDetailReturn {
} }
} }
setByPlayer(ladderMatch: LadderMatchType, warJsons: DicWarJson[], artifacts: ArtifactModelType[]) { setByPlayer(ladderMatch: LadderMatchType, warJsons: DicWarJson[], artifacts: ArtifactModelType[], subHeroes: HeroType[]) {
this.isRobot = false; this.isRobot = false;
let role = <RoleType>ladderMatch.role; let role = <RoleType>ladderMatch.role;
this.title = role.title; this.title = role.title;
@@ -436,7 +452,8 @@ export class LadderOppDetailReturn {
for(let hero of heroes) { for(let hero of heroes) {
let warJson = warJsons.find(cur => cur.dataId == hero.dataId); let warJson = warJsons.find(cur => cur.dataId == hero.dataId);
if(warJson) { if(warJson) {
let obj = new LadderOppDetailHeroReturn(warJson, hero, artifacts); let subHero = subHeroes.find(sub => sub.hid == hero.subHid);
let obj = new LadderOppDetailHeroReturn(warJson, hero, artifacts, subHero);
this.heroes.push(obj); this.heroes.push(obj);
this.defCe += hero.ce; this.defCe += hero.ce;
} }
+7 -2
View File
@@ -18,12 +18,15 @@ export class DefenseHeroInSaveData {
dataId: number; dataId: number;
@prop({ required: true }) @prop({ required: true })
order: number; order: number;
@prop({ required: false })
subHid: number;
constructor(param: { actorId: number, ai: number, dataId: number, order: number }) { constructor(param: { actorId: number, ai: number, dataId: number, order: number, subHid?: number }) {
this.actorId = param.actorId; this.actorId = param.actorId;
this.ai = param.ai; this.ai = param.ai;
this.dataId = param.dataId; this.dataId = param.dataId;
this.order = param.order; this.order = param.order;
this.subHid = param.subHid||0;
} }
} }
@@ -33,7 +36,7 @@ export class DefenseHero extends DefenseHeroInSaveData {
@prop({ ref: 'Hero', type: mongoose.Schema.Types.ObjectId }) @prop({ ref: 'Hero', type: mongoose.Schema.Types.ObjectId })
hero: Ref<Hero>; hero: Ref<Hero>;
constructor(param: { actorId: number, ai: number, dataId: number, order: number }, heroId: string) { constructor(param: { actorId: number, ai: number, dataId: number, order: number, subHid?: number }, heroId: string) {
super(param); super(param);
this.hero = heroId; this.hero = heroId;
} }
@@ -153,12 +156,14 @@ export class DefenseHeroReturn {
ai: number; // ai逻辑,1-进攻型 2-防守型 ai: number; // ai逻辑,1-进攻型 2-防守型
dataId: number; dataId: number;
order: number; order: number;
subHid: number;
constructor(defenseHero: DefenseHero) { constructor(defenseHero: DefenseHero) {
this.actorId = defenseHero.actorId; this.actorId = defenseHero.actorId;
this.ai = defenseHero.ai; this.ai = defenseHero.ai;
this.dataId = defenseHero.dataId; this.dataId = defenseHero.dataId;
this.order = defenseHero.order; this.order = defenseHero.order;
this.subHid = defenseHero.subHid;
} }
} }
+9 -5
View File
@@ -134,8 +134,6 @@ export class PvpHeroInfo {
this.quality = hero.quality; this.quality = hero.quality;
let skin = hero.skins?.find(cur => cur.enable); let skin = hero.skins?.find(cur => cur.enable);
if(skin) this.talent = skin.talent; if(skin) this.talent = skin.talent;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
if(artifact) this.artifact.push(artifact); if(artifact) this.artifact.push(artifact);
this.ePlace = ePlace; this.ePlace = ePlace;
} }
@@ -158,6 +156,12 @@ export class PvpHeroInfo {
setOutIndex(order: number) { setOutIndex(order: number) {
this.outIndex = order; this.outIndex = order;
} }
setSubHero(subHero: HeroType) {
console.log('#### setSubHero', subHero)
this.subHid = subHero?.skinId||0;
this.subActorId = subHero?.hid||0;
}
} }
export class GVGHeroInfo extends PvpHeroInfo { export class GVGHeroInfo extends PvpHeroInfo {
@@ -250,7 +254,7 @@ export class PvpEnemies extends Enemies {
// score: 这个武将的军功 // score: 这个武将的军功
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score?: number, ce?: number) { constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score?: number, ce?: number, subHero?: HeroType) {
super(warjson, heroInfo, ce); super(warjson, heroInfo, ce);
this.star = heroInfo.star; this.star = heroInfo.star;
this.colorStar = heroInfo.colorStar; this.colorStar = heroInfo.colorStar;
@@ -258,8 +262,8 @@ export class PvpEnemies extends Enemies {
this.lv = heroInfo.lv; this.lv = heroInfo.lv;
this.talent = heroInfo.talent; this.talent = heroInfo.talent;
this.job = heroInfo.job; this.job = heroInfo.job;
this.subHid = heroInfo.subHid; this.subHid = subHero?.hid||heroInfo.subHid||0;
this.subActorId = heroInfo.subActorId; this.subActorId = subHero?.skinId||heroInfo.subActorId||0;
this.artifact = heroInfo.artifact||[]; this.artifact = heroInfo.artifact||[];
this.ePlace = heroInfo.ePlace||[]; this.ePlace = heroInfo.ePlace||[];
if(score != undefined) this.score = score; if(score != undefined) this.score = score;
+12 -6
View File
@@ -30,6 +30,8 @@ export class OppPlayerHeroInfo {
order: number; // 行动顺序 order: number; // 行动顺序
@prop({ required: true }) @prop({ required: true })
ce: number; // 战力 ce: number; // 战力
@prop({ required: true })
subHid: number; // 副将
setByWarJson(warJson: DicWarJson) { setByWarJson(warJson: DicWarJson) {
this.hid = warJson.actorId; this.hid = warJson.actorId;
@@ -51,7 +53,7 @@ export class OppPlayerHeroInfo {
} }
} }
setByDefenseHero(hero: HeroType, lineup: {actorId: number, dataId: number, order: number}[]) { setByDefenseHero(hero: HeroType, lineup: {actorId: number, dataId: number, order: number, subHid: number}[]) {
this.hid = hero.hid; this.hid = hero.hid;
this.skinId = hero.skinId; this.skinId = hero.skinId;
this.quality = hero.quality; this.quality = hero.quality;
@@ -63,6 +65,7 @@ export class OppPlayerHeroInfo {
if(curLineup) { if(curLineup) {
this.dataId = curLineup.dataId; this.dataId = curLineup.dataId;
this.order = curLineup.order; this.order = curLineup.order;
this.subHid = curLineup.subHid;
} }
} }
} }
@@ -116,7 +119,7 @@ export class OppPlayerInfo {
this.leagueName = league.name; this.leagueName = league.name;
} }
setPlayerHeroes(heroes: HeroType[], lineup: {actorId: number, dataId: number, order: number}[]) { setPlayerHeroes(heroes: HeroType[], lineup: {actorId: number, dataId: number, order: number, subHid: number}[]) {
for(let hero of heroes) { for(let hero of heroes) {
let obj = new OppPlayerHeroInfo(); let obj = new OppPlayerHeroInfo();
obj.setByDefenseHero(hero, lineup); obj.setByDefenseHero(hero, lineup);
@@ -174,7 +177,7 @@ export class OppDetailHeroData {
subActorId: number = 0; subActorId: number = 0;
artifact: HeroArtifact[] = []; artifact: HeroArtifact[] = [];
constructor(warJson: DicWarJson, defensHero: OppPlayerHeroInfo, hero: HeroType, artifacts: ArtifactModelType[]) { constructor(warJson: DicWarJson, defensHero: OppPlayerHeroInfo, hero: HeroType, artifacts: ArtifactModelType[], subHero: HeroType) {
this.dataId = warJson.dataId; this.dataId = warJson.dataId;
this.relation = warJson.relation; this.relation = warJson.relation;
this.dirction = warJson.dirction; this.dirction = warJson.dirction;
@@ -201,12 +204,14 @@ export class OppDetailHeroData {
let skin = hero.skins.find(cur => cur.enable); let skin = hero.skins.find(cur => cur.enable);
if(skin) this.talent = skin.talent; if(skin) this.talent = skin.talent;
this.job = hero.job; this.job = hero.job;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
let artifact = artifacts.find(cur => cur.seqId == hero.artifact); let artifact = artifacts.find(cur => cur.seqId == hero.artifact);
if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv }); if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv });
} }
} }
if(subHero) {
this.subHid = subHero?.skinId||0;
this.subActorId = subHero?.hid||0;
}
} }
setAttribute(attribute: string) { setAttribute(attribute: string) {
@@ -240,7 +245,8 @@ export class OppDetailData{
let defenseHero = defenseHeroes.find(cur => cur.dataId == warJson.dataId); let defenseHero = defenseHeroes.find(cur => cur.dataId == warJson.dataId);
if(!defenseHero) continue; if(!defenseHero) continue;
let curHero = heroes.find(cur => cur.hid == defenseHero.hid); let curHero = heroes.find(cur => cur.hid == defenseHero.hid);
let hero = new OppDetailHeroData(warJson, defenseHero, curHero, artifacts); let subHero = defenseHero.subHid? heroes.find(cur => cur.hid == defenseHero.subHid): null;
let hero = new OppDetailHeroData(warJson, defenseHero, curHero, artifacts, subHero);
this.heroes.push(hero); this.heroes.push(hero);
this.lineupCe += curHero.ce; this.lineupCe += curHero.ce;
} }
+2 -1
View File
@@ -775,6 +775,7 @@ export class MyTeamSimpleInfo {
actorId: number; // 武将 actorId: number; // 武将
dataId: number; // 出兵表上的位置 dataId: number; // 出兵表上的位置
order: number; // 行动 order: number; // 行动
subHid: number;
}[]; }[];
hasConfirm: boolean; hasConfirm: boolean;
@@ -784,7 +785,7 @@ export class MyTeamSimpleInfo {
this.head = team.head; this.head = team.head;
this.frame = team.frame; this.frame = team.frame;
this.spine = team.spine; this.spine = team.spine;
this.lineup = team.lineup.map(({ actorId, dataId, outIndex }) => ({ actorId, dataId, order: outIndex })); this.lineup = team.lineup.map(({ actorId, dataId, outIndex, subActorId }) => ({ actorId, dataId, order: outIndex, subHid: subActorId }));
this.hasConfirm = team.confirmConfigId == configId; this.hasConfirm = team.confirmConfigId == configId;
} }
} }
+2
View File
@@ -164,4 +164,6 @@ export class LineupHero {
dataId: number; // 出兵表上的位置 dataId: number; // 出兵表上的位置
@prop({ required: true }) @prop({ required: true })
order: number; // 行动 order: number; // 行动
@prop({ required: false })
subHid?: number; // 行动
} }