Files
ZYZ/shared/domain/roleField/hero.ts
2023-03-31 13:41:00 +08:00

168 lines
5.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { prop } from '@typegoose/typegoose';
import { ArtifactModelType } from '../../db/Artifact';
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero';
import { JewelSe, JewelType, RandSe } from '../../db/Jewel';
import { gameData } from '../../pubUtils/data';
export interface CreateHeroParam extends HeroUpdate {
hid: number;
count: number;
}
export class HeroShowParam {
hid: number;
seqId: number;
skinId: number;
quality: number;
constructor(hero: HeroType) {
this.hid = hero.hid;
this.seqId = hero.seqId;
this.skinId = hero.skinId;
this.quality = hero.quality;
}
}
class HeroSKinParam {
id: number;
skinId: number; // fashions表的heroId字段
enable: boolean;
constructor(heroSkin: HeroSkin) {
this.id = heroSkin.id;
this.skinId = heroSkin.skinId;
this.enable = heroSkin.enable;
}
}
// 传给客户端的武将数据
export class HeroParam {
hid: number; // 武将 id
seqId: number; // 武将表自增 id
exp: number; // 经验值
lv: number; // 武将等级
ce: number; // 武将战力
star: number; // 星级
starStage: number; // 星级六维阶段
colorStar: number; // 觉醒, 彩星
colorStarStage: number; // 觉醒六维阶段
quality: number; // 品质
scrollActive: boolean; // 是否在名将谱中激活
scrollId: number; // 名将谱id
scrollStar: number; // 名将谱中保存的星级
scrollColorStar: number; // 名将谱中保存的觉醒等级
scrollQuality: number; // 名将谱中保存的品质
job: number; // 职业
jobStage: number; // 职阶
skinId: number; // 当前皮肤idfashions表的heroId字段
connections: Connect[]; // 羁绊
skins: HeroSKinParam[] = []; // 皮肤
ePlace: EPlace[]; // 武将装备引用数组
artifact: number|string = 0;
subHid: number = 0;
subActorId: number = 0;
talent: Talent[] = [];
usedTalentPoint: number = 0;
totalTalentPoint: number = 0;
constructor(hero: HeroType) {
this.seqId = hero.seqId;
this.hid = hero.hid;
this.exp = hero.exp;
this.lv = hero.lv;
this.ce = hero.ce;
this.star = hero.star;
this.starStage = hero.starStage;
this.colorStar = hero.colorStar;
this.colorStarStage = hero.colorStarStage;
this.quality = hero.quality;
this.scrollActive = hero.scrollActive;
this.scrollId = hero.scrollId;
this.scrollStar = hero.scrollStar;
this.scrollColorStar = hero.scrollColorStar;
this.scrollQuality = hero.scrollQuality;
this.job = hero.job;
this.totalTalentPoint = gameData.talentPointOfJob.get(hero.job)||0;
this.jobStage = hero.jobStage;
this.skinId = hero.skinId;
this.connections = hero.connections;
for(let skin of hero.skins) {
this.skins.push(new HeroSKinParam(skin));
if(skin.enable) {
this.talent = skin.talent||[];
this.usedTalentPoint = skin.usedTalentPoint||0;
}
}
this.ePlace = hero.ePlace;
this.artifact = hero.artifact;
this.subHid = hero.subHid;
this.subActorId = hero.subActorId;
}
}
export class JewelParam {
seqId: number; // 唯一id
id: number; // 装备id
name: string; // 装备名
hid: number; // 装备此装备的武将
ePlaceId: number; // 装备在哪个位置
randSe: RandSe[];
rareSe: JewelSe[];
count: number;
inc: number;
reason: number;
constructor(jewel: JewelType, isPush?: boolean, reason?: number) {
this.seqId = jewel.seqId;
this.id = jewel.id;
this.name = jewel.name;
this.hid = jewel.hid;
this.ePlaceId = jewel.ePlaceId;
this.randSe = jewel.randSe;
this.rareSe = jewel.rareSe;
if(isPush) {
this.count = 1;
this.inc = 1;
this.reason = reason;
}
}
}
export class ArtifactParam {
seqId: number|string; // 唯一id
artifactId: number; // 宝物id
id: number; // 物品id
lv: number; // 强化等级
hid: number; // 装备的武将
count: number;
inc: number; // 增减数量固定1
reason: number; // 来源id
constructor(artifact: ArtifactModelType, isPush?: boolean, reason?: number) {
this.seqId = artifact.seqId;
this.artifactId = artifact.artifactId;
this.id = artifact.id;
this.lv = artifact.lv;
this.hid = artifact.hid;
if(isPush) {
this.count = 1;
this.inc = 1;
this.reason = reason;
}
}
}
// 阵容
export class LineupHero {
@prop({ required: true })
actorId: number; // 武将
@prop({ required: true })
dataId: number; // 出兵表上的位置
@prop({ required: true })
order: number; // 行动
}