🐞 fix(gvg): 修复城池驻守和机器人刷新逻辑
This commit is contained in:
@@ -345,6 +345,8 @@ export const STATUS = {
|
||||
GVG_NOT_BATTLE_PERIOD: { code: 21339, simStr: '您只能在激战期进行此操作' },
|
||||
GVG_FIELD_HAS_PLANT: { code: 21340, simStr: '该田已种植' },
|
||||
GVG_NOT_JOIN_LEAGUE: { code: 21341, simStr: '您未加入联军' },
|
||||
GVG_NOT_ENTER_CITY_TIME: { code: 21342, simStr: '您此时不可进入城池' },
|
||||
GVG_NOT_BATTLE_TIME: { code: 21343, simStr: '您此时只能进驻据点不可挑战' },
|
||||
|
||||
// GVG征战中原
|
||||
GVG_VESTIGE_ERR: { code: 21350, simStr: '今日未开放该遗迹' },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import BaseModel from "./BaseModel";
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { LeagueRankInfo } from "../domain/rank";
|
||||
import { GVGLeagueType } from "./GVGLeague";
|
||||
|
||||
class Player {
|
||||
@prop({ required: true })
|
||||
@@ -96,17 +96,22 @@ export default class GVGCity extends BaseModel {
|
||||
}
|
||||
|
||||
// 占领城池
|
||||
public static async guardCity(configId: number, groupKey: string, cityId: number, league: LeagueRankInfo) {
|
||||
public static async guardCity(configId: number, groupKey: string, cityId: number, league: GVGLeagueType) {
|
||||
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId: configId + 1, cityId, groupKey }, { $set: {
|
||||
hasGuard: true, guardLeague: league.code, guardLeagueName: league.name, guardLeagueIcon: league.icon
|
||||
hasGuard: true, guardLeague: league.leagueCode, guardLeagueName: league.name, guardLeagueIcon: league.icon
|
||||
}, $setOnInsert: { userCnt: 0, players: [] } }, { upsert: true, new: true }).lean();
|
||||
return city;
|
||||
}
|
||||
|
||||
public static async findByConfig(configId: number, groupKey: string) {
|
||||
public static async findByConfigAndGroup(configId: number, groupKey: string) {
|
||||
const cities: GVGCityType[] = await GVGCityModel.find({ configId, groupKey, hasGuard: true }).lean();
|
||||
return cities
|
||||
}
|
||||
|
||||
public static async findByConfig(configId: number) {
|
||||
const cities: GVGCityType[] = await GVGCityModel.find({ configId, hasGuard: true }).lean();
|
||||
return cities
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -199,6 +199,11 @@ export default class GVGLeague extends BaseModel {
|
||||
let leagues: GVGLeagueType[] = await GVGLeagueModel.find({ isAuto: true, status: 1 }).lean();
|
||||
return leagues
|
||||
}
|
||||
|
||||
public static async removeAuto(leagueCode: string) {
|
||||
let league: GVGLeagueType = await GVGLeagueModel.findOneAndUpdate({ leagueCode }, { $set: { isAuto: false } }).lean();
|
||||
return league
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGLeagueModel = getModelForClass(GVGLeague);
|
||||
|
||||
+11
-15
@@ -212,19 +212,15 @@ export default class GVGTeam extends BaseModel {
|
||||
|
||||
// 每赛季初刷新机器人
|
||||
public static async initRobots(configId: number, groupKey: string, cityId: number, dicPoints: DicGVGAreaPoint[], lv: number) {
|
||||
await GVGTeamModel.bulkWrite(dicPoints.map(({ pointId, areaId, name, head, spine, ce, durability }) => {
|
||||
return {
|
||||
updateOne: {
|
||||
filter: { groupKey, cityId, areaId, pointId },
|
||||
update: { $setOnInsert: {
|
||||
teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true, lv,
|
||||
isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId,
|
||||
}, $set: { configId, durability } },
|
||||
upsert: true
|
||||
}
|
||||
}
|
||||
}));
|
||||
return await this.findRobotTeams(groupKey, cityId);
|
||||
let teams: GVGTeamType[] = [];
|
||||
for(let { pointId, areaId, name, head, spine, ce, durability } of dicPoints) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ groupKey, cityId, areaId, pointId }, {
|
||||
$setOnInsert: {teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true, lv, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId,
|
||||
}, $set: { configId, durability }
|
||||
}, { new: true, upsert: true }).lean();
|
||||
teams.push(team);
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
|
||||
public static async findCatapultTeams(groupKey: string, cityId: number) {
|
||||
@@ -304,8 +300,8 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static async findByAreaId(groupKey: string, cityId: number, areaId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupKey, cityId, areaId, stopMoveTime: { $lte: nowSeconds() }, isBroken: false }).lean();
|
||||
public static async findByAreaId(configId: number, groupKey: string, cityId: number, areaId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ configId, groupKey, cityId, areaId, stopMoveTime: { $lte: nowSeconds() }, isBroken: false }).lean();
|
||||
return team;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface DicGVGAreaPoint {
|
||||
// 位置
|
||||
readonly pointPosition: string;
|
||||
// 守卫名
|
||||
readonly name: number;
|
||||
readonly name: string;
|
||||
// 守卫头像
|
||||
readonly head: number;
|
||||
// 守卫形象
|
||||
|
||||
Reference in New Issue
Block a user