X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=715f4e053a03b9b092618b4e6cdbf0e33b30bdf4;hb=55a15dcb7df5091f46f7dd9c170b2aae5846c6c0;hp=da72320413674fd6a57593188e1651f3afb07432;hpb=67c5c19892b8bf3d851c4b7f4fcb1514b8491091;p=xogo.git diff --git a/base_rules.js b/base_rules.js index da72320..715f4e0 100644 --- a/base_rules.js +++ b/base_rules.js @@ -760,7 +760,7 @@ export default class ChessRules { } updateReserve(color, piece, count) { - if (this.options["cannibal"] && C.CannibalKing[piece]) + if (this.options["cannibal"] && C.CannibalKings[piece]) piece = "k"; //capturing cannibal king: back to king form const oldCount = this.reserve[color][piece]; this.reserve[color][piece] = count; @@ -2160,20 +2160,21 @@ export default class ChessRules { }; animateRec(0); }; - const checkDisplayThenAnimate = () => { + // Delay if user wasn't focused: + const checkDisplayThenAnimate = (delay) => { if (boardContainer.style.display == "none") { alert("New move! Let's go back to game..."); document.getElementById("gameInfos").style.display = "none"; boardContainer.style.display = "block"; setTimeout(launchAnimation, 700); } - else launchAnimation(); //focused user! + else setTimeout(launchAnimation, delay || 0); }; let boardContainer = document.getElementById("boardContainer"); if (document.hidden) { document.onvisibilitychange = () => { document.onvisibilitychange = undefined; - checkDisplayThenAnimate(); + checkDisplayThenAnimate(700); }; } else checkDisplayThenAnimate();