修改机器人默认参数

This commit is contained in:
zhl 2021-03-19 16:35:06 +08:00
parent a0792dcbd5
commit 10eba07531

View File

@ -24,6 +24,7 @@ export class Robot {
this.host = host this.host = host
this.roomId = roomId this.roomId = roomId
this.client = new Client(host) this.client = new Client(host)
this.updateRobotCfg(0)
} }
async connect() { async connect() {
@ -70,12 +71,7 @@ export class Robot {
} }
break break
case 'update_robot_level': case 'update_robot_level':
const { cheatRate, noEatRate, noTripleRate } = new GameEnv().getRobotCfg(data.lvl) self.updateRobotCfg(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
break break
} }
}) })
@ -137,7 +133,14 @@ export class Robot {
this.room.send(messageType, message) 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 // >>>>>>>>>>>>>>>>>> begin
/** /**
* *