Use the new public field counting the turns and adapt the web

interface
This commit is contained in:
Tissevert 2019-10-17 19:25:35 +02:00
parent 8c107c0c2a
commit 55ec64fafc
3 changed files with 13 additions and 12 deletions

View File

@ -65,6 +65,7 @@ extractPublicState game = PublicState {
, river = KoiKoi.river game
, step = KoiKoi.step game
, trick = KoiKoi.trick game
, turns = 24 - length (KoiKoi.deck game)
, rounds = KoiKoi.rounds game
}

View File

@ -111,39 +111,39 @@
margin: 0;
}
#rest.init, #rest.count24 {
#rest.init, #rest.turn0 {
box-shadow: 2px 3px 0 0 #555, 4px 6px 0 0 #555, 6px 9px 0 0 #555;
}
#rest.count22 {
#rest.turn2 {
box-shadow: 2px 3px 0 0 #555, 4px 6px 0 0 #555, 5.5px 8.3px 0 0 #555;
}
#rest.count20 {
#rest.turn4 {
box-shadow: 2px 3px 0 0 #555, 4px 6px 0 0 #555, 5px 7.5px 0 0 #555;
}
#rest.count18 {
#rest.turn6 {
box-shadow: 2px 3px 0 0 #555, 4px 6px 0 0 #555, 4.5px 6.8px 0 0 #555;
}
#rest.count16 {
#rest.turn8 {
box-shadow: 2px 3px 0 0 #555, 4px 6px 0 0 #555;
}
#rest.count14 {
#rest.turn10 {
box-shadow: 2px 3px 0 0 #555, 3.5px 5.3px 0 0 #555;
}
#rest.count12 {
#rest.turn12 {
box-shadow: 2px 3px 0 0 #555, 3px 4.5px 0 0 #555;
}
#rest.count10 {
#rest.turn14 {
box-shadow: 2px 3px 0 0 #555, 2.5px 3.8px 0 0 #555;
}
#rest.count8 {
#rest.turn16 {
box-shadow: 2px 3px 0 0 #555;
}

View File

@ -53,7 +53,7 @@ function Game(modules) {
}
function handleGameMessage(o) {
if(o.game.deck == 24) { // deck is full, means new round
if(o.game.publicState.turns == 0) {
if(o.logs.length > 0) { // but still some logs, from the previous round
return modules.async.sequence(applyDiff(o), setGame(o)); // so play the diff, then set the new round
} else {
@ -99,7 +99,7 @@ function Game(modules) {
setTurned(o.game.step.contents);
} else {
if(status.step == "ToPlay" && o.game.playing == o.game.oyake) {
rest.className = ["card", "count" + o.game.deck].join(' ');
rest.className = ["card", "turn" + o.game.publicState.turns].join(' ');
}
if(deck.lastChild.id != "rest") {
deck.removeChild(deck.lastChild);
@ -294,7 +294,7 @@ function Game(modules) {
function setTheirCards(game) {
var turnsTheyPlayed = Math.floor(
(24 - game.deck + (modules.session.is(game.oyake) ? 0 : 1)) / 2
(game.publicState.turns + (modules.session.is(game.oyake) ? 0 : 1)) / 2
);
modules.dom.clear(sets.them.hand.dom);
for(var i = 0; i < 8 - turnsTheyPlayed; i++) {