添加获取对手阵容,开始战斗,结算
This commit is contained in:
@@ -7,6 +7,15 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
@index({ roleId: 1, battleId: 1 })
|
||||
@index({ battleCode: 1 })
|
||||
|
||||
class Record {
|
||||
@prop({ required: true, type: Number })
|
||||
heroes: Array <number>; // 武将id
|
||||
@prop({ required: false })
|
||||
oppRoleId?: string; // pvp对手
|
||||
@prop({ required: false })
|
||||
pos?: number; // pvp位置
|
||||
}
|
||||
|
||||
export default class BattleRecord extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
@@ -26,10 +35,8 @@ export default class BattleRecord extends BaseModel {
|
||||
status: number; // 关卡状态 0-挑战中 1-挑战成功 2-挑战失败
|
||||
@prop({ required: true, default: 0 })
|
||||
star: number; // 关卡状态 0-挑战中 1-挑战成功 2-挑战失败
|
||||
@prop({ required: true })
|
||||
record: { // 使用的武将等记录
|
||||
heroes: Array <number>; // 武将id
|
||||
};
|
||||
@prop({ required: true, _id: false })
|
||||
record: Record; // 使用的武将等记录
|
||||
|
||||
public static async getBattleRecordByCode(battleCode: string, lean = true) {
|
||||
const result: BattleRecordType = await BattleRecordModel.findOne({ battleCode }).lean(lean);
|
||||
|
||||
@@ -153,6 +153,12 @@ export default class Hero extends BaseModel {
|
||||
const hero: HeroType[] = await HeroModel.find({ seqId: {$in: seqIds}, roleId }).lean(lean);
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async findByHidRange(hids: Array<number>, roleId: string, lean = true) {
|
||||
const hero: HeroType[] = await HeroModel.find({ hid: {$in: hids}, roleId }).lean(lean);
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async findBySeqIdAndRole(seqId: number, roleId: string, lean = true) {
|
||||
const hero: HeroType = await HeroModel.findOne({ seqId, roleId }).lean(lean);
|
||||
return hero;
|
||||
|
||||
@@ -10,6 +10,8 @@ interface pvpUpdateInter {
|
||||
oppPlayers?: OppPlayers[];
|
||||
score?: number;
|
||||
pLv?:number;
|
||||
heroScores?: HeroScores[];
|
||||
winStreakNum?: number;
|
||||
}
|
||||
|
||||
export class Heroes {
|
||||
@@ -74,6 +76,8 @@ export class Robot {
|
||||
}
|
||||
|
||||
export class OppPlayers {
|
||||
@prop({ required: true })
|
||||
roleId: string;
|
||||
@prop({ ref: 'PvpDefense', type: mongoose.Schema.Types.ObjectId })
|
||||
oppDef: Ref<PvpDef>;
|
||||
@prop({ required: true })
|
||||
@@ -84,7 +88,7 @@ export class OppPlayers {
|
||||
robot: Robot
|
||||
}
|
||||
|
||||
class HeroScores {
|
||||
export class HeroScores {
|
||||
@prop({ required: true })
|
||||
hid: number;
|
||||
@prop({ required: true })
|
||||
@@ -180,8 +184,8 @@ export default class PvpDefense extends BaseModel {
|
||||
.populate({
|
||||
path: 'oppPlayers.oppDef',
|
||||
populate: {
|
||||
path: 'role',
|
||||
select: 'headHid sHid topFiveCe roleId roleName'
|
||||
path: 'role heroes.hero',
|
||||
select: 'headHid sHid topFiveCe roleId roleName hid ceAttr globalCeAttr'
|
||||
}
|
||||
}).lean();
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user