军团活动:诸侯混战自动宣战
This commit is contained in:
@@ -344,7 +344,7 @@ export class GmHandler {
|
||||
|
||||
// 清空旧数据
|
||||
if (day <= 2) {
|
||||
await GuildActivityCityModel.deleteMany({});
|
||||
await GuildActivityCityModel.clearGuardAndStartNext();
|
||||
}
|
||||
if(aid != 0) await delGuildActivityRank(aid);
|
||||
await GuildActivityRecordModel.updateTodayInfo({ status: 2 });
|
||||
|
||||
@@ -36,12 +36,17 @@ export class CityActivityObject {
|
||||
}
|
||||
}
|
||||
|
||||
public hasSent(serverId: number, cityId: number) {
|
||||
let key = this.getKey(serverId, cityId);
|
||||
return this.sentCity.indexOf(key) != -1;
|
||||
}
|
||||
|
||||
public getAllCities() {
|
||||
let allCities = new Array<{ serverId: number, cityId: number, guildCodes: string[]}>();
|
||||
let serverlists = new Array<number>();
|
||||
for(let [key, guildCodes] of this.cities) {
|
||||
if(this.sentCity.indexOf(key) == -1) {
|
||||
let { serverId, cityId } = this.decodeKey(key);
|
||||
let { serverId, cityId } = this.decodeKey(key);
|
||||
if(!this.hasSent(serverId, cityId)) {
|
||||
allCities.push({ serverId, cityId, guildCodes });
|
||||
if(!serverlists.includes(serverId)) serverlists.push(serverId);
|
||||
}
|
||||
|
||||
@@ -444,6 +444,7 @@ async function updateUserRecAndSendHonour(honour: number, myScore: number, rank:
|
||||
*/
|
||||
export async function cityActivitySettleReward(cityId: number, serverId: number) {
|
||||
let obj = getCityActivityObj();
|
||||
if(obj.hasSent(serverId, cityId)) return;
|
||||
|
||||
let dicCity = gameData.cityActivity.get(cityId);
|
||||
if (!dicCity) return;
|
||||
@@ -455,9 +456,10 @@ export async function cityActivitySettleReward(cityId: number, serverId: number)
|
||||
for (let { rank: guildRank, code: guildCode, name, num } of ranks) {
|
||||
if (guildRank == 1) {
|
||||
if (isSuccess) {
|
||||
await GuildActivityCityModel.guard(serverId, cityId, guildCode, name); // 占领
|
||||
console.log(dicCity)
|
||||
await GuildActivityCityModel.guard(serverId, cityId, dicCity?.nextCity, guildCode, name); // 占领
|
||||
} else {
|
||||
await GuildActivityCityModel.guard(serverId, cityId, "", ""); // 无人能占领
|
||||
await GuildActivityCityModel.guard(serverId, cityId, 0, "", ""); // 无人能占领
|
||||
}
|
||||
}
|
||||
let rewards = getGuildAuctionRewards(GUILD_ACTIVITY_TYPE.CITY_ACTIVITY, guildRank, cityId);
|
||||
@@ -496,18 +498,10 @@ export async function cityActivitySettleReward(cityId: number, serverId: number)
|
||||
* 清空完declareGuilds之后,做下一次活动的自动宣战
|
||||
*/
|
||||
export async function autoDeclare(serverId: number) {
|
||||
let allCities = await GuildActivityCityModel.getAllCities(serverId);
|
||||
let guardList = new Array<{ cityId: number, guardGuildCode: string }>();
|
||||
for (let { cityId, guardGuildCode } of allCities) {
|
||||
guardList.push({ cityId, guardGuildCode });
|
||||
await GuildActivityCityModel.clearGuard(serverId, cityId);
|
||||
}
|
||||
// console.log(JSON.stringify(guardList));
|
||||
for (let { cityId, guardGuildCode } of guardList) {
|
||||
let dicCity = gameData.cityActivity.get(cityId);
|
||||
if (guardGuildCode && dicCity.nextCity) {
|
||||
await GuildActivityCityModel.declare(serverId, dicCity.nextCity, guardGuildCode);
|
||||
}
|
||||
await GuildActivityCityModel.clearGuardAndStartNext(serverId);
|
||||
for(let [ cityId ] of gameData.cityActivity) {
|
||||
let msg = { cityId, declareGuildCode: "", declareCount: 0 };
|
||||
await sendMessageToCityWithSuc(cityId, PUSH_ROUTE.GUILD_CITY_DECLARE, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user