诸侯混战:防止多次发送奖励
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 = <GuildRankInfo[]>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) {
|
||||
|
||||
Reference in New Issue
Block a user