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 /** * 开局选择英雄