军团活动:诸侯混战初始
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { Application, ChannelService, BackendSession } from "pinus";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS } from "../../../consts";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, CITY_STATUS } from "../../../consts";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { getGuildActivityStatus } from "../../../services/guildActivityService";
|
||||
import { GuildActivityCityModel } from "../../../db/GuildActivityCity";
|
||||
import { CityParam } from "../../../domain/battleField/guildActivity";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
|
||||
export default function (app: Application) {
|
||||
return new CityActivityHandler(app);
|
||||
@@ -18,16 +21,74 @@ export class CityActivityHandler {
|
||||
// 进入诸侯混战
|
||||
async getCityActivity(msg: {}, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
// const roleId = session.get('roleId');
|
||||
// const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
let statusResult = getGuildActivityStatus(this.aid);
|
||||
if(!statusResult) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
const dbCities = await GuildActivityCityModel.getAllCities(serverId);
|
||||
|
||||
let cities = new Array<CityParam>();
|
||||
for(let [ cityId, dic ] of gameData.cityActivity) {
|
||||
let param = new CityParam(cityId);
|
||||
let curCity = dbCities.find(cur => cur.cityId == cityId);
|
||||
|
||||
let preCity = dic.preCity;
|
||||
if(preCity && preCity.length) {
|
||||
let hasGuardCity = dbCities.find(cur => {
|
||||
return preCity.includes(cur.cityId) && cur.guardGuildCode == guildCode;
|
||||
});
|
||||
if(!!hasGuardCity) {
|
||||
param.status = CITY_STATUS.CAN_DECLARE;
|
||||
}
|
||||
} else {
|
||||
param.status = CITY_STATUS.CAN_DECLARE;
|
||||
}
|
||||
|
||||
if(curCity) {
|
||||
if(curCity.guardGuildCode == guildCode) {
|
||||
param.status = CITY_STATUS.GUARD;
|
||||
} else if (curCity.declareGuilds.includes(guildCode)) {
|
||||
param.status = CITY_STATUS.DECLARED;
|
||||
}
|
||||
param.guardGuildCode = curCity.guardGuildCode;
|
||||
param.guardGuildName = curCity.guardGuildName;
|
||||
param.declareCount = curCity.declareCount;
|
||||
}
|
||||
cities.push(param);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
...statusResult,
|
||||
cities
|
||||
});
|
||||
}
|
||||
|
||||
// 获取单个城池状态
|
||||
async getCityStatus(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 宣战
|
||||
async declareCity(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 开始挑战
|
||||
async checkBattle(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 上报城门受到伤害
|
||||
async hitGate(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 结束挑战
|
||||
async battleEnd(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user