Fix turnless pool player handling.

This commit is contained in:
yukirij 2024-12-17 17:38:06 -08:00
parent 842a945a01
commit be42a50cc6
2 changed files with 24 additions and 5 deletions

View File

@ -116,10 +116,11 @@ GAME.MovementTile = class {
};
GAME.Play = class {
constructor(source, from, to) {
constructor(source, from, to, player=-1) {
this.source = source;
this.from = from;
this.to = to;
this.player = player;
}
};
@ -319,7 +320,12 @@ GAME.Game = class {
process(play) {
if(this.state.code != 0) { return false; }
let player = this.turn & 1;
let player = 0;
if(play.player == -1) {
player = this.turn & 1;
} else {
player = play.player;
}
// Move piece on board.
switch(play.source) {
@ -399,7 +405,12 @@ GAME.Game = class {
}
play_is_valid(play) {
let player = this.turn & 1;
let player = 0;
if(play.player == -1) {
player = this.turn & 1;
} else {
player = play.player;
}
switch(play.source) {
case 0: {

View File

@ -215,6 +215,8 @@ const INTERFACE = {
},
click(event) {
let play_player = -1;
console.log("CLICK");
switch(event.button) {
@ -252,8 +254,12 @@ const INTERFACE = {
}
if((GAME_DATA.turn & 1) != pool_selected) {
if(GAME_DATA.config.rules.turn) {
console.log("NOT POOL");
result = 0;
} else {
play_player = pool_selected;
}
}
}
}
@ -292,6 +298,8 @@ const INTERFACE = {
INTERFACE_DATA.hover.tile,
INTERFACE_DATA.alt_mode
);
play.player = play_player;
INTERFACE.process(play);
INTERFACE_DATA.select = null;
INTERFACE_DATA.alt_mode = false;