名将擂台:基础界面
This commit is contained in:
50
shared/db/LadderMatchRec.ts
Normal file
50
shared/db/LadderMatchRec.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typegoose/typegoose';
|
||||
import Role, { } from './Role';
|
||||
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, } from '../domain/battleField/pvp';
|
||||
import { CounterModel } from './Counter';
|
||||
import { COUNTER, LADDER_STATUS } from '../consts';
|
||||
import { EXTERIOR, PVP } from '../pubUtils/dicParam';
|
||||
import { LadderDefense, LadderOppPlayerInfo } from '../domain/battleField/ladder';
|
||||
|
||||
|
||||
@index({ battleCode: 1 })
|
||||
export default class LadderMatchRec extends BaseModel {
|
||||
@prop({ required: true })
|
||||
battleCode: string; // 唯一code
|
||||
@prop({ required: true })
|
||||
roleId1: string; // 攻方玩家id
|
||||
@prop({ required: true })
|
||||
roleId2: string; // 守方玩家id
|
||||
@prop({ required: true })
|
||||
serverId: number; // 区 id
|
||||
@prop({ required: true })
|
||||
status: LADDER_STATUS; // 1-出兵中 2-挑战中 3-挑战完毕
|
||||
@prop({ required: true })
|
||||
checkTime: number; // 开始出兵的时间,10位时间戳
|
||||
@prop({ required: true })
|
||||
battleTime: number; // 开始挑战的时间,10位时间
|
||||
@prop({ required: true })
|
||||
endTime: number; // 结束时间
|
||||
@prop({ required: true, type: LadderOppPlayerInfo, default: {}, _id: false })
|
||||
attackInfo: () => LadderOppPlayerInfo; // 攻方信息
|
||||
@prop({ required: true, type: LadderOppPlayerInfo, default: {}, _id: false })
|
||||
defenseInfo: () => LadderOppPlayerInfo; // 守方信息
|
||||
@prop({ required: true, type: LadderDefense, default: {}, _id: false })
|
||||
defense: () => LadderDefense; // 守方信息
|
||||
|
||||
public static async findByRoleId(roleId: string, getters = false) {
|
||||
const result: LadderMatchRecType = await LadderMatchRecModel.findOne({ roleId1: roleId }).lean({ getters});
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findNotCompleteRecByRoleId(roleId: string, getters = false) {
|
||||
const result: LadderMatchRecType = await LadderMatchRecModel.findOne({ roleId1: roleId, status: { $in: [ LADDER_STATUS.BATTLE, LADDER_STATUS.CHECK ] } }).lean({ getters});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const LadderMatchRecModel = getModelForClass(LadderMatchRec);
|
||||
|
||||
export interface LadderMatchRecType extends Pick<DocumentType<LadderMatchRec>, keyof LadderMatchRec> { };
|
||||
export type pvpUpdateInter = Partial<LadderMatchRecType>;
|
||||
Reference in New Issue
Block a user