From ba63b25ae19df97e3a42ef2ba45a0b8755cfa678 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 31 Aug 2022 13:42:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B8=E4=BE=AF=E6=B7=B7=E6=88=98=EF=BC=9A?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=A4=9A=E6=AC=A1=E5=8F=91=E9=80=81=E5=A5=96?= =?UTF-8?q?=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/guildActivity/cityActivityObj.ts | 28 +++++++++++-------- .../guildActivity/guildActivityService.ts | 7 ++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/game-server/app/services/guildActivity/cityActivityObj.ts b/game-server/app/services/guildActivity/cityActivityObj.ts index 878e8d8f2..6fe2558fb 100644 --- a/game-server/app/services/guildActivity/cityActivityObj.ts +++ b/game-server/app/services/guildActivity/cityActivityObj.ts @@ -52,6 +52,23 @@ export class CityActivityObject { return Math.floor((Date.now() - this.startTime)/1000); } + public lockCity(serverId: number, cityId: number) { + if(this.hasSent(serverId, cityId)) return false; + this.unlockCity(serverId, cityId); + return true; + } + + private unlockCity(serverId: number, cityId: number) { + let key = this.getKey(serverId, cityId); + // let guildCodes = this.cities.get(key)||[]; + // for(let guildCode of guildCodes) { + // this.members.delete(guildCode); + // this.guilds.delete(guildCode); + // } + // this.cities.delete(key); + this.sentCity.push(key); + } + public hasSent(serverId: number, cityId: number) { let key = this.getKey(serverId, cityId); return this.sentCity.indexOf(key) != -1; @@ -130,15 +147,4 @@ export class CityActivityObject { } this.guilds.set(guildCode, cityId); } - - public delCityRecord(cityId: number, serverId: number) { - let key = this.getKey(serverId, cityId); - // let guildCodes = this.cities.get(key)||[]; - // for(let guildCode of guildCodes) { - // this.members.delete(guildCode); - // this.guilds.delete(guildCode); - // } - // this.cities.delete(key); - this.sentCity.push(key); - } } \ No newline at end of file diff --git a/game-server/app/services/guildActivity/guildActivityService.ts b/game-server/app/services/guildActivity/guildActivityService.ts index a00e0f72b..58943be2e 100644 --- a/game-server/app/services/guildActivity/guildActivityService.ts +++ b/game-server/app/services/guildActivity/guildActivityService.ts @@ -436,8 +436,9 @@ async function updateUserRecAndSendHonour(honour: number, myScore: number, rank: * @param serverId 服务器id */ export async function cityActivitySettleReward(cityId: number, serverId: number) { + console.log('###### cityActivitySettleReward 0') let obj = getCityActivityObj(); - if(obj.hasSent(serverId, cityId)) return; + if(!obj.lockCity(serverId, cityId)) return; let dicCity = gameData.cityActivity.get(cityId); if (!dicCity) return; @@ -447,7 +448,7 @@ export async function cityActivitySettleReward(cityId: number, serverId: number) let index = getGAIndexInPinus(GUILD_ACTIVITY_TYPE.CITY_ACTIVITY); let r = new Rank(REDIS_KEY.CITY_ACTIVITY, { serverId, cityId, index }, true); let ranks = await r.getRankByRange(); - console.log('###### cityActivitySettleReward', ranks) + console.log('###### cityActivitySettleReward 1', JSON.stringify(ranks)); for (let { rank: guildRank, code: guildCode, name, num } of ranks) { if (guildRank == 1) { if (isSuccess) { @@ -494,8 +495,6 @@ export async function cityActivitySettleReward(cityId: number, serverId: number) await addActive(roleId, serverId, GUILD_POINT_WAYS.ACTIVITY); //获得活跃值 } } - - obj.delCityRecord(cityId, serverId); } export async function autoDeclare(serverId: number) {