hunter now moves when a player reaches field 8 instead of after 5 rounds
This commit is contained in:
parent
f39f64dab4
commit
25e569ace5
@ -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;
|
||||
|
@ -1,6 +1,7 @@
|
||||
class Hunter {
|
||||
constructor() {
|
||||
this.position = 0;
|
||||
this.isAlive = false;
|
||||
}
|
||||
|
||||
move_by(amount) {
|
||||
|
Loading…
Reference in New Issue
Block a user