-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for premature finishing of a round. Allow setting the remaining…
… runs to 0 if all players played their solo.
- Loading branch information
Showing
8 changed files
with
165 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, {ReactElement, useState} from 'react'; | ||
import {Button, Form, Header, Icon, Message, Modal} from 'semantic-ui-react'; | ||
import {useSortedGames} from '../../store/Games'; | ||
import {useFinishRound} from '../../store/Round/FinishRound'; | ||
import {usePlayersWithStats} from '../../store/Players'; | ||
|
||
export default function FinishRoundPrematurely(): ReactElement | null { | ||
const sortedGames = useSortedGames(); | ||
const lastGame = sortedGames[sortedGames.length - 1]; | ||
const finishRound = useFinishRound(); | ||
const [open, setOpen] = useState(false); | ||
const players = usePlayersWithStats(); | ||
const playersMissingSolo = players.filter(({dutySoloPlayed}) => !dutySoloPlayed); | ||
|
||
return <section> | ||
<Form.Button color={'grey'} size={'mini'} onClick={() => setOpen(true)}>Runde vorzeitig abschließen</Form.Button> | ||
|
||
<Modal open={open} onClose={() => setOpen(false)} basic size='small' closeIcon> | ||
<Header> | ||
<Icon name={'flag checkered'}/> | ||
Runde abschließen | ||
</Header> | ||
<Modal.Content> | ||
<p>Möchtest du die Runde jetzt nach {lastGame.gameNumber} Spielen wirklich abschließen?</p> | ||
{playersMissingSolo.length > 0 && <Message error visible> | ||
<Message.Header>Folgende Spieler haben noch nicht ihr Solo gespielt:</Message.Header> | ||
<Message.Content>{playersMissingSolo.map(({member}) => member.name).join(', ')}</Message.Content> | ||
</Message>} | ||
</Modal.Content> | ||
<Modal.Actions> | ||
<Button inverted onClick={() => { | ||
finishRound(true); | ||
setOpen(false); | ||
}}> | ||
<Icon name='checkmark'/> Ja, Runde vorzeitig abschließen | ||
</Button> | ||
</Modal.Actions> | ||
</Modal> | ||
</section>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, {ReactElement, useState} from 'react'; | ||
import {Button, Divider, Form, Header, Icon, Modal} from 'semantic-ui-react'; | ||
import {usePatchRound, useRound} from '../../store/Rounds'; | ||
import NumberStepper from '../../components/NumberStepper'; | ||
import {useSortedGames} from '../../store/Games'; | ||
import {usePlayersWithStats} from '../../store/Players'; | ||
|
||
export default function RoundEndInfoPopup({duration, endKnown, setOpen}: { | ||
duration: number | null; | ||
endKnown: boolean; | ||
setOpen: (open: boolean) => void; | ||
}): ReactElement { | ||
const {data} = useRound()!; | ||
const patchRound = usePatchRound(); | ||
const sortedGames = useSortedGames(); | ||
const lastGameRunNumber = sortedGames.length ? sortedGames[sortedGames.length - 1].data.runNumber : 1; | ||
const [remaining, setRemaining] = useState(data.roundDuration ? (data.roundDuration - lastGameRunNumber) : 1); | ||
const playersWithStats = usePlayersWithStats(); | ||
const activePlayersWithoutSolo = playersWithStats.filter( | ||
(p) => p.player.leftAfterGameNumber === null && !p.dutySoloPlayed); | ||
const minimumRoundNumbers = activePlayersWithoutSolo.length ? 1 : 0; | ||
|
||
return <> | ||
<Header> | ||
<Icon name={'sync alternate'}/> | ||
Spielende | ||
</Header> | ||
<Modal.Content> | ||
<p>Wir befinden uns derzeit in Durchgang {lastGameRunNumber}.</p> | ||
|
||
{endKnown && <p>Das Spiel endet nach {duration} Durchgängen.</p>} | ||
|
||
{data.dynamicRoundDuration && <> | ||
<Divider section/> | ||
|
||
<Form className="u-flex-row-around u-align-center"> | ||
<Form.Field> | ||
Noch | ||
</Form.Field> | ||
<NumberStepper value={remaining} min={minimumRoundNumbers} onChange={setRemaining} inverted/> | ||
<Form.Field> | ||
volle Durchgänge | ||
</Form.Field> | ||
</Form> | ||
</>} | ||
</Modal.Content> | ||
{data.dynamicRoundDuration && <Modal.Actions> | ||
<Button inverted onClick={() => { | ||
patchRound({data: {roundDuration: lastGameRunNumber + remaining}}); | ||
setOpen(false); | ||
}}> | ||
<Icon name='checkmark'/> Ok | ||
</Button> | ||
</Modal.Actions>} | ||
</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters