✨ feat(宝物): 添加宝物系统
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { mongoose, prop, Ref } from "@typegoose/typegoose";
|
||||
import { LADDER_STATUS } from "../../consts";
|
||||
import { ArtifactModelType } from "../../db/Artifact";
|
||||
import Hero, { HeroType, Talent } from '../../db/Hero';
|
||||
import { LadderMatchType } from "../../db/LadderMatch";
|
||||
import { LadderMatchRecType } from "../../db/LadderMatchRec";
|
||||
@@ -56,6 +57,15 @@ export class LadderOppPlayerInDB {
|
||||
rank: number;
|
||||
}
|
||||
|
||||
|
||||
class HeroArtifact {
|
||||
@prop({ required: true })
|
||||
artifactId: number;
|
||||
|
||||
@prop({ required: true })
|
||||
lv: number;
|
||||
}
|
||||
|
||||
// ladderMatchRec
|
||||
export class LadderOppPlayerHeroInfo {
|
||||
@prop({ required: true })
|
||||
@@ -70,6 +80,8 @@ export class LadderOppPlayerHeroInfo {
|
||||
colorStar: number; // 彩星
|
||||
@prop({ required: true })
|
||||
lv: number; // 等级
|
||||
@prop({ required: true, type: HeroArtifact, _id: false })
|
||||
artifact: HeroArtifact[] = []; // 等级
|
||||
|
||||
setByWarJson(warJson: DicWarJson) {
|
||||
this.hid = warJson.actorId;
|
||||
@@ -96,6 +108,10 @@ export class LadderOppPlayerHeroInfo {
|
||||
this.colorStar = hero.colorStar;
|
||||
this.lv = hero.lv;
|
||||
}
|
||||
|
||||
setArtifact(artifact: ArtifactModelType) {
|
||||
if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv });
|
||||
}
|
||||
}
|
||||
|
||||
// ladderMatchRec
|
||||
@@ -343,8 +359,9 @@ export class LadderOppDetailHeroReturn {
|
||||
spine: string = ''; // 动画
|
||||
talent: Talent[] = [];
|
||||
subHid: number = 0; // 副将
|
||||
artifact: HeroArtifact[] = [];
|
||||
|
||||
constructor(warJson: DicWarJson, defensHero: LadderDefenseHero) {
|
||||
constructor(warJson: DicWarJson, defensHero: LadderDefenseHero, artifacts: ArtifactModelType[]) {
|
||||
this.dataId = warJson.dataId;
|
||||
this.relation = warJson.relation;
|
||||
this.dirction = warJson.dirction;
|
||||
@@ -373,6 +390,8 @@ export class LadderOppDetailHeroReturn {
|
||||
if(skin) this.talent = skin.talent;
|
||||
this.job = hero.job;
|
||||
this.subHid = hero.subHid;
|
||||
let artifact = artifacts.find(cur => cur.seqId == hero.artifact);
|
||||
if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,7 +424,7 @@ export class LadderOppDetailReturn {
|
||||
}
|
||||
}
|
||||
|
||||
setByPlayer(ladderMatch: LadderMatchType, warJsons: DicWarJson[]) {
|
||||
setByPlayer(ladderMatch: LadderMatchType, warJsons: DicWarJson[], artifacts: ArtifactModelType[]) {
|
||||
this.isRobot = false;
|
||||
let role = <RoleType>ladderMatch.role;
|
||||
this.title = role.title;
|
||||
@@ -415,7 +434,7 @@ 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);
|
||||
let obj = new LadderOppDetailHeroReturn(warJson, hero, artifacts);
|
||||
this.heroes.push(obj);
|
||||
this.defCe += hero.ce;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user