From 10eba07531613bcf8c05ef6052611039f414b7d9 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 19 Mar 2021 16:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/Robot.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 5297b65..896c3a6 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -24,6 +24,7 @@ export class Robot { this.host = host this.roomId = roomId this.client = new Client(host) + this.updateRobotCfg(0) } async connect() { @@ -70,12 +71,7 @@ export class Robot { } break case 'update_robot_level': - const { cheatRate, noEatRate, noTripleRate } = new GameEnv().getRobotCfg(data.lvl) - log(`update robot lvl to: ${data.lvl}, cheatRate: ${cheatRate}, noEatRate: ${noEatRate}, noTripleRate: ${noTripleRate}`) - this.lvl = data.lvl - this.cheatRate = cheatRate - this.noEatRate = noEatRate - this.noTripleRate = noTripleRate + self.updateRobotCfg(data.lvl) break } }) @@ -137,7 +133,14 @@ export class Robot { this.room.send(messageType, message) } - + private updateRobotCfg(lvl: number) { + const { cheatRate, noEatRate, noTripleRate } = new GameEnv().getRobotCfg(lvl) + log(`update robot lvl to: ${lvl}, cheatRate: ${cheatRate}, noEatRate: ${noEatRate}, noTripleRate: ${noTripleRate}`) + this.lvl = lvl + this.cheatRate = cheatRate + this.noEatRate = noEatRate + this.noTripleRate = noTripleRate + } // >>>>>>>>>>>>>>>>>> begin /** * 开局选择英雄