hunter now moves when a player reaches field 8 instead of after 5 rounds #57

Merged
thorsten-rausch merged 1 commits from fix-hunter-movement into main 2021-07-10 14:02:22 +00:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit 25e569ace5 - Show all commits

View File

@ -4,7 +4,7 @@ const Hunter = require("./Hunter");
class Game {
static MAX_PLAYERS = 4;
static WIN_POSITION = 16;
static MAX_POSITION = 16;
static STATUS = {
SETTING_UP: 0,
ONGOING: 1,
@ -42,7 +42,10 @@ class Game {
#finish_round() {
this.round++;
if (this.round >= 5) {
if (this.players.some(player => player.position >= Game.MAX_POSITION / 2)) {
this.hunter.isAlive = true;
}
if (this.hunter.isAlive) {
this.hunter.move_by(1);
this.hunter.hunt(this.players);
}
@ -83,7 +86,7 @@ class Game {
update_game_status() {
if (!this.players.some(player => player.isAlive === true)) this.currentStatus = Game.STATUS.IS_DRAW;
let index = this.players.findIndex(player => player.position >= Game.WIN_POSITION);
let index = this.players.findIndex(player => player.position >= Game.MAX_POSITION);
if (index !== -1) {
this.currentStatus = Game.STATUS.IS_WON;
this.winnerIndex = index;

View File

@ -1,6 +1,7 @@
class Hunter {
constructor() {
this.position = 0;
this.isAlive = false;
}
move_by(amount) {