✨ feat(宝物): 添加宝物系统
This commit is contained in:
@@ -3,6 +3,7 @@ import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
|
||||
import Hero, { HeroType } from '../db/Hero';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { DicHero } from '../pubUtils/dictionary/DicHero';
|
||||
import { ArtifactModelType } from '../db/Artifact';
|
||||
|
||||
|
||||
class Talent {
|
||||
@@ -11,6 +12,16 @@ class Talent {
|
||||
@prop({ required: true })
|
||||
level: number; // 激活等级
|
||||
}
|
||||
|
||||
|
||||
class HeroArtifact {
|
||||
@prop({ required: true })
|
||||
artifactId: number;
|
||||
|
||||
@prop({ required: true })
|
||||
lv: number;
|
||||
}
|
||||
|
||||
// 从玩家数据中覆盖warjson的部分字段
|
||||
export class PvpHeroInfo {
|
||||
@prop({ required: true })
|
||||
@@ -44,8 +55,10 @@ export class PvpHeroInfo {
|
||||
|
||||
@prop({ required: true, _id: false })
|
||||
attribute?: string; // 属性
|
||||
@prop({ required: true, _id: false, type: HeroArtifact })
|
||||
artifact?: HeroArtifact[] = []; // 宝物
|
||||
|
||||
setHeroInfo(hero: HeroType) {
|
||||
setHeroInfo(hero: HeroType, artifact: ArtifactModelType) {
|
||||
this.actorId = hero.hid;
|
||||
this.skinId = hero.skinId;
|
||||
this.actorName = hero.hName;
|
||||
@@ -57,6 +70,7 @@ export class PvpHeroInfo {
|
||||
let skin = hero.skins?.find(cur => cur.enable);
|
||||
if(skin) this.talent = skin.talent;
|
||||
this.subHid = hero.subHid;
|
||||
if(artifact) this.artifact.push({ artifactId: artifact.artifactId, lv: artifact.lv })
|
||||
}
|
||||
|
||||
setRobotInfo(dicHero: DicHero, lv: number) {
|
||||
@@ -150,6 +164,9 @@ export class PvpEnemies extends Enemies {
|
||||
talent: Talent[];
|
||||
@prop({ required: true })
|
||||
subHid: number;
|
||||
@prop({ required: true, type: () => HeroArtifact, _id: false })
|
||||
artifact: HeroArtifact[] = []; // 宝物
|
||||
|
||||
|
||||
// score: 这个武将的军功
|
||||
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score: number, ce: number) {
|
||||
@@ -162,6 +179,7 @@ export class PvpEnemies extends Enemies {
|
||||
this.talent = heroInfo.talent;
|
||||
this.job = heroInfo.job;
|
||||
this.subHid = heroInfo.subHid;
|
||||
this.artifact = heroInfo.artifact||[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user