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

View File

@@ -25,14 +25,17 @@ export class LadderDefenseHero {
hero: Ref<Hero>;
@prop({ required: true })
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.ai = param.ai;
this.dataId = param.dataId;
this.order = param.order;
this.hero = heroId;
this.ce = ce;
this.subHid = param.subHid||0;
}
}
@@ -80,6 +83,10 @@ export class LadderOppPlayerHeroInfo {
colorStar: number; // 彩星
@prop({ required: true })
lv: number; // 等级
@prop({ required: true })
subHid: number; // 副将
@prop({ required: true })
subActorId: number; // 副将(纯武将)
@prop({ required: true, type: HeroArtifact, _id: false })
artifact: HeroArtifact[] = []; // 等级
@@ -112,6 +119,11 @@ export class LadderOppPlayerHeroInfo {
setArtifact(artifact: ArtifactModelType) {
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
@@ -180,12 +192,14 @@ export class LadderDefenseHeroReturn {
ai: number; // ai逻辑1-进攻型 2-防守型
dataId: number;
order: number;
subHid: number;
constructor(defenseHero: LadderDefenseHero) {
this.actorId = defenseHero.actorId;
this.ai = defenseHero.ai;
this.dataId = defenseHero.dataId;
this.order = defenseHero.order;
this.subHid = defenseHero.subHid||0;
}
}
@@ -362,7 +376,7 @@ export class LadderOppDetailHeroReturn {
subActorId: number = 0;
artifacts: HeroArtifact[] = [];
constructor(warJson: DicWarJson, defensHero: LadderDefenseHero, artifacts: ArtifactModelType[]) {
constructor(warJson: DicWarJson, defensHero: LadderDefenseHero, artifacts: ArtifactModelType[], subHero: HeroType) {
this.dataId = warJson.dataId;
this.relation = warJson.relation;
this.dirction = warJson.dirction;
@@ -390,12 +404,14 @@ export class LadderOppDetailHeroReturn {
let skin = hero.skins.find(cur => cur.enable);
if(skin) this.talent = skin.talent;
this.job = hero.job;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
let artifact = artifacts.find(cur => cur.seqId == hero.artifact);
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) {
@@ -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;
let role = <RoleType>ladderMatch.role;
this.title = role.title;
@@ -436,7 +452,8 @@ export class LadderOppDetailReturn {
for(let hero of heroes) {
let warJson = warJsons.find(cur => cur.dataId == hero.dataId);
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.defCe += hero.ce;
}

View File

@@ -18,12 +18,15 @@ export class DefenseHeroInSaveData {
dataId: number;
@prop({ required: true })
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.ai = param.ai;
this.dataId = param.dataId;
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 })
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);
this.hero = heroId;
}
@@ -153,12 +156,14 @@ export class DefenseHeroReturn {
ai: number; // ai逻辑1-进攻型 2-防守型
dataId: number;
order: number;
subHid: number;
constructor(defenseHero: DefenseHero) {
this.actorId = defenseHero.actorId;
this.ai = defenseHero.ai;
this.dataId = defenseHero.dataId;
this.order = defenseHero.order;
this.subHid = defenseHero.subHid;
}
}

View File

@@ -134,8 +134,6 @@ export class PvpHeroInfo {
this.quality = hero.quality;
let skin = hero.skins?.find(cur => cur.enable);
if(skin) this.talent = skin.talent;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
if(artifact) this.artifact.push(artifact);
this.ePlace = ePlace;
}
@@ -158,6 +156,12 @@ export class PvpHeroInfo {
setOutIndex(order: number) {
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 {
@@ -250,7 +254,7 @@ export class PvpEnemies extends Enemies {
// 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);
this.star = heroInfo.star;
this.colorStar = heroInfo.colorStar;
@@ -258,8 +262,8 @@ export class PvpEnemies extends Enemies {
this.lv = heroInfo.lv;
this.talent = heroInfo.talent;
this.job = heroInfo.job;
this.subHid = heroInfo.subHid;
this.subActorId = heroInfo.subActorId;
this.subHid = subHero?.hid||heroInfo.subHid||0;
this.subActorId = subHero?.skinId||heroInfo.subActorId||0;
this.artifact = heroInfo.artifact||[];
this.ePlace = heroInfo.ePlace||[];
if(score != undefined) this.score = score;

View File

@@ -30,6 +30,8 @@ export class OppPlayerHeroInfo {
order: number; // 行动顺序
@prop({ required: true })
ce: number; // 战力
@prop({ required: true })
subHid: number; // 副将
setByWarJson(warJson: DicWarJson) {
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.skinId = hero.skinId;
this.quality = hero.quality;
@@ -63,6 +65,7 @@ export class OppPlayerHeroInfo {
if(curLineup) {
this.dataId = curLineup.dataId;
this.order = curLineup.order;
this.subHid = curLineup.subHid;
}
}
}
@@ -116,7 +119,7 @@ export class OppPlayerInfo {
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) {
let obj = new OppPlayerHeroInfo();
obj.setByDefenseHero(hero, lineup);
@@ -174,7 +177,7 @@ export class OppDetailHeroData {
subActorId: number = 0;
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.relation = warJson.relation;
this.dirction = warJson.dirction;
@@ -201,12 +204,14 @@ export class OppDetailHeroData {
let skin = hero.skins.find(cur => cur.enable);
if(skin) this.talent = skin.talent;
this.job = hero.job;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
let artifact = artifacts.find(cur => cur.seqId == hero.artifact);
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) {
@@ -240,7 +245,8 @@ export class OppDetailData{
let defenseHero = defenseHeroes.find(cur => cur.dataId == warJson.dataId);
if(!defenseHero) continue;
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.lineupCe += curHero.ce;
}

View File

@@ -775,6 +775,7 @@ export class MyTeamSimpleInfo {
actorId: number; // 武将
dataId: number; // 出兵表上的位置
order: number; // 行动
subHid: number;
}[];
hasConfirm: boolean;
@@ -784,7 +785,7 @@ export class MyTeamSimpleInfo {
this.head = team.head;
this.frame = team.frame;
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;
}
}

View File

@@ -164,4 +164,6 @@ export class LineupHero {
dataId: number; // 出兵表上的位置
@prop({ required: true })
order: number; // 行动
@prop({ required: false })
subHid?: number; // 行动
}