Files
ZYZ/shared/domain/dbGeneral.ts
2021-02-04 13:57:58 +08:00

146 lines
4.6 KiB
TypeScript

import { prop } from '@typegoose/typegoose';
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
import { HeroType } from '../db/Hero';
import { CeAttrNumber } from './roleField/attribute';
// 从玩家数据中覆盖warjson的部分字段
export class PvpHeroInfo {
@prop({ required: true })
actorId?: number = 0; // 敌人id
@prop({ required: false })
actorName?: string = ""; // 敌人名
@prop({ required: false })
outIndex?: number = 0; // 程序将信息存入数组顺序
@prop({ required: false })
star?: number = 0; // 角色星级
@prop({ required: false })
lv?: number = 0; // 角色等级
@prop({ required: false })
skill?: string = "0"; // 技能
@prop({ required: false })
seid?: string = "&"; // 技能
@prop({ required: false })
spine?: string = "0"; // S动画
@prop({ required: false })
colorStar?: number = 0; // 觉醒
@prop({ required: false })
quality?: number = 0; // 品质
@prop({ required: true, _id: false })
attribute?: CeAttrNumber; // 属性
setHeroInfo(hero: HeroType) {
this.actorId = hero.hid;
this.actorName = hero.hName;
this.star = hero.star;
this.lv = hero.lv;
this.colorStar = hero.colorStar;
this.quality = hero.quality;
}
setRobotInfo(warjson: DicWarJson, lv: number, initialStar: number, quality: number) {
this.actorId = warjson.actorId;
this.actorName = warjson.actorName;
this.star = initialStar;
this.lv = lv;
this.quality = quality;
}
setAttribute(attribute: CeAttrNumber) {
this.attribute = attribute;
}
setOutIndex(order: number) {
this.outIndex = order;
}
}
// 远征敌军
export class Enemies extends PvpHeroInfo {
@prop({ required: true })
actorId: number; // 敌人id
@prop({ required: false })
actorName: string; // 敌人名
@prop({ required: false })
dataId: number; // 战场中唯一指向武将的代码
@prop({ required: false })
relation: number; // 角色属于我方还是地方
@prop({ required: false })
x: number; // 战场x坐标
@prop({ required: false })
y: number; // 战场y坐标
@prop({ required: false })
direction: number; // 朝向
@prop({ required: false })
var: number; // 变量
@prop({ required: false })
hide: number; // 是否隐藏
@prop({ required: false })
initial_ai: number; // AI类型
// warjson 出兵表
// heroInfo 覆盖掉出兵表的相应参数
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo) {
super();
this.actorId = heroInfo.actorId != undefined ? heroInfo.actorId : warjson.actorId;
this.actorName = heroInfo.actorName != undefined ? heroInfo.actorName : warjson.actorName;
this.dataId = warjson.dataId;
this.relation = warjson.relation;
this.outIndex = heroInfo.outIndex != undefined ? heroInfo.outIndex : warjson.outIndex;
this.x = warjson.x;
this.y = warjson.y;
this.direction = warjson.direction;
this.var = warjson.var;
this.lv = heroInfo.lv != undefined ? heroInfo.lv : warjson.lv;
this.hide = warjson.hide;
this.initial_ai = warjson.initial_ai;
this.attribute = heroInfo.attribute;
this.skill = heroInfo.skill != undefined ? heroInfo.skill : warjson.skill;
this.seid = heroInfo.seid != undefined ? heroInfo.seid : warjson.seid;
this.star = heroInfo.star != undefined ? heroInfo.star : warjson.star;
this.spine = heroInfo.spine != undefined ? heroInfo.spine : warjson.spine;
}
}
export class PvpEnemies extends Enemies {
@prop({ required: true })
star: number;
@prop({ required: true })
colorStar: number;
@prop({ required: true })
quality: number;
@prop({ required: true })
lv: number;
@prop({ required: true })
score: number;
// score: 这个武将的军功
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score: number) {
super(warjson, heroInfo);
this.star = heroInfo.star;
this.colorStar = heroInfo.colorStar;
this.quality = heroInfo.quality;
this.lv = heroInfo.lv;
this.score = score;
}
}
// 未显示在阵容中的其他武将
export class PvpOtherHeroes extends PvpHeroInfo {
@prop({ required: true })
score: number;
// score: 这个武将的军功
constructor(score: number) {
super();
this.score = score;
}
}
export class ItemReward {
@prop({ required: true })
id: number;
@prop({ required: true })
count: number;
}