Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(game-lobby): player group organizer #893

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ async function onClickFromRandomCompositionButton(): Promise<void> {
isLoadingGetRandomGameComposition.value = true;
const randomGameComposition = await fetchRandomGameComposition({
players: createGameDto.value.players,
excludedRoles: ["prejudiced-manipulator"],
});
if (randomGameComposition !== null) {
setPlayersToCreateGameDto(randomGameComposition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ref="gameLobbyHeaderSetupButtons"
@additional-cards-manager-button-click="onAdditionalCardsManagerButtonClickFromGameLobbyHeaderSetupButtons"
@game-options-button-click="onGameOptionsButtonClickFromGameLobbyHeaderSetupButtons"
@group-organizer-button-click="onGroupOrganizerButtonClickFromGameLobbyHeaderSetupButtons"
@position-coordinator-button-click="onPositionCoordinatorButtonClickFromGameLobbyHeaderSetupButtons"
/>
</div>
Expand Down Expand Up @@ -85,6 +86,10 @@ function onAdditionalCardsManagerButtonClickFromGameLobbyHeaderSetupButtons(): v
emit("additionalCardsManagerButtonClick");
}

function onGroupOrganizerButtonClickFromGameLobbyHeaderSetupButtons(): void {
emit("groupOrganizerButtonClick");
}

function highlightGameOptionsButton(): void {
if (gameLobbyHeaderSetupButtons.value === null) {
throw createError("Game Lobby Header Setup Buttons is not defined");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<PrimeVueButton
id="game-lobby-header-group-organizer-button"
:pt="{ 'root': '!border-sky-600' }"
severity="info"
size="small"
@click.prevent="onClickFromGroupOrganizerButton"
>
<FontAwesomeIcon
class="animate__animated animate__heartBeat animate__slow"
icon="users"
/>

<span
id="game-lobby-header-group-organizer-button-text"
class="hidden md:inline"
>
{{ $t('components.GameLobbyHeaderGroupOrganizerButton.groupOrganizer') }}
</span>

<FontAwesomeIcon
v-if="!arePlayerGroupsSetForPrejudicedManipulatorIfPresent"
id="player-groups-not-set-warning-icon"
beat
icon="exclamation-circle"
/>
</PrimeVueButton>
</template>

<script setup lang="ts">
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { storeToRefs } from "pinia";
import type { GameLobbyHeaderGroupOrganizerButtonEmits } from "~/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/game-lobby-header-group-organizer-button.types";
import { useCreateGameDtoValidation } from "~/composables/api/game/useCreateGameDtoValidation";
import { useCreateGameDtoStore } from "~/stores/game/create-game-dto/useCreateGameDtoStore";

const emit = defineEmits<GameLobbyHeaderGroupOrganizerButtonEmits>();

const createGameDtoStore = useCreateGameDtoStore();
const { createGameDto } = storeToRefs(createGameDtoStore);

const { arePlayerGroupsSetForPrejudicedManipulatorIfPresent } = useCreateGameDtoValidation(createGameDto);

function onClickFromGroupOrganizerButton(): void {
emit("groupOrganizerButtonClick");
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type GameLobbyHeaderGroupOrganizerButtonEmits = {
groupOrganizerButtonClick: [];
};

export type { GameLobbyHeaderGroupOrganizerButtonEmits };
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
>
<FontAwesomeIcon
class="animate__animated animate__heartBeat animate__slow"
icon="users"
icon="group-arrows-rotate"
/>

<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
class="fade-list-item h-10 md:h-auto md:w-auto w-1/4"
@additional-cards-manager-button-click="onAdditionalCardsManagerButtonClickFromGameAdditionalCardsManagerButton"
/>

<GameLobbyHeaderGroupOrganizerButton
v-if="isGroupOrganizerVisible"
id="game-lobby-header-group-organizer-button"
key="game-group-organizer-button"
class="fade-list-item h-10 md:h-auto md:w-auto w-1/4"
@group-organizer-button-click="onGroupOrganizerButtonClickFromGameGroupOrganizerButton"
/>
</TransitionGroup>
</PrimeVueButtonGroup>
</template>
Expand All @@ -38,6 +46,7 @@ import { storeToRefs } from "pinia";
import type { ComponentPublicInstance } from "vue";
import type { GameLobbyHeaderSetupButtonsEmits, GameLobbyHeaderSetupButtonsExposed } from "~/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/game-lobby-header-setup-buttons.types";
import GameLobbyHeaderAdditionalCardsManagerButton from "~/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderAdditionalCardsManagerButton/GameLobbyHeaderAdditionalCardsManagerButton.vue";
import GameLobbyHeaderGroupOrganizerButton from "~/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.vue";
import GameLobbyHeaderOptionsButton from "~/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderOptionsButton/GameLobbyHeaderOptionsButton.vue";
import GameLobbyHeaderPositionCoordinatorButton from "~/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderPositionCoordinatorButton/GameLobbyHeaderPositionCoordinatorButton.vue";
import { useAnimateCss } from "~/composables/animate-css/useAnimateCss";
Expand All @@ -46,6 +55,7 @@ import { useCreateGameDtoStore } from "~/stores/game/create-game-dto/useCreateGa
const emit = defineEmits<GameLobbyHeaderSetupButtonsEmits>();

const createGameDtoStore = useCreateGameDtoStore();
const { getPlayersWithRoleNameInCreateGameDto } = createGameDtoStore;
const { createGameDto, doesCreateGameDtoContainAdditionalCardsDependantRoles } = storeToRefs(createGameDtoStore);

const minPlayerToDisplayPositionCoordinator = 2;
Expand All @@ -62,6 +72,8 @@ const isPositionCoordinatorVisible = computed<boolean>(() => createGameDto.value

const isAdditionalCardsManagerVisible = computed<boolean>(() => doesCreateGameDtoContainAdditionalCardsDependantRoles.value);

const isGroupOrganizerVisible = computed<boolean>(() => getPlayersWithRoleNameInCreateGameDto("prejudiced-manipulator").length > 0);

function onGameOptionsButtonClickFromGameOptionButton(): void {
emit("gameOptionsButtonClick");
}
Expand All @@ -74,6 +86,10 @@ function onAdditionalCardsManagerButtonClickFromGameAdditionalCardsManagerButton
emit("additionalCardsManagerButtonClick");
}

function onGroupOrganizerButtonClickFromGameGroupOrganizerButton(): void {
emit("groupOrganizerButtonClick");
}

async function highlightGameOptionsButton(): Promise<void> {
if (!gameLobbyHeaderOptionsButton.value) {
throw createError("Game Lobby Header Options Button is not defined");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type GameLobbyHeaderSetupButtonsEmits = {
gameOptionsButtonClick: [];
positionCoordinatorButtonClick: [];
additionalCardsManagerButtonClick: [];
groupOrganizerButtonClick: [];
};

type GameLobbyHeaderSetupButtonsExposed = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type GameLobbyHeaderEmits = {
gameOptionsButtonClick: [];
positionCoordinatorButtonClick: [];
additionalCardsManagerButtonClick: [];
groupOrganizerButtonClick: [];
};

type GameLobbyHeaderExposed = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
>
<DialogHeaderTitleOnly
id="game-lobby-position-coordinator-header"
icon="users"
icon="group-arrows-rotate"
icon-class="text-primary"
:title="$t('components.GameLobbyPositionCoordinator.positionCoordinator')"
/>
Expand Down
5 changes: 5 additions & 0 deletions app/pages/game-lobby.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
ref="gameLobbyHeader"
@additional-cards-manager-button-click="onAdditionalCardsButtonManagerClickFromGameLobbyHeader"
@game-options-button-click="onGameOptionsButtonClickFromGameLobbyHeader"
@group-organizer-button-click="onGroupOrganizerButtonClickFromGameLobbyHeader"
@position-coordinator-button-click="onPositionCoordinatorButtonClickFromGameLobbyHeader"
/>

Expand Down Expand Up @@ -117,6 +118,10 @@
gameLobbyAdditionalCardsManager.value.open();
}

function onGroupOrganizerButtonClickFromGameLobbyHeader(): void {
console.log("coucou");

Check failure on line 122 in app/pages/game-lobby.vue

View workflow job for this annotation

GitHub Actions / Lint 🔍

Unexpected console statement
}
Comment on lines +121 to +123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the console statement and implement the actual functionality.

The console statement is likely a placeholder for the actual implementation. Please remove it and implement the intended functionality for the onGroupOrganizerButtonClickFromGameLobbyHeader function.

Do you want me to open a GitHub issue to track this task or provide suggestions for the implementation?

Tools
GitHub Check: Lint 🔍

[failure] 122-122:
Unexpected console statement


function onRejectPlayersPositionStepFromGameLobbyFooter(): void {
if (!gameLobbyHeader.value) {
throw createError("Game Lobby Header is not defined");
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/vue-font-awesome-icon/vue-font-awesome-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {
faCompass,
faRotate,
faMagicWandSparkles,
faGroupArrowsRotate,
} from "@fortawesome/free-solid-svg-icons";

import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons";
Expand Down Expand Up @@ -162,6 +163,7 @@ library.add(
faCompass,
faRotate,
faMagicWandSparkles,
faGroupArrowsRotate,
);

export default defineNuxtPlugin(nuxtApp => {
Expand Down
3 changes: 3 additions & 0 deletions modules/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@
"ChangedGameOptionsList": {
"resetOptionAlt": "Reset to official rule the option : {option}",
"resetToOfficialRule": "Reset to official rule"
},
"GameLobbyHeaderGroupOrganizerButton": {
"groupOrganizer": "Group organizer"
}
}
}
3 changes: 3 additions & 0 deletions modules/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@
"ChangedGameOptionsList": {
"resetOptionAlt": "Revenir à la règle officielle pour la variante : {option}",
"resetToOfficialRule": "Revenir à la règle officielle"
},
"GameLobbyHeaderGroupOrganizerButton": {
"groupOrganizer": "Organisation des groupes"
}
}
}
Loading
Loading