Skip to content

Commit

Permalink
make doubling cube unavailable if final game of match
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeppell committed Jan 31, 2025
1 parent d27c2a9 commit d08a772
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chessground",
"version": "7.11.1-pstrat3.10",
"version": "7.11.1-pstrat3.11",
"description": "playstrategy.org chess ui, forked from lichess.org",
"type": "module",
"module": "dist/chessground.js",
Expand Down
15 changes: 9 additions & 6 deletions src/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ export function renderWrap(element: HTMLElement, s: HeadlessState, relative: boo
}

if (s.variant === 'backgammon' || s.variant === 'hyper' || s.variant === 'nackgammon') {
const mps = s.multiPointState;
if (s.doublingCube) {
container.appendChild(renderDoublingCube(s.doublingCube, false));
container.appendChild(
renderDoublingCube(s.doublingCube, mps !== undefined && mps.p1 === mps.p2 && mps.p1 + 1 === mps.target),
);
if (s.cubeActions) {
if (s.cubeActions.includes('offer'))
container.appendChild(
Expand All @@ -238,13 +241,13 @@ export function renderWrap(element: HTMLElement, s: HeadlessState, relative: boo
renderCubeAction('take', s.turnPlayerIndex + ' right', s.turnPlayerIndex === s.myPlayerIndex),
);
}
} else if (s.doublingCube === undefined && s.multiPointState) {
} else if (s.doublingCube === undefined && mps) {
container.appendChild(renderDoublingCube({ owner: 'both', value: 0 }, true));
}
if (s.multiPointState) {
container.appendChild(renderMultiPointTarget(s.multiPointState.target));
container.appendChild(renderMultiPointPlayerScore(s.multiPointState.p1, 'p1'));
container.appendChild(renderMultiPointPlayerScore(s.multiPointState.p2, 'p2'));
if (mps) {
container.appendChild(renderMultiPointTarget(mps.target));
container.appendChild(renderMultiPointPlayerScore(mps.p1, 'p1'));
container.appendChild(renderMultiPointPlayerScore(mps.p2, 'p2'));
if (s.autoRoll !== undefined) container.appendChild(renderAutoRollButton(s.autoRoll));
}
}
Expand Down

0 comments on commit d08a772

Please sign in to comment.