robotank/client-hodejs/targetpractice.ts
Sascha Nitsch 51f0415617 initial im
2025-03-03 02:17:50 +01:00

39 lines
No EOL
909 B
TypeScript

import { RobotStatus } from "./robotstatus";
import { RoboBase } from "./robobase";
class TargetPractice extends RoboBase {
lastHealth = 100;
ready() {
console.log("targetPractice is ready");
this.cmd.radarMin = -1;
this.cmd.radarMax = -1;
this.cmd.gunTarget = 0;
this.sendCmd();
}
start() {
console.log("simulation started");
this.cmd.radarMin = -1;
this.cmd.radarMax = -1;
this.sendCmd();
}
statusReady(status: RobotStatus) {
if (status.health != this.lastHealth) {
console.log("got hit life left:", status.health);
this.lastHealth = status.health;
}
// no actions, no send
// this.sendCmd();
}
lost() {
console.log("we lost");
this.disconnect();
}
won() {
console.log("we won, how?");
this.disconnect();
}
}
var targetPractice = new TargetPractice("targetPractice", "scout");
targetPractice.connect();