✨ feat(远征&巅峰): 选择其他对手获取他的装备和宝物信息
This commit is contained in:
@@ -12,6 +12,7 @@ import * as dicParam from '../pubUtils/dicParam';
|
||||
import { getHeroesAttributes, getSumCe } from './playerCeService';
|
||||
import { checkSystemIsOpen } from './roleService';
|
||||
import { ArtifactModel } from '../db/Artifact';
|
||||
import { JewelModel } from '../db/Jewel';
|
||||
|
||||
/**
|
||||
* 获取远征关卡列表
|
||||
@@ -144,6 +145,10 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
enemyObj.enemyId = roleId;
|
||||
enemyObj.ce = topLineupCe;
|
||||
|
||||
let hids = topLineup.map(cur => cur.hid);
|
||||
let artifacts = await ArtifactModel.findbyHids(roleId, hids);
|
||||
let jewels = await JewelModel.findbyRoleAndHids(roleId, hids);
|
||||
|
||||
let heroIndex = 0;
|
||||
for(let json of dicWarJson) {
|
||||
if(json.relation == 2) {
|
||||
@@ -151,9 +156,10 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
if(hero) {
|
||||
let h = <HeroType>hero.hero;
|
||||
if(h) {
|
||||
let { star, lv, ce, skins, colorStar, quality, job, subHid = 0, subActorId = 0 } = h;
|
||||
let artifact = h.artifact? await ArtifactModel.findbySeqId(role.roleId, h.artifact): null;
|
||||
let { star, lv, ce, skins, colorStar, quality, job, subHid = 0, subActorId = 0, ePlace = [] } = h;
|
||||
let artifact = h.artifact? artifacts.find(cur => cur.seqId == h.artifact): null;
|
||||
let skin = skins?.find(cur => cur.enable);
|
||||
let curJewels = jewels.filter(jewel => jewel.hid == h.hid);
|
||||
|
||||
let dicHero = gameData.hero.get(hero.hid);
|
||||
let attr = attrByHid.get(hero.hid);
|
||||
@@ -175,7 +181,9 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
talent: skin? skin.talent: [],
|
||||
artifact: artifact? [{ artifactId: artifact.artifactId, lv: artifact.lv }]: [],
|
||||
subHid,
|
||||
subActorId
|
||||
subActorId,
|
||||
ePlace,
|
||||
jewels: curJewels
|
||||
};
|
||||
|
||||
enemyObj.enemies.push({...json, ...heroInfo});
|
||||
|
||||
@@ -208,7 +208,7 @@ export async function generNewLineup(roleId: string, heroes: HeroType[], lineup:
|
||||
if(hero) {
|
||||
let artifact = hero.artifact? await ArtifactModel.findbySeqId(roleId, hero.artifact): null;
|
||||
let heroInfo = new GVGHeroInfo();
|
||||
heroInfo.setHeroInfo(hero, artifact);
|
||||
heroInfo.setHeroInfo(hero, artifact, []);
|
||||
heroInfo.setDataId(dataId, order);
|
||||
|
||||
let attr = attrByHid.get(actorId);
|
||||
|
||||
@@ -29,6 +29,7 @@ import { setPvpSettleSeasonNumToRemote } from './timeTaskService';
|
||||
import { ArtifactModel } from '../db/Artifact';
|
||||
import { getPVPGroupIdOfServer, getPvpServersByGroupId } from './serverService';
|
||||
import { findKeys } from './redisService';
|
||||
import { JewelModel } from '../db/Jewel';
|
||||
|
||||
/**
|
||||
* 返回对手三人信息
|
||||
@@ -232,8 +233,18 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos
|
||||
let otherHeroes = new Array<PvpOtherHeroes>(); // 阵容外的所有武将信息
|
||||
let defCe = 0;
|
||||
let attrByHid = await getHeroesAttributes(role.roleId);
|
||||
let hids = defenseHeroes.map(cur => cur.actorId);
|
||||
|
||||
console.log('#### hids', hids);
|
||||
|
||||
let artifacts = await ArtifactModel.findbyHids(role.roleId, hids);
|
||||
let jewels = await JewelModel.findbyRoleAndHids(role.roleId, hids);
|
||||
console.log('#### jewels', jewels.length);
|
||||
|
||||
for (let dbHero of dbHeroes) {
|
||||
let artifact = dbHero.artifact? await ArtifactModel.findbySeqId(role.roleId, dbHero.artifact): null;
|
||||
let artifact = dbHero.artifact? artifacts.find(cur => cur.seqId == dbHero.artifact): null;
|
||||
let curJewels = jewels.filter(jewel => jewel.hid == dbHero.hid);
|
||||
console.log('#### curJewels', dbHero.hid, curJewels.length)
|
||||
let h = defenseHeroes.find(cur => cur.actorId == dbHero.hid); // 阵容里是否有这个武将
|
||||
let hs = heroScores.find(cur => cur.hid == dbHero.hid); // 这个武将是否有这个得分
|
||||
if (!!h) {
|
||||
@@ -242,7 +253,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos
|
||||
let warJson = mapWarJson.find(cur => cur.dataId == h.dataId);
|
||||
if (warJson && warJson.relation == 2) {
|
||||
let heroInfo = new PvpHeroInfo();
|
||||
heroInfo.setHeroInfo(dbHero, artifact);
|
||||
heroInfo.setHeroInfo(dbHero, artifact, curJewels);
|
||||
// heroInfo.setOutIndex(h.order);
|
||||
let attr = attrByHid.get(h.actorId);
|
||||
if(!attr) continue;
|
||||
@@ -258,7 +269,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos
|
||||
}
|
||||
} else {
|
||||
let heroInfo = new PvpOtherHeroes(hs ? hs.score : 0);
|
||||
heroInfo.setHeroInfo(dbHero, artifact);
|
||||
heroInfo.setHeroInfo(dbHero, artifact, curJewels);
|
||||
otherHeroes.push(heroInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ export default class Artifact extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findbyHids(roleId: string, hids: number[]) {
|
||||
const result: ArtifactModelType[] = await ArtifactModel.find({ roleId, hid: { $in: hids }, status: 1 }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const result: ArtifactModelType[] = await ArtifactModel.find({ roleId, status: 1 }).select(select).lean();
|
||||
|
||||
@@ -4,6 +4,7 @@ import Hero, { HeroType } from '../db/Hero';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { DicHero } from '../pubUtils/dictionary/DicHero';
|
||||
import { ArtifactModelType } from '../db/Artifact';
|
||||
import { JewelType } from '../db/Jewel';
|
||||
|
||||
|
||||
class Talent {
|
||||
@@ -20,6 +21,62 @@ class HeroArtifact {
|
||||
|
||||
@prop({ required: true })
|
||||
lv: number;
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
quality: number; // 品质 1-5 蓝紫橙红金
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
qualityStage: number; // 品质+n,0开始
|
||||
}
|
||||
|
||||
class Stone {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
@prop({ required: true })
|
||||
stone: number;
|
||||
}
|
||||
|
||||
|
||||
class JewelSe {
|
||||
@prop({ required: true })
|
||||
id: number; // 随机属性位置id
|
||||
@prop({ required: true })
|
||||
seid: number; // 随机属性池id
|
||||
@prop({ required: true })
|
||||
rand: number; // 随机属性内需要随机的值
|
||||
}
|
||||
|
||||
class Jewel {
|
||||
@prop({ required: true })
|
||||
seqId: number; // 装备表自增 id
|
||||
@prop({ required: true })
|
||||
id: number; // 装备 id
|
||||
|
||||
@prop({ required: false, type: JewelSe, default: [], _id: false })
|
||||
rareSe: JewelSe[]; // 强化随机属性
|
||||
@prop({ required: false, type: JewelSe, default: [], _id: false })
|
||||
randSe: JewelSe[]; // 强化随机属性
|
||||
}
|
||||
|
||||
class EPlace {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
@prop({ required: true })
|
||||
equipId: number;
|
||||
@prop({ required: true })
|
||||
lv: number = 0;
|
||||
@prop({ required: true })
|
||||
quality: number = 1;
|
||||
@prop({ required: true })
|
||||
qualityStage: number = 0;
|
||||
@prop({ required: true })
|
||||
star: number = 0;
|
||||
@prop({ required: true })
|
||||
starStage: number = 0;
|
||||
@prop({ required: true, type: Stone, _id: false })
|
||||
stones: Stone[];
|
||||
@prop({ required: false })
|
||||
jewel: number = 0;
|
||||
}
|
||||
|
||||
// 从玩家数据中覆盖warjson的部分字段
|
||||
@@ -60,7 +117,12 @@ export class PvpHeroInfo {
|
||||
@prop({ required: true, _id: false, type: HeroArtifact })
|
||||
artifact?: HeroArtifact[] = []; // 宝物
|
||||
|
||||
setHeroInfo(hero: HeroType, artifact: ArtifactModelType) {
|
||||
@prop({ required: false, type: EPlace, _id: false })
|
||||
ePlace: EPlace[]; // 战力
|
||||
@prop({ required: false, type: Jewel, _id: false })
|
||||
jewels: Jewel[]; // 天晶
|
||||
|
||||
setHeroInfo(hero: HeroType, artifact: ArtifactModelType, jewels: JewelType[]) {
|
||||
this.actorId = hero.hid;
|
||||
this.skinId = hero.skinId;
|
||||
this.actorName = hero.hName;
|
||||
@@ -73,7 +135,9 @@ export class PvpHeroInfo {
|
||||
if(skin) this.talent = skin.talent;
|
||||
this.subHid = hero.subHid;
|
||||
this.subActorId = hero.subActorId;
|
||||
if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv })
|
||||
if(artifact) this.artifact.push(artifact);
|
||||
this.ePlace = hero.ePlace;
|
||||
this.jewels = jewels;
|
||||
}
|
||||
|
||||
setRobotInfo(dicHero: DicHero, lv?: number) {
|
||||
@@ -197,6 +261,8 @@ export class PvpEnemies extends Enemies {
|
||||
this.subHid = heroInfo.subHid;
|
||||
this.subActorId = heroInfo.subActorId;
|
||||
this.artifact = heroInfo.artifact||[];
|
||||
this.ePlace = heroInfo.ePlace||[];
|
||||
this.jewels = heroInfo.jewels||[];
|
||||
if(score != undefined) this.score = score;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user