From cec130b7c4230bc35e46907f007e66da7371bd07 Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 10 Sep 2021 17:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/rankService.ts | 20 ++++++++++---------- shared/db/Guild.ts | 5 ++++- shared/domain/rank.ts | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/game-server/app/services/rankService.ts b/game-server/app/services/rankService.ts index 4dbc230f0..609fa30a4 100644 --- a/game-server/app/services/rankService.ts +++ b/game-server/app/services/rankService.ts @@ -245,7 +245,7 @@ export class Rank { if (!guild) { guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK) } - let param = new GuildRankParam(guild); + let param = new GuildRankParam(guild, true); await this.setUserInfo(infoKey, { guildCode }, param); } else if (infoKey == REDIS_KEY.TOP_LINEUP_INFO) { if (!role) { @@ -458,12 +458,12 @@ export class Rank { if (!guild) { guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK); } - param = new GuildRankInfo(guild); + param = new GuildRankInfo(guild, true); param.setInfo(0, { guildCode }, score, time); } else { const info = await redisClient().hgetAsync(this.infoKey, guildCode); const guildInfo = JSON.parse(info); - param = new GuildRankInfo(guildInfo); + param = new GuildRankInfo(guildInfo, false); param.setInfo(0, { guildCode }, score, time); } @@ -483,12 +483,12 @@ export class Rank { if (!guild) { guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK); } - param = new GuildRankInfo(guild); + param = new GuildRankInfo(guild, true); param.setInfo2(0, { guildCode }, score, time, active); } else { const info = await redisClient().hgetAsync(this.infoKey, guildCode); const guildInfo = JSON.parse(info); - param = new GuildRankInfo(guildInfo); + param = new GuildRankInfo(guildInfo, false); param.setInfo2(0, { guildCode }, score, time, active); } @@ -681,10 +681,10 @@ export class Rank { param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } else if (this.infoKey == REDIS_KEY.GUILD_INFO) { if(this.key == REDIS_KEY.GUILD_LV_RANK) { - param = new GuildRankInfo(userInfo); + param = new GuildRankInfo(userInfo, false); param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]); } else { - param = new GuildRankInfo(userInfo); + param = new GuildRankInfo(userInfo, false); param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } } @@ -727,10 +727,10 @@ export class Rank { param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } else if (this.infoKey == REDIS_KEY.GUILD_INFO) { if(this.key == REDIS_KEY.GUILD_LV_RANK) { - param = new GuildRankInfo(userInfo); + param = new GuildRankInfo(userInfo, false); param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]); } else { - param = new GuildRankInfo(userInfo); + param = new GuildRankInfo(userInfo, false); param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } } @@ -818,7 +818,7 @@ export class Rank { if(!reverse) { encodeResult += score * Math.pow(10, weight); } else { - let pow = Math.pow(10, len + 1); + let pow = Math.pow(10, len); encodeResult += pow - 1 - score; } }) diff --git a/shared/db/Guild.ts b/shared/db/Guild.ts index 011e0078e..240ddf6d9 100644 --- a/shared/db/Guild.ts +++ b/shared/db/Guild.ts @@ -72,6 +72,9 @@ export default class Guild extends BaseModel { @prop({ required: true, default: 0, get: (val:number) => reduceCe(val), set: (val: number) => val }) guildCe: number; // 总战力 + + @prop({ required: false, set: (val: boolean) => val, get: () => true }) + isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true @prop({ required: true, type: String, default: [], select: false }) members: string[]; // 军团成员的roleId,用于增加战力的时候加入总战力 @@ -139,7 +142,7 @@ export default class Guild extends BaseModel { let sort = {}, condition = {}; switch(type) { case REDIS_KEY.GUILD_LV_RANK: - sort = { lv: -1, lvUpdateTime: 1 }; break; + sort = { lv: -1, activeWeekly: -1, lvUpdateTime: 1 }; break; case REDIS_KEY.GUILD_ACTIVE_RANK: sort = { activeWeekly: -1, activeUpdateTime: 1 }; condition = { activeWeekly: { $gt: 0 } }; break; } diff --git a/shared/domain/rank.ts b/shared/domain/rank.ts index a68858d8a..9bc1122d8 100644 --- a/shared/domain/rank.ts +++ b/shared/domain/rank.ts @@ -177,14 +177,27 @@ export class GuildRankParam { @prop({ required: true }) guildCe: number; - constructor(guild: GuildUpdateParam) { + constructor(guild: GuildUpdateParam, fromDb: boolean) { this.icon = guild.icon; this.name = guild.name; this.lv = guild.lv; let leader = guild.leader; let _leader = new GuildLeader(leader); this.leader = _leader; - this.guildCe = guild.guildCe; + console.log('*****', guild.isReducedCe, guild.guildCe, reduceCe(guild.guildCe)) + if(guild.isReducedCe) { + this.guildCe = guild.guildCe; + } else { + this.guildCe = reduceCe(guild.guildCe); + } + + if(fromDb && !(guild).isReducedCe) { + this.guildCe = reduceCe(guild.guildCe); + } else { + this.guildCe = guild.guildCe; + } + + this.memberCnt = guild.memberCnt; } }