add breaks to end dialog

main
Ugo Finnendahl 2 months ago
parent ba04659d6f
commit 9efe183658
  1. 19
      assets/js/views/xoi/logic.js
  2. 6
      assets/js/views/xoi/main.js

@ -113,6 +113,25 @@ export function getGameProps(page, current_set, current_leg) {
});
ret.current_player = current_player;
const breaks = computed(() => {
let b = [0,0];
for (const j in page.game.sets) {
const set = page.game.sets[j];
for (const i in set.legs) {
const l = set.legs[i];
if (l.visits[l.visits.length-1].toGo === undefined) {
return b;
}
if (l.visits[l.visits.length-1].toGo[0] == 0 && i%2 == 1)
b[0] += 1;
else if (l.visits[l.visits.length-1].toGo[1] == 0 && i%2 == 0)
b[1] += 1;
}
}
return b;
});
ret.breaks = breaks;
const getVal = (tr) => {
const val = tr.trim();
if (val == "") {

@ -454,11 +454,11 @@ const impossibleDialog = (sum) => {
}]}
}
const gameOverDialog = (winner, points) => {
const gameOverDialog = (winner, points, breaks) => {
return {
"withshortkey": true,
"title": `Game Over`,
"text": `${winner != "DRAW" ? "The winner is": ""} ${winner} with ${points[0]}-${points[1]}`,
"text": `${winner != "DRAW" ? "The winner is": ""} ${winner} with ${points[0]}-${points[1]} (Breaks: ${breaks[0]}-${breaks[1]})`,
"buttons": [
{
"component": "d-plainElem",
@ -650,7 +650,7 @@ const gameStateMachine = (gamestack, stack, page, computedProps) => {
if (winner != -2){
name = page.players[winner].forename;
}
const [answer, error] = await overlayAndPop("d-dialog", gameOverDialog(name, points[1]), stack);
const [answer, error] = await overlayAndPop("d-dialog", gameOverDialog(name, points[1], computedProps.breaks.value), stack);
if (answer == "end") {
saveGame(page);
return [undefined, page.stats.winner];

Loading…
Cancel
Save