From 43f0a21063a723555fb2f967dccd67b47d52e6cf Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 9 Mar 2021 12:47:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E4=BD=9C=E5=BC=8A=E6=9C=BA=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cfg/GameEnv.ts | 27 ++++++++++++++++++++++++++ src/constants/BaseConst.ts | 13 +++++++++++++ src/rooms/commands/BeginGameCommand.ts | 17 +++------------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/cfg/GameEnv.ts b/src/cfg/GameEnv.ts index 675612c..05b1c69 100644 --- a/src/cfg/GameEnv.ts +++ b/src/cfg/GameEnv.ts @@ -66,8 +66,18 @@ export class GameEnv { public petInheritRate: number // 低级机器人的胜率值 public robotLvlLow: number + public robotRateLow: number + + // 中等机器人的胜率值 + public robotLvlMid: number + public robotRateMid: number + // 高级机器人的胜率值 public robotLvlHigh: number + public robotRateHigh: number + // 变态机器人的胜率值 + public robotLvlExtra: number + public robotRateExtra: number public init(data: Map) { this.initCardNum = data.get(BaseConst.INIT_CARD_NUM).value @@ -106,6 +116,23 @@ export class GameEnv { this.canEatAdv = !!data.get(BaseConst.CAN_EAT_ADV).value this.petInheritRate = data.get(BaseConst.PET_INHERIT_RATE).value / 100 this.robotLvlLow = data.get(BaseConst.ROBOT_LVL_LOW).value + this.robotLvlMid = data.get(BaseConst.ROBOT_LVL_MID).value this.robotLvlHigh = data.get(BaseConst.ROBOT_LVL_HIGHT).value + this.robotLvlExtra = data.get(BaseConst.ROBOT_LVL_EXTRA).value + this.robotRateLow = data.get(BaseConst.ROBOT_RATE_LOW).value + this.robotRateMid = data.get(BaseConst.ROBOT_RATE_MID).value + this.robotRateHigh = data.get(BaseConst.ROBOT_RATE_HIGHT).value + this.robotRateExtra = data.get(BaseConst.ROBOT_RATE_EXTRA).value + } + public getCheatRate(val: number) { + if (val < this.robotLvlLow) { + return this.robotRateLow + } else if (val < this.robotLvlMid) { + return this.robotRateMid + } else if (val < this.robotLvlHigh) { + return this.robotRateHigh + } else { + return this.robotRateExtra + } } } diff --git a/src/constants/BaseConst.ts b/src/constants/BaseConst.ts index 923b857..5ad0c93 100644 --- a/src/constants/BaseConst.ts +++ b/src/constants/BaseConst.ts @@ -64,8 +64,21 @@ export class BaseConst { public static readonly PET_INHERIT_RATE = 99041 // 低级机器人的胜率值 public static readonly ROBOT_LVL_LOW = 99042 + // 中等机器人胜率值 + public static readonly ROBOT_LVL_MID = 99043 // 高级机器人的胜率值 public static readonly ROBOT_LVL_HIGHT = 99044 + // 变态机器人胜率值 + public static readonly ROBOT_LVL_EXTRA = 99045 + + // 低级机器人的胜率值 + public static readonly ROBOT_RATE_LOW = 99046 + // 中等机器人胜率值 + public static readonly ROBOT_RATE_MID = 99047 + // 高级机器人的胜率值 + public static readonly ROBOT_RATE_HIGHT = 99048 + // 变态机器人胜率值 + public static readonly ROBOT_RATE_EXTRA = 99049 public static readonly COMPOUND = 'compound' public static readonly EFFECTCARD = 'effectcard' diff --git a/src/rooms/commands/BeginGameCommand.ts b/src/rooms/commands/BeginGameCommand.ts index 7a26e4a..0b723ad 100644 --- a/src/rooms/commands/BeginGameCommand.ts +++ b/src/rooms/commands/BeginGameCommand.ts @@ -21,8 +21,6 @@ export class BeginGameCommand extends Command { cardAll.randomSort() // 如果是匹配模式, 挑战机器人作弊比率 if (this.state.mode == 1) { - let highRate = new GameEnv().robotLvlHigh / 100 - let lowRate = new GameEnv().robotLvlLow / 100 for (let [, player] of this.state.players) { if (!player.robot) { continue @@ -46,21 +44,12 @@ export class BeginGameCommand extends Command { } let assistClient = this.room.getAssistClient(player.id) - if (global.isProd) { - let rate = 0 - if (oplayer.winRate > highRate) { - rate = oplayer.winRate * 100 | 0 - } else if (oplayer.winRate > lowRate) { - rate = oplayer.winRate / 2 * 100 | 0 - } - debugRoom(`opposite play win rate: ${ oplayer.winRate }, robot change rate: ${ rate }`) + let rate = new GameEnv().getCheatRate(oplayer.winRate * 100) + if (rate) { + debugRoom(`opposite play win rate: ${ oplayer.winRate }, robot cheat rate: ${ rate }`) client.send('update_change_rate', { val: rate }) assistClient.send('update_change_rate', { val: rate }) - } else { - client.send('update_change_rate', { val: 100 }) - assistClient.send('update_change_rate', { val: 100 }) } - } }