diff --git a/Webservice/Game.js b/Webservice/Game.js index 970bdd3..1b3d6c6 100644 --- a/Webservice/Game.js +++ b/Webservice/Game.js @@ -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; diff --git a/Webservice/Hunter.js b/Webservice/Hunter.js index 3538041..b244d18 100644 --- a/Webservice/Hunter.js +++ b/Webservice/Hunter.js @@ -1,6 +1,7 @@ class Hunter { constructor() { this.position = 0; + this.isAlive = false; } move_by(amount) {