Skip to content

Commit

Permalink
don't show finish dialog in offline games
Browse files Browse the repository at this point in the history
  • Loading branch information
naueramant committed Jul 28, 2024
1 parent a7ef982 commit 5d834db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/views/Game/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ const Header: FunctionComponent = () => {
const [exitGameDialogOpen, setExitGameDialogOpen] = useState(false);
const [dnfDialogOpen, setDNFDialogOpen] = useState(false);

const showExitGameDialog = () => {
if (game.offline && gameMetrics.done) {
game.ExitGame({
dnf: false,
});

return;
}

setExitGameDialogOpen(true);
};

const closeExitGameDialog = (e: { ok: boolean }) => {
setExitGameDialogOpen(false);

Expand Down Expand Up @@ -254,7 +266,7 @@ const Header: FunctionComponent = () => {
sx={{
color: "primary.contrastText",
}}
onClick={() => setExitGameDialogOpen(true)}
onClick={showExitGameDialog}
>
<IoExitOutline />
</IconButton>
Expand Down
5 changes: 4 additions & 1 deletion src/views/Game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const GameView: FunctionComponent = () => {
const game = useGame((state) => ({
DrawCard: state.DrawCard,
cards: state.draws,
offline: state.offline,
}));

const settings = useSettings((state) => ({
Expand Down Expand Up @@ -216,7 +217,9 @@ const GameView: FunctionComponent = () => {

<ChugDialog open={gameMetrics.chugging} />

<GameFinishedDialog open={gameMetrics.done && !gameMetrics.chugging} />
<GameFinishedDialog
open={!game.offline && gameMetrics.done && !gameMetrics.chugging}
/>

<Terminal
open={showTerminal}
Expand Down

0 comments on commit 5d834db

Please sign in to comment.