后台:设置关卡等级

This commit is contained in:
luying
2021-12-17 20:44:15 +08:00
parent 07e12ccf9e
commit 3ca6d99dc7
6 changed files with 52 additions and 36 deletions
+12
View File
@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { gameData } from '../pubUtils/data';
class WarStatus {
@prop({ required: true })
@@ -86,6 +87,17 @@ export default class TowerRecord extends BaseModel {
return rec;
}
public static async insertTowerRec(roleId: string, lv: number) {
let insertParams = [];
let doc = new TowerRecordModel();
for(let [towerLv, { warArray }] of gameData.tower) {
if(towerLv < lv) {
insertParams.push({...doc.toJSON(), roleId, lv: towerLv, warStatus: warArray.map(warId => ({ warId, status: true })), passed: true})
} else if (towerLv == lv) {
insertParams.push({...doc.toJSON(), roleId, lv: towerLv, warStatus: warArray.map(warId => ({ warId, status: true })), passed: false})
}
}
}
public static async deleteAccount(roleId: string) {
let result = await TowerRecordModel.deleteMany({roleId});