✨ feat(gvg): 激战期获取挑战对手阵容
This commit is contained in:
@@ -4,6 +4,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
import { genCode } from "../pubUtils/util";
|
||||
import { GVGTeamType } from "./GVGTeam";
|
||||
import { GVGHeroInfo } from "../domain/dbGeneral";
|
||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
||||
|
||||
class TeamInfo {
|
||||
@prop({ required: true })
|
||||
@@ -51,6 +52,9 @@ export default class GVGBattleRec extends BaseModel {
|
||||
@prop({ required: true })
|
||||
battleCode: string; // 战斗记录
|
||||
|
||||
@prop({ required: true })
|
||||
warId: number; // 关卡id
|
||||
|
||||
@prop({ required: true, type: TeamInfo, _id: false })
|
||||
attackTeam: TeamInfo; // 挑战队伍
|
||||
|
||||
@@ -60,14 +64,22 @@ export default class GVGBattleRec extends BaseModel {
|
||||
@prop({ required: true })
|
||||
isSuccess: boolean;
|
||||
|
||||
public static async createRec(attackTeam: GVGTeamType, defenseTeam: GVGTeamType) {
|
||||
@prop({ required: true })
|
||||
battleEndTime: number;
|
||||
|
||||
public static async createRec(warId: number, attackTeam: GVGTeamType, defenseTeam: GVGTeamType) {
|
||||
const battleCode = genCode(8);
|
||||
const result: GVGBattleRecType = await GVGBattleRecModel.findOneAndUpdate({ battleCode }, { $set: { attackTeam, defenseTeam, isSuccess: false } }, { new: true, upsert: true }).lean();
|
||||
const result: GVGBattleRecType = await GVGBattleRecModel.findOneAndUpdate({ battleCode }, { $set: { warId, attackTeam, defenseTeam, isSuccess: false } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findByBattleCode(battleCode: string) {
|
||||
const result: GVGBattleRecType = await GVGBattleRecModel.findOne({ battleCode }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findByBattleCode(battleCode: string) {
|
||||
const result: GVGBattleRecType = await GVGBattleRecModel.findOne({ battleCode }).lean();
|
||||
public static async battleEnd(battleCode: string, isSuccess: boolean) {
|
||||
const result: GVGBattleRecType = await GVGBattleRecModel.findOneAndUpdate({ battleCode }, { $set: { isSuccess, battleEndTime: nowSeconds() } }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user