-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(game-lobby): game options confirm step in lobby (#845)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a confirmation dialog for game options changes in the game lobby, enhancing user interaction before starting the game. - Added functionality to display and manage a list of changed game options, allowing users to revert to official rules easily. - Enhanced the game lobby header and footer with new event handling for game options changes. - Updated the Elder role's elimination logic to clarify consequences based on player interactions. - **Bug Fixes** - Improved error handling when game options are altered and the corresponding actions are triggered. - **Documentation** - Updated localization files to include new phrases and improved clarity for game options changes. - **Tests** - Expanded test coverage for game options functionality, including scenarios for confirming changes and handling user interactions effectively. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
3a20f01
commit 20cc2ce
Showing
66 changed files
with
118,406 additions
and
111,009 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Game Lobby Confirm Dialog" type="cucumber.js" factoryName="Cucumber.js" folderName="Tags"> | ||
<option name="myFilePath" value="$PROJECT_DIR$/tests/acceptance" /> | ||
<option name="myNameFilter" value="" /> | ||
<option name="cucumberJsArguments" value="--config config/cucumber/cucumber.json --parallel 1 --tags @game-lobby-confirm-dialog" /> | ||
<option name="workingDirectory" value="$PROJECT_DIR$" /> | ||
<envs> | ||
<env name="NODE_OPTIONS" value="--import tsx/esm" /> | ||
</envs> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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
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
55 changes: 55 additions & 0 deletions
55
...tartGameConfirmDialogGameOptionsChanged/ChangedGameOptionsList/ChangedGameOptionsList.vue
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,55 @@ | ||
<template> | ||
<div id="changed-game-options-list"> | ||
<ul class="max-h-64 overflow-y-scroll px-1"> | ||
<li | ||
v-for="gameOptionText in changedGameOptionsTexts" | ||
:key="gameOptionText" | ||
class="!bg-sky-950 border-2 border-gray-600 changed-game-options-list-item flex gap-4 items-center px-2 py-1 rounded-md shadow-black shadow-md" | ||
> | ||
<PrimeVueButton | ||
v-p-tooltip.top="$t('components.ChangedGameOptionsList.resetToOfficialRule')" | ||
:aria-label="$t('components.ChangedGameOptionsList.resetOptionAlt', { 'option': gameOptionText })" | ||
class="!w-2 h-4 reset-changed-game-option-button text-xs" | ||
raised | ||
severity="danger" | ||
size="small" | ||
@click.prevent="onClickFromResetChangedGameOptionButton(gameOptionText)" | ||
> | ||
<template #icon> | ||
<FontAwesomeIcon | ||
icon="minus" | ||
/> | ||
</template> | ||
</PrimeVueButton> | ||
|
||
<p class="!leading-relaxed !mb-0"> | ||
{{ gameOptionText }} | ||
</p> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; | ||
import { storeToRefs } from "pinia"; | ||
import { useGameOptionsTexts } from "~/composables/api/game/game-options/useGameOptionsTexts"; | ||
import { useCreateGameDtoStore } from "~/stores/game/create-game-dto/useCreateGameDtoStore"; | ||
const createGameDtoStore = useCreateGameDtoStore(); | ||
const { resetCreateGameOptionDto } = createGameDtoStore; | ||
const { createGameOptionsDto } = storeToRefs(createGameDtoStore); | ||
const { changedGameOptionsTexts, getGameOptionKeyFromText } = useGameOptionsTexts(createGameOptionsDto); | ||
function onClickFromResetChangedGameOptionButton(gameOptionText: string): void { | ||
const key = getGameOptionKeyFromText(gameOptionText); | ||
if (key === undefined) { | ||
return; | ||
} | ||
resetCreateGameOptionDto(key); | ||
if (key === "roles.sheriff.electedAt.turn") { | ||
resetCreateGameOptionDto("roles.sheriff.electedAt.phaseName"); | ||
} | ||
} | ||
</script> |
88 changes: 88 additions & 0 deletions
88
...GameConfirmDialogGameOptionsChanged/GameLobbyStartGameConfirmDialogGameOptionsChanged.vue
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,88 @@ | ||
<template> | ||
<div | ||
id="game-lobby-start-game-confirm-dialog-game-options-changed" | ||
class="flex flex-col gap-6 items-center justify-center" | ||
> | ||
<div class="flex flex-col gap-2 items-center justify-center"> | ||
<NuxtImg | ||
:alt="$t(`components.GameLobbyStartGameConfirmDialogGameOptionsChanged.changedGameOptionsIcon`)" | ||
:height="svgSize" | ||
placeholder="/svg/misc/infinite-spinner.svg" | ||
src="/svg/misc/rabbit-in-hat.svg" | ||
:width="svgSize" | ||
/> | ||
</div> | ||
|
||
<h4 | ||
id="game-lobby-start-game-confirm-dialog-game-options-changed-text" | ||
class="text-center" | ||
> | ||
{{ gameOptionsChangedText }} | ||
</h4> | ||
|
||
<ChangedGameOptionsList class="w-full"/> | ||
|
||
<div | ||
id="game-lobby-start-game-confirm-dialog-game-options-changed-actions" | ||
class="flex gap-2 items-center justify-evenly w-full" | ||
> | ||
<PrimeVueButton | ||
id="reject-step-button" | ||
:label="$t(`components.GameLobbyStartGameConfirmDialogGameOptionsChanged.seeAllGameOptions`)" | ||
severity="info" | ||
@click.prevent="onRejectGameOptionsChangedStep" | ||
> | ||
<template #icon> | ||
<FontAwesomeIcon icon="eye"/> | ||
</template> | ||
</PrimeVueButton> | ||
|
||
<PrimeVueButton | ||
id="confirm-step-button" | ||
:label="$t(`shared.actions.confirm`)" | ||
severity="success" | ||
@click.prevent="onConfirmGameOptionsChangedStep" | ||
> | ||
<template #icon> | ||
<FontAwesomeIcon icon="check"/> | ||
</template> | ||
</PrimeVueButton> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; | ||
import { storeToRefs } from "pinia"; | ||
import ChangedGameOptionsList from "~/components/pages/game-lobby/GameLobbyFooter/GameLobbyStartGameButton/GameLobbyStartGameConfirmDialog/GameLobbyStartGameConfirmDialogContainer/GameLobbyStartGameConfirmDialogContent/GameLobbyStartGameConfirmDialogGameOptionsChanged/ChangedGameOptionsList/ChangedGameOptionsList.vue"; | ||
import type { GameLobbyStartGameConfirmDialogGameOptionsChangedEmits } from "~/components/pages/game-lobby/GameLobbyFooter/GameLobbyStartGameButton/GameLobbyStartGameConfirmDialog/GameLobbyStartGameConfirmDialogContainer/GameLobbyStartGameConfirmDialogContent/GameLobbyStartGameConfirmDialogGameOptionsChanged/game-lobby-start-game-confirm-dialog-game-options-changed.types"; | ||
import { useGameOptionsTexts } from "~/composables/api/game/game-options/useGameOptionsTexts"; | ||
import { useCreateGameDtoStore } from "~/stores/game/create-game-dto/useCreateGameDtoStore"; | ||
const emit = defineEmits<GameLobbyStartGameConfirmDialogGameOptionsChangedEmits>(); | ||
const svgSize = 75; | ||
const createGameDtoStore = useCreateGameDtoStore(); | ||
const { createGameOptionsDto } = storeToRefs(createGameDtoStore); | ||
const { changedGameOptionsTexts } = useGameOptionsTexts(createGameOptionsDto); | ||
const { t } = useI18n(); | ||
const changedGameOptionsCount = computed<number>(() => changedGameOptionsTexts.value.length); | ||
const gameOptionsChangedText = computed<string>(() => { | ||
const tKey = "components.GameLobbyStartGameConfirmDialogGameOptionsChanged.gameOptionsChanged"; | ||
return t(tKey, { count: changedGameOptionsCount.value }, changedGameOptionsCount.value); | ||
}); | ||
function onConfirmGameOptionsChangedStep(): void { | ||
emit("confirmStep"); | ||
} | ||
function onRejectGameOptionsChangedStep(): void { | ||
emit("rejectGameOptionsChangedStep"); | ||
} | ||
</script> |
6 changes: 6 additions & 0 deletions
6
...alogGameOptionsChanged/game-lobby-start-game-confirm-dialog-game-options-changed.types.ts
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,6 @@ | ||
type GameLobbyStartGameConfirmDialogGameOptionsChangedEmits = { | ||
confirmStep: []; | ||
rejectGameOptionsChangedStep: []; | ||
}; | ||
|
||
export type { GameLobbyStartGameConfirmDialogGameOptionsChangedEmits }; |
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
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
Oops, something went wrong.