fix 刷新对手无法找到武将

This commit is contained in:
luying
2021-01-14 18:37:13 +08:00
parent 9eaecf3a28
commit 13570982f4
5 changed files with 47 additions and 45 deletions

View File

@@ -138,7 +138,7 @@ export async function matchPlayerByRank(oppPlayers: OppPlayers[], mapWarJson: Di
if(result.length <= 0) return false;
oppRoleId = result[0];
let pvpdefense = await PvpDefenseModel.findByRoleId(oppRoleId);
let pvpdefense = await PvpDefenseModel.findByRoleIdIncludeAll(oppRoleId);
let pvpHistoryOpp = await generPlayerOppHis(pvpdefense, mapWarJson, roleId, pos);
oppPlayers.push({
@@ -192,8 +192,8 @@ async function generPlayerOppHis(result: PvpDefenseType, mapWarJson: DicWarJson[
for(let warJson of mapWarJson) {
if(warJson.relation == 1) continue;
let h = result.heroes.find(cur => cur.dataId == warJson.dataId);
if(h) {
let hs = heroScores.find(cur => cur.hid == warJson.actorId); // 这个武将的军功
if(h && h.hero) {
let hs = heroScores.find(cur => cur.hid == h.actorId); // 这个武将的军功
let hero = <HeroType>h.hero;
let heroInfo = new PvpHeroInfo();
heroInfo.setHeroInfo(hero);

View File

@@ -201,14 +201,18 @@ export default class PvpDefense extends BaseModel {
public static async findByRoleIdIncludeAll(roleId: string) {
const result: PvpDefenseType = await PvpDefenseModel.findOne({ roleId })
.populate('role', 'headHid sHid topFiveCe roleId roleName lv')
.populate('role', 'headHid sHid topFiveCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName headHid sHid rankLv pLv defCe heroes').lean();
return result;
}
public static async findByTeamLv(min: number, max: number) {
const result: PvpDefenseType[] = await PvpDefenseModel.find({ pLv: { $gte: min, $lte: max } }).lean();
const result: PvpDefenseType[] = await PvpDefenseModel.find({ pLv: { $gte: min, $lte: max } })
.populate('role', 'headHid sHid topFiveCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName headHid sHid rankLv pLv defCe heroes')
.lean();
return result;
}

View File

@@ -1,9 +1,7 @@
// 一些通用的interface定义
import { RoleType } from "../db/Role";
import { Robot } from "../db/PvpDefense";
import { reduceCe } from "./util";
import { PvpHeroInfo, PvpEnemies } from "../db/generalField";
import { PvpEnemies } from "../db/generalField";
export interface RewardInter {
id: number;

View File

@@ -140,7 +140,7 @@ async function calculateTopFive(role: RoleType, hid: number, ce: number, heroId:
} else { // 原来就是最强5人
if (ce < topFive[topFive.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(role.roleId, 5);
topFive = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce } });
topFive = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
topFive[index].ce = ce;
}

View File

@@ -11,7 +11,7 @@
"suitLevel": "1&20",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -28,7 +28,7 @@
"suitLevel": "1&20",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "2&3",
"winDialogue": "&",
"loseDialogue": "&"
@@ -45,7 +45,7 @@
"suitLevel": "1&20",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -62,7 +62,7 @@
"suitLevel": "1&20",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -79,7 +79,7 @@
"suitLevel": "1&20",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -96,7 +96,7 @@
"suitLevel": "1&20",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "20&21&22&23&24",
"winDialogue": "25&",
"loseDialogue": "26&"
@@ -113,7 +113,7 @@
"suitLevel": "1&20",
"warId": 2001,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "5&6",
"winDialogue": "3&",
"loseDialogue": "7&"
@@ -130,7 +130,7 @@
"suitLevel": "1&20",
"warId": 2002,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "27&28&29&30&31",
"winDialogue": "32&33",
"loseDialogue": "34&"
@@ -147,7 +147,7 @@
"suitLevel": "1&20",
"warId": 2003,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "8&9&10&11",
"winDialogue": "12&13",
"loseDialogue": "14&15"
@@ -164,7 +164,7 @@
"suitLevel": "21&40",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -181,7 +181,7 @@
"suitLevel": "21&40",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "2&3",
"winDialogue": "&",
"loseDialogue": "&"
@@ -198,7 +198,7 @@
"suitLevel": "21&40",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -215,7 +215,7 @@
"suitLevel": "21&40",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -232,7 +232,7 @@
"suitLevel": "21&40",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -249,7 +249,7 @@
"suitLevel": "21&40",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "20&21&22&23&24",
"winDialogue": "25&",
"loseDialogue": "26&"
@@ -266,7 +266,7 @@
"suitLevel": "21&40",
"warId": 2001,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "5&6",
"winDialogue": "3&",
"loseDialogue": "7&"
@@ -283,7 +283,7 @@
"suitLevel": "21&40",
"warId": 2002,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "27&28&29&30&31",
"winDialogue": "32&33",
"loseDialogue": "34&"
@@ -300,7 +300,7 @@
"suitLevel": "21&40",
"warId": 2003,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "8&9&10&11",
"winDialogue": "12&13",
"loseDialogue": "14&15"
@@ -317,7 +317,7 @@
"suitLevel": "41&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -334,7 +334,7 @@
"suitLevel": "41&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "2&3",
"winDialogue": "&",
"loseDialogue": "&"
@@ -351,7 +351,7 @@
"suitLevel": "41&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -368,7 +368,7 @@
"suitLevel": "41&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -385,7 +385,7 @@
"suitLevel": "41&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -402,7 +402,7 @@
"suitLevel": "41&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "20&21&22&23&24",
"winDialogue": "25&",
"loseDialogue": "26&"
@@ -419,7 +419,7 @@
"suitLevel": "41&100",
"warId": 2001,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "5&6",
"winDialogue": "3&",
"loseDialogue": "7&"
@@ -436,7 +436,7 @@
"suitLevel": "41&100",
"warId": 2002,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "27&28&29&30&31",
"winDialogue": "32&33",
"loseDialogue": "34&"
@@ -453,7 +453,7 @@
"suitLevel": "41&100",
"warId": 2003,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "8&9&10&11",
"winDialogue": "12&13",
"loseDialogue": "14&15"
@@ -470,7 +470,7 @@
"suitLevel": "61&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -487,7 +487,7 @@
"suitLevel": "61&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "2&3",
"winDialogue": "&",
"loseDialogue": "&"
@@ -504,7 +504,7 @@
"suitLevel": "61&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "1&4",
"winDialogue": "&",
"loseDialogue": "&"
@@ -521,7 +521,7 @@
"suitLevel": "61&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -538,7 +538,7 @@
"suitLevel": "61&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "16&17",
"winDialogue": "18&",
"loseDialogue": "19&"
@@ -555,7 +555,7 @@
"suitLevel": "61&100",
"warId": 0,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "20&21&22&23&24",
"winDialogue": "25&",
"loseDialogue": "26&"
@@ -572,7 +572,7 @@
"suitLevel": "61&100",
"warId": 2001,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "5&6",
"winDialogue": "3&",
"loseDialogue": "7&"
@@ -589,7 +589,7 @@
"suitLevel": "61&100",
"warId": 2002,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "27&28&29&30&31",
"winDialogue": "32&33",
"loseDialogue": "34&"
@@ -606,7 +606,7 @@
"suitLevel": "61&100",
"warId": 2003,
"weight": 1,
"movePointArray": "26&27&28&29",
"movePointArray": "44&46&48&50",
"startDialogue": "8&9&10&11",
"winDialogue": "12&13",
"loseDialogue": "14&15"