make WIN_POSITION a static member
This commit is contained in:
parent
494109de79
commit
0e4fd19933
@ -1,11 +1,10 @@
|
|||||||
const Player = require('./Player');
|
const Player = require('./Player');
|
||||||
const Hunter = require("./Hunter");
|
const Hunter = require("./Hunter");
|
||||||
|
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
|
|
||||||
static MAX_PLAYERS = 4;
|
static MAX_PLAYERS = 4;
|
||||||
|
static WIN_POSITION = 16;
|
||||||
static STATUS = {
|
static STATUS = {
|
||||||
SETTING_UP: 0,
|
SETTING_UP: 0,
|
||||||
ONGOING: 1,
|
ONGOING: 1,
|
||||||
@ -83,7 +82,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 > 15);
|
let index = this.players.findIndex(player => player.position >= Game.WIN_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;
|
||||||
|
Loading…
Reference in New Issue
Block a user