Skip to content

Instantly share code, notes, and snippets.

@NoxWings
Created January 12, 2018 13:58
Show Gist options
  • Save NoxWings/8c2d990c05bfedfa5334770c24d06d90 to your computer and use it in GitHub Desktop.
Save NoxWings/8c2d990c05bfedfa5334770c24d06d90 to your computer and use it in GitHub Desktop.
Cheat for ztype
class Cheat {
constructor (game) {
this.game = game;
this._target = undefined;
}
get target () {
if (!this._target || this._target.remainingWord.length === 0) {
this._target = this.bestTarget;
}
return this._target;
}
get bestTarget () {
return this.potentialTargets
.sort((a, b) => this.game.player.distanceTo(a) > this.game.player.distanceTo(b))[0];
}
get potentialTargets () {
return Object.values(this.game.targets)
.filter(t => t.length > 0)
.reduce((flat, toFlaten) => flat.concat(toFlaten), []);
}
shoot () {
if (this.target) {
this.game.shoot(this.target.remainingWord[0]);
}
}
start (interval = 10) {
this._interval = setInterval(this.shoot.bind(this), interval);
}
stop () {
clearTimeout(this._interval);
}
}
c = new Cheat(ig.game);
c.start()
@Gradyruan
Copy link

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment