Skip to content

Instantly share code, notes, and snippets.

@MikeShi42
Created August 13, 2018 17:41
Show Gist options
  • Save MikeShi42/9459db59ac478d414d328544b6d22e1d to your computer and use it in GitHub Desktop.
Save MikeShi42/9459db59ac478d414d328544b6d22e1d to your computer and use it in GitHub Desktop.
// Sends the updated grid to the actuator
actuate() {
if (this.storageManager.getBestScore() < this.score) {
this.storageManager.setBestScore(this.score);
}
// Clear the state when the game is over (game over only, not win)
if (this.over) {
this.storageManager.clearGameState();
} else {
this.storageManager.setGameState(this.serialize());
}
const grid = this.grid;
const metadata = {
score: this.score,
over: this.over,
won: this.won,
bestScore: this.storageManager.getBestScore(),
terminated: this.isGameTerminated()
};
this.actuator.actuate(grid, metadata);
this.sendRemoteMove(grid, metadata); // Call our sendRemoteMove function!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment