名将擂台:获取对手详细信息,结算
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { mongoose, prop, Ref } from "@typegoose/typegoose";
|
||||
import { LADDER_BATTLE_STOP_TIME, LADDER_CHECK_STOP_TIME, LADDER_STATUS } from "../../consts";
|
||||
import { LADDER_STATUS } from "../../consts";
|
||||
import Hero, { HeroType } from '../../db/Hero';
|
||||
import { LadderMatchType } from "../../db/LadderMatch";
|
||||
import { LadderMatchRecType } from "../../db/LadderMatchRec";
|
||||
@@ -137,6 +137,7 @@ export class LadderOppPlayerInfo {
|
||||
this.lv = role.lv;
|
||||
this.isSuccess = isSuccess;
|
||||
this.heroes = heroes;
|
||||
this.isRobot = false;
|
||||
}
|
||||
|
||||
initByRobot(dicLadderDifficultRatio: DicLadderDifficultRatio, heroes: LadderOppPlayerHeroInfo[], isSuccess: boolean) {
|
||||
@@ -149,7 +150,9 @@ export class LadderOppPlayerInfo {
|
||||
this.lv = dicLadderDifficultRatio.level;
|
||||
this.isSuccess = isSuccess;
|
||||
this.heroes = heroes;
|
||||
this.isRobot = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// defense字段 接口返回
|
||||
@@ -245,9 +248,9 @@ export class LadderDataReturn {
|
||||
if(ladderRec) {
|
||||
this.status = ladderRec.status;
|
||||
if(this.status == LADDER_STATUS.BATTLE) {
|
||||
this.time = ladderRec.battleTime + LADDER_BATTLE_STOP_TIME;
|
||||
this.time = ladderRec.battleTime + LADDER.LADDER_BATTLE_COUNTDOWN;
|
||||
} else if (this.status == LADDER_STATUS.CHECK) {
|
||||
this.time = ladderRec.checkTime + LADDER_CHECK_STOP_TIME;
|
||||
this.time = ladderRec.checkTime + LADDER.LADDER_BATTLE_PREPARE_COUNTDOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,4 +310,105 @@ export class LadderOppLineupReturn {
|
||||
this.heroes.push(hero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getOppData接口的返回
|
||||
export class LadderOppDetailHeroReturn {
|
||||
actorId: number = 0; // 武将id
|
||||
skinId: number = 0; // 皮肤id,fashions表的heroId
|
||||
actorName: string = ''; // 武将名
|
||||
dataId: number = 0; // 出兵表唯一id
|
||||
relation: number = 0; // 地方还是我方
|
||||
dirction: number = 0; // 方向
|
||||
outIndex: number = 0; // 玩家设置的出场顺序,即order字段
|
||||
x: number = 0; // 战场x坐标
|
||||
y: number = 0; // 战场y坐标
|
||||
var: number = 0; // 变量
|
||||
lv: number = 0; // 等级
|
||||
hide: number = 0; // 是否隐藏
|
||||
initial_ai: number = 0; // ai类型
|
||||
attribute: string = ''; // 武将属性,格式 id&val|id&val|...,这里的次级属性都是没有除1000的值
|
||||
star: number = 0; // 星级
|
||||
colorStar: number = 0; // 彩星
|
||||
quality: number = 0; // 品质
|
||||
skill: string = ''; // 技能
|
||||
seid: string = ''; // 技能
|
||||
spine: string = ''; // 动画
|
||||
|
||||
constructor(warJson: DicWarJson, defensHero: LadderDefenseHero) {
|
||||
this.dataId = warJson.actorId;
|
||||
this.relation = warJson.relation;
|
||||
this.dirction = warJson.dirction;
|
||||
this.x = warJson.x;
|
||||
this.y = warJson.y;
|
||||
this.var = warJson.var;
|
||||
this.hide = warJson.hide;
|
||||
|
||||
if(defensHero) {
|
||||
this.outIndex = defensHero.order;
|
||||
this.initial_ai = defensHero.ai;
|
||||
let hero = <HeroType>defensHero.hero;
|
||||
if(hero) {
|
||||
this.actorId = hero.hid;
|
||||
this.skinId = hero.skinId;
|
||||
this.actorName = hero.hName;
|
||||
this.lv = hero.lv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setAttribute(attribute: string) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
}
|
||||
|
||||
// getOppData接口的返回
|
||||
export class LadderOppDetailReturn {
|
||||
battleCode: string = '';
|
||||
roleId: string = '';
|
||||
status: LADDER_STATUS = LADDER_STATUS.NO;
|
||||
time: number = 0;
|
||||
isRobot: boolean = false;
|
||||
title: number = 1;
|
||||
warId: number = 0;
|
||||
heroes: LadderOppDetailHeroReturn[] = [];
|
||||
|
||||
constructor(ladderRec: LadderMatchRecType) {
|
||||
this.battleCode = ladderRec.battleCode;
|
||||
this.roleId = ladderRec.roleId2;
|
||||
this.status = ladderRec.status;
|
||||
if(this.status == LADDER_STATUS.BATTLE) {
|
||||
this.time = ladderRec.battleTime + LADDER.LADDER_BATTLE_COUNTDOWN;
|
||||
} else if (this.status == LADDER_STATUS.CHECK) {
|
||||
this.time = ladderRec.checkTime + LADDER.LADDER_BATTLE_PREPARE_COUNTDOWN;
|
||||
}
|
||||
}
|
||||
|
||||
setByPlayer(ladderMatch: LadderMatchType, warJsons: DicWarJson[]) {
|
||||
this.isRobot = false;
|
||||
let role = <RoleType>ladderMatch.role;
|
||||
this.title = role.title;
|
||||
if(ladderMatch.defense) {
|
||||
this.warId = ladderMatch.defense.warId;
|
||||
let heroes = ladderMatch.defense.heroes||[];
|
||||
for(let hero of heroes) {
|
||||
let warJson = warJsons.find(cur => cur.dataId == hero.dataId);
|
||||
if(warJson) {
|
||||
let obj = new LadderOppDetailHeroReturn(warJson, hero);
|
||||
this.heroes.push(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setByRobot(dicLadderDifficultRatio: DicLadderDifficultRatio) {
|
||||
this.isRobot = true;
|
||||
this.roleId = `robot${dicLadderDifficultRatio.rank}`;
|
||||
this.warId = dicLadderDifficultRatio.gkId;
|
||||
}
|
||||
|
||||
setAttribute(hid: number, attribute: string) {
|
||||
let hero = this.heroes.find(cur => cur.actorId == hid);
|
||||
if(hero) hero.setAttribute(attribute);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user