✨ feat(gvgBattle): 填充接口,通过部分激战期用例测试
This commit is contained in:
@@ -336,6 +336,7 @@ export const STATUS = {
|
||||
GVG_TASK_HAS_RECEIVED: { code: 21330, simStr: '任务已领取过' },
|
||||
GVG_BATTLE_CITY_FULL: { code: 21331, simStr: '城市已满员' },
|
||||
GVG_BATTLE_TEAM_INVALID: { code: 21332, simStr: '无效的队伍' },
|
||||
GVG_CITY_NOT_FOUND: { code: 21333, simStr: '城池不存在' },
|
||||
|
||||
// GVG征战中原
|
||||
GVG_VESTIGE_ERR: { code: 21350, simStr: '今日未开放该遗迹' },
|
||||
|
||||
+15
-1
@@ -10,7 +10,7 @@ export default class GVGCity extends BaseModel {
|
||||
@prop({ required: true })
|
||||
cityId: number; // 城池id
|
||||
|
||||
@prop({ required: true })
|
||||
@prop({ required: true, default: [] })
|
||||
leagueCodes: string[]; // 联军
|
||||
|
||||
@prop({ required: false })
|
||||
@@ -24,6 +24,20 @@ export default class GVGCity extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
teamCnt: number; // 城池队伍数
|
||||
|
||||
// 创建城市
|
||||
public static async createCity(configId: number, cityId: number) {
|
||||
let doc = new GVGCityModel();
|
||||
let update = Object.assign(doc.toJSON(), { configId, cityId});
|
||||
const city: GVGCityType | null = await GVGCityModel.findOneAndUpdate({ configId, cityId }, { $setOnInsert: update }, { upsert: true, new: true }).lean();
|
||||
return city;
|
||||
}
|
||||
|
||||
// 通过 cityId 获取城市
|
||||
public static async getCityByCityId(cityId: number) {
|
||||
const city: GVGCityType | null = await GVGCityModel.findOne({ cityId }).lean();
|
||||
return city;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-1
@@ -1,6 +1,7 @@
|
||||
// GVGTeam 数据库表,存储 GVG 队伍信息
|
||||
import BaseModel from "./BaseModel";
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { genCode } from "../pubUtils/util";
|
||||
|
||||
@index({ roleId: 1, teamId: 1 })
|
||||
@index({ teamCode: 1 })
|
||||
@@ -9,7 +10,10 @@ export default class GVGTeam extends BaseModel {
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
teamCode: string; // 玩家队伍id,3个队伍
|
||||
teamCode: string; // 玩家队伍唯一标识
|
||||
|
||||
@prop({ required: true })
|
||||
teamId: number; // 队伍id,1-3,玩家的第几个队伍
|
||||
|
||||
@prop({ required: true })
|
||||
leagueCode: string; // 联军
|
||||
@@ -53,6 +57,15 @@ export default class GVGTeam extends BaseModel {
|
||||
dataId: number; // 位置
|
||||
order: number; // 进攻顺序
|
||||
}]
|
||||
|
||||
// 创建队伍
|
||||
public static async createTeam(roleId: string, leagueCode: string, teamId: number, head: number, spine: number, frame: number, lineup: any) {
|
||||
const doc = new GVGTeamModel();
|
||||
const teamCode = genCode(8);
|
||||
let update = Object.assign(doc.toJSON(), { roleId, leagueCode, teamId, teamCode, head, spine, frame, lineup });
|
||||
const team: GVGTeamType | null = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $setOnInsert: update }, { upsert: true, new: true }).lean();
|
||||
return team;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGTeamModel = getModelForClass(GVGTeam);
|
||||
|
||||
Reference in New Issue
Block a user