Skip to content

Commit

Permalink
feat: Remove possibility to pause the game from the user-facing app
Browse files Browse the repository at this point in the history
  • Loading branch information
barnslig committed Jul 6, 2022
1 parent eef0dae commit 8f3c324
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 294 deletions.
24 changes: 0 additions & 24 deletions app/lang-compiled/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
"value": "Sende Nachricht"
}
],
"3eJT2C": [
{
"type": 0,
"value": "Das Spiel ist pausiert. Du kannst es aber für alle fortsetzen."
}
],
"7vghdx": [
{
"type": 0,
Expand Down Expand Up @@ -107,12 +101,6 @@
"value": "QR-Code nicht ausführen"
}
],
"R14Oy/": [
{
"type": 0,
"value": "Spiel für alle fortsetzen"
}
],
"R6ODBn": [
{
"type": 0,
Expand Down Expand Up @@ -219,12 +207,6 @@
"value": "Bewegungspunkte"
}
],
"gyakmc": [
{
"type": 0,
"value": "Spiel für alle fortsetzen"
}
],
"h1UmHT": [
{
"type": 0,
Expand Down Expand Up @@ -279,12 +261,6 @@
"value": "Scanner"
}
],
"vcAwuf": [
{
"type": 0,
"value": "Spiel für alle pausieren"
}
],
"xlGZnG": [
{
"type": 0,
Expand Down
16 changes: 0 additions & 16 deletions app/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"defaultMessage": "Sende Nachricht",
"description": "qr code action label"
},
"3eJT2C": {
"defaultMessage": "Das Spiel ist pausiert. Du kannst es aber für alle fortsetzen.",
"description": "game paused message description"
},
"7vghdx": {
"defaultMessage": "Aktionen anzeigen",
"description": "appbar menu toggle"
Expand Down Expand Up @@ -71,10 +67,6 @@
"defaultMessage": "QR-Code nicht ausführen",
"description": "app bar close button of the confirm qr code action page"
},
"R14Oy/": {
"defaultMessage": "Spiel für alle fortsetzen",
"description": "appbar menu item continue game"
},
"R6ODBn": {
"defaultMessage": "QR-Code scannen",
"description": "scanner page title"
Expand Down Expand Up @@ -131,10 +123,6 @@
"defaultMessage": "Bewegungspunkte",
"description": "parameter label"
},
"gyakmc": {
"defaultMessage": "Spiel für alle fortsetzen",
"description": "game paused message continue button label"
},
"h1UmHT": {
"defaultMessage": "Spiel pausiert",
"description": "game paused message title"
Expand Down Expand Up @@ -171,10 +159,6 @@
"defaultMessage": "Scanner",
"description": "main nav scanner page item label"
},
"vcAwuf": {
"defaultMessage": "Spiel für alle pausieren",
"description": "appbar menu item pause game"
},
"xlGZnG": {
"defaultMessage": "Spiel-Code",
"description": "start code page game id input label"
Expand Down
32 changes: 0 additions & 32 deletions app/src/app/pages/IndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import useCharacter from "../../common/hooks/useCharacter";
import useClock from "../../common/hooks/api/useClock";
import useLeaveGame from "../../common/hooks/useLeaveGame";
import usePwaInstaller from "../../common/hooks/usePwaInstaller";
import useUpdateClock from "../../common/hooks/api/useUpdateClock";

import ButtonProgressIndicator from "../../common/components/ButtonProgressIndicator";
import ChooseCharacterHeroMessage from "../../common/components/ChooseCharacterHeroMessage";
import GameOverHeroMessage from "../../common/components/GameOverHeroMessage";
import PausedHeroMessage from "../../common/components/PausedHeroMessage";
Expand All @@ -46,7 +44,6 @@ const IndexPage = (props: IndexPageProps) => {

const appBarMenuAnchorEl = React.useRef<HTMLButtonElement>(null);
const [appBarMenuIsOpen, setAppBarMenuIsOpen] = React.useState(false);
const [updateClockIsLoading, updateClock] = useUpdateClock();

const leaveGame = useLeaveGame();
const onLeaveGame = () => {
Expand Down Expand Up @@ -107,35 +104,6 @@ const IndexPage = (props: IndexPageProps) => {
open={appBarMenuIsOpen}
onClose={() => setAppBarMenuIsOpen(false)}
>
{isPaused ? (
<MenuItem
disabled={updateClockIsLoading}
onClick={async () => {
await updateClock("running");
setAppBarMenuIsOpen(false);
}}
>
<FormattedMessage
defaultMessage="Spiel für alle fortsetzen"
description="appbar menu item continue game"
/>
{updateClockIsLoading && <ButtonProgressIndicator />}
</MenuItem>
) : (
<MenuItem
disabled={updateClockIsLoading}
onClick={async () => {
await updateClock("paused");
setAppBarMenuIsOpen(false);
}}
>
<FormattedMessage
defaultMessage="Spiel für alle pausieren"
description="appbar menu item pause game"
/>
{updateClockIsLoading && <ButtonProgressIndicator />}
</MenuItem>
)}
<MenuItem onClick={onLeaveGame}>
<FormattedMessage
defaultMessage="Spiel verlassen"
Expand Down
21 changes: 1 addition & 20 deletions app/src/app/pages/__snapshots__/IndexPage.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ exports[`can show the game is paused message 1`] = `
</div>
</nav>
<main
class="MuiBox-root css-elj48x"
class="MuiBox-root css-96m5c5"
>
<div
class="MuiContainer-root MuiContainer-maxWidthSm css-cuefkz-MuiContainer-root"
Expand All @@ -272,25 +272,6 @@ exports[`can show the game is paused message 1`] = `
>
Spiel pausiert
</h2>
<p
class="MuiTypography-root MuiTypography-body2 css-r40f8v-MuiTypography-root"
>
Das Spiel ist pausiert. Du kannst es aber für alle fortsetzen.
</p>
<div
class="MuiBox-root css-fv0itm"
>
<button
class="MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButtonBase-root css-1rwt2y5-MuiButtonBase-root-MuiButton-root"
tabindex="0"
type="button"
>
Spiel für alle fortsetzen
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
</main>
</div>
Expand Down
49 changes: 10 additions & 39 deletions app/src/common/components/PausedHeroMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
import { Box, Button } from "@mui/material";
import { FormattedMessage } from "react-intl";
import * as React from "react";

import ButtonProgressIndicator from "./ButtonProgressIndicator";
import HeroMessage from "./HeroMessage";
import useUpdateClock from "../hooks/api/useUpdateClock";

const PausedHeroMessage = () => {
const [isLoading, updateClock] = useUpdateClock();

return (
<HeroMessage
title={
<FormattedMessage
defaultMessage="Spiel pausiert"
description="game paused message title"
/>
}
description={
<FormattedMessage
defaultMessage="Das Spiel ist pausiert. Du kannst es aber für alle fortsetzen."
description="game paused message description"
/>
}
after={
<Box marginTop={4} marginBottom={6}>
<Button
variant="outlined"
color="primary"
onClick={() => updateClock("running")}
disabled={isLoading}
>
<FormattedMessage
defaultMessage="Spiel für alle fortsetzen"
description="game paused message continue button label"
/>
{isLoading && <ButtonProgressIndicator />}
</Button>
</Box>
}
/>
);
};
const PausedHeroMessage = () => (
<HeroMessage
title={
<FormattedMessage
defaultMessage="Spiel pausiert"
description="game paused message title"
/>
}
/>
);

export default PausedHeroMessage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`renders correctly 1`] = `
<main
class="MuiBox-root css-elj48x"
class="MuiBox-root css-96m5c5"
>
<div
class="MuiContainer-root MuiContainer-maxWidthSm css-cuefkz-MuiContainer-root"
Expand All @@ -12,25 +12,6 @@ exports[`renders correctly 1`] = `
>
Spiel pausiert
</h2>
<p
class="MuiTypography-root MuiTypography-body2 css-r40f8v-MuiTypography-root"
>
Das Spiel ist pausiert. Du kannst es aber für alle fortsetzen.
</p>
<div
class="MuiBox-root css-fv0itm"
>
<button
class="MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButtonBase-root css-1rwt2y5-MuiButtonBase-root-MuiButton-root"
tabindex="0"
type="button"
>
Spiel für alle fortsetzen
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
</main>
`;
42 changes: 0 additions & 42 deletions app/src/common/hooks/api/useUpdateClock.ts

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { rest } from "msw";

import { ClockApiResponse } from "../common/hooks/api/useClock";
import { ClockState } from "../common/types/Clock";

let clockState: ClockState = "running";

export const handlers = [
rest.get("/games/:gameId/clock", (req, res, ctx) => {
const clockRes: ClockApiResponse = require("./data/clock.json");
clockRes.data.attributes.state = clockState;
return res(ctx.json(clockRes));
}),
rest.post("/games/:gameId/clock", (req, res, ctx) => {
clockState =
JSON.parse(req.body as string).data.attributes.state || "running";

const clockRes: ClockApiResponse = require("./data/clock.json");
clockRes.data.attributes.state = clockState;
return res(ctx.json(clockRes));
}),

Expand Down
14 changes: 0 additions & 14 deletions backend/dpt_app/trails/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,6 @@ def get_clock(request: HttpRequest, gameId: str):
return serialize_clock(request.game)


@api.post("games/{str:gameId}/clock", response=ClockSchema, url_name="clock")
@wrap_get_game
@wrap_get_player
def post_clock(request: HttpRequest, gameId: str, payload: ClockSchema):
if payload.data.attributes.state == "running":
request.game.clock_state = ClockType.RUNNING
elif payload.data.attributes.state == "paused":
request.game.clock_state = ClockType.STOPPED

request.game.save()

return serialize_clock(request.game)


def serialize_player(player: Player):
character = None
if player.character:
Expand Down
28 changes: 0 additions & 28 deletions backend/dpt_app/trails/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,34 +323,6 @@ def test_get(self):
}
})

def test_post(self):
self.assertEqual(self.game.clock_state, ClockType.STOPPED)

url = reverse("api-1.0.0:clock", args=(self.game.slug,))
res = self.client.post(url, HTTP_AUTHORIZATION=self.player.bearer, content_type="application/json", data={
"data": {
"type": "clock",
"attributes": {
"state": "running"
}
}
})
self.assertEqual(res.status_code, 200)
self.assertEqual(res.json(), {
"data": {
"type": "clock",
"id": "1",
"attributes": {
"state": "running",
"speed": 1.0
}
}
})

self.game.refresh_from_db()

self.assertEqual(self.game.clock_state, ClockType.RUNNING)


class PlayerApiTest(GameTestCase):
def test_put(self):
Expand Down
Loading

0 comments on commit 8f3c324

Please sign in to comment.