hunter now moves when a player reaches field 8 instead of after 5 rounds #57
@ -4,7 +4,7 @@ const Hunter = require("./Hunter");
|
|||||||
class Game {
|
class Game {
|
||||||
|
|
||||||
static MAX_PLAYERS = 4;
|
static MAX_PLAYERS = 4;
|
||||||
static WIN_POSITION = 16;
|
static MAX_POSITION = 16;
|
||||||
static STATUS = {
|
static STATUS = {
|
||||||
SETTING_UP: 0,
|
SETTING_UP: 0,
|
||||||
ONGOING: 1,
|
ONGOING: 1,
|
||||||
@ -42,7 +42,10 @@ class Game {
|
|||||||
|
|
||||||
#finish_round() {
|
#finish_round() {
|
||||||
this.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.move_by(1);
|
||||||
this.hunter.hunt(this.players);
|
this.hunter.hunt(this.players);
|
||||||
}
|
}
|
||||||
@ -83,7 +86,7 @@ class Game {
|
|||||||
update_game_status() {
|
update_game_status() {
|
||||||
if (!this.players.some(player => player.isAlive === true)) this.currentStatus = Game.STATUS.IS_DRAW;
|
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) {
|
if (index !== -1) {
|
||||||
this.currentStatus = Game.STATUS.IS_WON;
|
this.currentStatus = Game.STATUS.IS_WON;
|
||||||
this.winnerIndex = index;
|
this.winnerIndex = index;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
class Hunter {
|
class Hunter {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.position = 0;
|
this.position = 0;
|
||||||
|
this.isAlive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
move_by(amount) {
|
move_by(amount) {
|
||||||
|
Loading…
Reference in New Issue
Block a user