🐞 fix(gvg): 添加投石车

This commit is contained in:
luying
2023-02-27 21:54:32 +08:00
parent 82c4149063
commit 78777a1437
4 changed files with 378 additions and 22 deletions

View File

@@ -116,6 +116,7 @@ export async function initRobots(configId: number, groupKey: string, city: GVGCi
let updateDicPoints: DicGVGAreaPoint[] = [];
let { areaIds = []} = gameData.gvgCity.get(cityId);
for(let [_, point] of gameData.gvgAreaPoint) {
if(point.type != 1) continue;
if(areaIds.indexOf(point.areaId) == -1) continue;
let robotTeam = robotTeams.find(team => team.pointId == point.pointId);
if(!robotTeam || (!robotTeam.isBroken && robotTeam.configId != configId) ) {
@@ -296,14 +297,17 @@ export async function initCatapult(cityId: number, groupKey: string, leagueCode:
}
}
if(hasCatapult) {
let dicCity = gameData.gvgCity.get(cityId);
let areaIds = (dicCity?.areaIds||[]).filter(areaId => {
let dicArea = gameData.gvgArea.get(areaId);
return dicArea && dicArea.areaType == GVG_AREA_TYPE.CATAPULT;
});
let updateDicPoints: DicGVGAreaPoint[] = [];
let { areaIds = []} = gameData.gvgCity.get(cityId);
for(let [_, point] of gameData.gvgAreaPoint) {
if(point.type != 2) continue;
if(areaIds.indexOf(point.areaId) == -1) continue;
updateDicPoints.push(point);
}
let lv = gameData.war.get(GVG.GVG_CATAPULT_WARJSON)?.level||50;
let teams = await GVGTeamModel.initCatapult(configId, groupKey, cityId, leagueCode, leagueName, areaIds, atk, durability, lv);
let teams = await GVGTeamModel.initCatapult(configId, groupKey, cityId, updateDicPoints, leagueCode, leagueName, atk, durability, lv);
// 处理内存
let teamObj = getGVGBattleData(groupKey);
teamObj.enterCity(...teams);

View File

@@ -229,22 +229,18 @@ export default class GVGTeam extends BaseModel {
}
// 生成投石车
public static async initCatapult(configId: number, groupKey: string, cityId: number, leagueCode: string, leagueName: string, areaIds: number[], atk: number, durability: number, lv: number) {
await GVGTeamModel.bulkWrite(areaIds.map(areaId => {
return {
updateOne: {
filter: { groupKey, cityId, areaId },
update: { $setOnInsert: {
teamCode: genCode(8), maxDurability: durability, captapultAtk: atk, leagueCode, leagueName,
roleName: GVG.GVG_CATAPULT_NAME, head: GVG.GVG_CATAPULT_HEAD, spine: GVG.GVG_CATAPULT_SPINE, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: GVG.GVG_CATAPULT_CE, lv,
isRobot: true, isCatapult: true, fromAreaId: areaId,
isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', pointId: 0, roleId: GVG_CATAPULT
}, $set: { configId, durability } },
upsert: true
}
}
}));
return await this.findCatapultTeams(groupKey, cityId);
public static async initCatapult(configId: number, groupKey: string, cityId: number, dicPoints: DicGVGAreaPoint[], leagueCode: string, leagueName: string, atk: number, durability: number, lv: number) {
const teams: GVGTeamType[] = [];
for(let { pointId, areaId, name, head, spine, ce } 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, lv, leagueCode, leagueName, captapultAtk: atk,
isRobot: true, isCatapult: true, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', fromAreaId: areaId,
}, $set: { configId, durability }
}, { new: true, upsert: true }).lean();
teams.push(team);
}
return teams
}
// 攻击方攻击cd

View File

@@ -7,6 +7,8 @@ export interface DicGVGAreaPoint {
readonly pointId: number;
// 区域id
readonly areaId: number;
// 类型 1-守卫者 2-投石车
readonly type: number;
// 积分
readonly score: number;
// 位置

File diff suppressed because it is too large Load Diff