Add automatic play mode.
This commit is contained in:
parent
6dda0a60da
commit
3fc98038ba
@ -552,6 +552,13 @@ const INTERFACE = {
|
||||
let message = null;
|
||||
ctx.fillStyle = INTERFACE.Color.Text;
|
||||
|
||||
if(INTERFACE_DATA.auto_mode !== null) {
|
||||
switch(INTERFACE_DATA.auto_mode) {
|
||||
case 0: message = "Auto Dawn"; break;
|
||||
case 1: message = "Auto Dusk"; break;
|
||||
}
|
||||
}
|
||||
|
||||
if(GAME_DATA.state.code == GAME.Const.State.Retire) {
|
||||
ctx.fillStyle = INTERFACE.Color.HintCheck;
|
||||
message = "Retire";
|
||||
@ -720,6 +727,8 @@ const INTERFACE = {
|
||||
play: null,
|
||||
retire:false,
|
||||
|
||||
auto_mode: null,
|
||||
|
||||
replay_turn: 0,
|
||||
history: history,
|
||||
|
||||
@ -839,6 +848,10 @@ const INTERFACE = {
|
||||
INTERFACE_DATA.rotate = +(!INTERFACE_DATA.rotate);
|
||||
|
||||
INTERFACE.draw();
|
||||
|
||||
if(INTERFACE_DATA.auto_mode !== null && INTERFACE_DATA.auto_mode == (GAME_DATA.turn & 1)) {
|
||||
setTimeout(INTERFACE.auto_play, 500);
|
||||
}
|
||||
} break;
|
||||
|
||||
// Send action to server for validation.
|
||||
@ -910,6 +923,17 @@ const INTERFACE = {
|
||||
},
|
||||
|
||||
auto() {
|
||||
if(INTERFACE_DATA.auto_mode === null) {
|
||||
console.log("auto on");
|
||||
INTERFACE_DATA.auto_mode = ((GAME_DATA.turn & 1) ^ 1);
|
||||
} else {
|
||||
console.log("auto off");
|
||||
INTERFACE_DATA.auto_mode = null;
|
||||
}
|
||||
INTERFACE.draw();
|
||||
},
|
||||
|
||||
auto_play() {
|
||||
function state_score(state, player) {
|
||||
let score = 0;
|
||||
let opponent = player ^ 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user