30 lines
831 B
JavaScript
30 lines
831 B
JavaScript
"use strict";
|
|
|
|
import { Team } from "/models/round.js";
|
|
import Game from "/models/game.js";
|
|
|
|
export default class GameView {
|
|
/** @param {{ attrs: { model: Game } }} param The game model to use. */
|
|
view({ attrs: { model } }) {
|
|
let { ourPoints, theirPoints } = model.result;
|
|
|
|
return m.fragment([
|
|
(model.rounds.length !== 0)
|
|
? m("tbody", model.rounds.map(function(round) {
|
|
return m("tr", [
|
|
m("td", round.winner === Team.They ? round.points : ""),
|
|
m("td", round.winner === Team.We ? round.points : ""),
|
|
]);
|
|
}))
|
|
: m("tbody", [ m("td", "0"), m("td", "0") ]),
|
|
(!model.decided)
|
|
? m("tfoot", [
|
|
m("tr", [
|
|
m("th", theirPoints), m("th", ourPoints),
|
|
]),
|
|
])
|
|
: null,
|
|
]);
|
|
}
|
|
}
|