Files
ZYZ/shared/domain/dbGeneral.ts

282 lines
8.3 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, mongoose, Ref } from '@typegoose/typegoose';
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
import { Attribute } from './roleField/attribute';
import Hero, { HeroType } from '../db/Hero';
import { nowSeconds } from '../pubUtils/timeUtil';
// 从玩家数据中覆盖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?: Attribute; // 属性
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: Attribute) {
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类型
@prop({ required: false })
ce: number; // 战力
// warjson 出兵表
// heroInfo 覆盖掉出兵表的相应参数
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, ce: number) {
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;
this.ce = ce;
}
}
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, ce: number) {
super(warjson, heroInfo, ce);
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;
}
export class TopHero {
@prop({ required: true })
hid: number; // 武将id
@prop({ required: true })
ce: number; // 战力
@prop({ ref: Hero, type: mongoose.Schema.Types.ObjectId })
hero: Ref<Hero>;
}
export class DungeonHero {
@prop({ required: true })
battleId: number; // 关卡id
@prop({ required: true, type: Number, default: [] })
heroes: Array<number>; // 武将id
}
export class PayRecord {
@prop({ required: true })
id: string; // 购买项 product id
@prop({ required: true })
cnt: number; // 购买次数
}
export class WarStar {
@prop({ required: true })
id: number; // 关卡 id
@prop({ required: true })
warType: number; // 关卡类型
@prop({ required: true })
star: number; // 星级
}
export class Teraph {
@prop({ required: true, default: 1 })
id: number; // 神像的id
@prop({ required: true, default: 1 })
grade: number; // 等级
@prop({ required: true, default: 0 })
hp: number;
@prop({ required: true, default: 0 })
atk: number;
@prop({ required: true, default: 0 })
def: number;
@prop({ required: true, default: 0 })
mdef: number;
@prop({ required: true, default: 0 })
agi: number;
@prop({ required: true, default: 0 })
luk: number;
}
export class Figure {
@prop({ required: true, default: 0 })
id: number; // 头像id
@prop({ required: true, default: false })
enable: boolean = false; // 是否启用
@prop({ required: false })
time?: number; // 到期时间
@prop({ required: false, type: Number })
unlockedId?: number[]; // 当前已经解锁了的type
@prop({ required: true, default: false })
unlocked: boolean = false; // 是否已解锁
public get status () { // 虚拟字段status当前头像是否已经解锁
if(!this.unlocked) return this.unlocked; // 未解锁
if(this.time && this.time < nowSeconds()) return false; // 已解锁过时
return true;
}
constructor(id: number, unlocked: boolean, time?: number, enable = false) {
this.id = id;
this.unlocked = unlocked;
if(time) this.time = time;
this.enable = enable;
}
}
/**
* @description 出价记录
* @export
* @class BidRec
*/
export class BidRec {
@prop({ required: true, default: '' })
roleId: string; // 出价玩家
@prop({ required: true, default: 0 })
price: number; // 出价金额
@prop({ required: true })
time: Date; // 出价时间
}
/**
* @description 拍品记录
* @export
* @class LotRec
*/
export class LotRec {
@prop({ required: true, default: '' })
code: string; // 竞拍物品唯一标识
@prop({ required: true, default: 0 })
gid: number; // 物品 id
@prop({ required: true, default: 0 })
count: number; // 物品数量
@prop({ required: true, default: 0 })
price: number; // 物品成交价
@prop({ required: true, default: null })
time: Date; // 出价时间
@prop({ required: true, default: 0 })
max: boolean; // 一口价
}
/**
* @description 分红记录
* @export
* @class DividendRec
*/
export class DividendRec {
@prop({ required: true, default: '' })
roleId: string;
@prop({ required: true, default: 0 })
posNum: number; // 职位分红
@prop({ required: true, default: 0 })
weekendNum: number; // 额外分红,周末
@prop({ required: true, default: 0 })
total: number; // 总分红
@prop({ required: true, default: 0 })
status: number; // 0未领取1已领取
}