Skip to content

Commit

Permalink
Handle letting folks know why canceled games are annulled
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Oct 24, 2023
1 parent c1d8523 commit 87ab944
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/views/Game/PlayControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,14 @@ export function PlayControls({
pgettext("Displayed to the user when the game is annulled", "Game Annulled")}
{annulled && <i className="fa fa-question-circle" />}

{annulled && annulment_reason && <AnnulmentReason reason={annulment_reason} />}
{annulled && (
<AnnulmentReason
reason={
annulment_reason ||
(engine.outcome === "Cancellation" ? { cancellation: true } : null)
}
/>
)}
</div>
{((phase === "play" &&
mode === "play" &&
Expand Down Expand Up @@ -1306,7 +1313,11 @@ function currentPlayer(goban: Goban): number {
return ret;
}

function AnnulmentReason({ reason }: { reason: rest_api.AnnulmentReason }): JSX.Element {
function AnnulmentReason({
reason,
}: null | {
reason: rest_api.AnnulmentReason | { cancellation: true };
}): JSX.Element {
if (!reason) {
return null;
}
Expand Down Expand Up @@ -1349,6 +1360,9 @@ function AnnulmentReason({ reason }: { reason: rest_api.AnnulmentReason }): JSX.
// modern games.
arr.push(<div key={key}>Handicap out of range</div>);
break;
case "cancellation":
arr.push(<div key={key}>{_("The game was canceled so will not be rated.")}</div>);
break;
default:
arr.push(<div key={key}>{key}</div>);
break;
Expand Down

0 comments on commit 87ab944

Please sign in to comment.