Skip to content

Commit

Permalink
Style recommended players modal and add recommended number of players…
Browse files Browse the repository at this point in the history
… to options
  • Loading branch information
jengu288 committed Mar 11, 2024
1 parent ba33039 commit b766022
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
1 change: 0 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/jsLinters/eslint.xml

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/components/endRound/EndRound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ watch(selectedId, async (val: string) => {
});
onMounted(() => {
selectedId.value = roomStore.self!.id;
selectedId.value = roomStore.self.id;
});
function sendVote() {
Expand Down
24 changes: 17 additions & 7 deletions client/src/components/lobby/Lobby.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { useRoomStore } from '@/stores/room.js';
import { useI18n } from 'vue-i18n';
import { Portal, PortalTarget } from 'portal-vue';
import { Modal } from 'bootstrap';
import { useGameStore } from '@/stores/game';
const click = new AudioWrap(ClickMp3);
const roomStore = useRoomStore();
const gameStore = useGameStore();
onUnmounted(() => {
Modal.getInstance(document.getElementById('recPlayersModal') as HTMLElement)?.dispose();
Expand All @@ -24,7 +26,7 @@ const canStart = computed<boolean>(() => {
});
function startGameRequest() {
if (roomStore.players.length <= 3) {
if (roomStore.players.length <= gameStore.options.recPlayers) {
//canStart is already checked so min players has been reached
startGame();
} else {
Expand All @@ -46,16 +48,24 @@ const { t } = useI18n();
<h1 v-t="'players'" class="font-fancy text-dark display-3" />
<player-list />
<portal to="modal">
<div id="recPlayersModal" class="modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div
id="recPlayersModal"
class="modal fade"
tabindex="-1"
aria-labelledby="recPlayersModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 id="exampleModalLabel" class="modal-title">Modal title</h5>
<h5 id="recPlayersModalLabel" class="modal-title mx-auto font-fancy display-6">Warning!</h5>
</div>
<div class="modal-body">
This lobby is a bit crowded for the best game experience. Splitting into two groups could make things more
enjoyable!
</div>
<div class="modal-body">here is a asd</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" @click="startGame">Start Game</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-blue" @click="startGame">Start Game</button>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/responseMatching/MatchingSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const gameStore = useGameStore();
const roomStore = useRoomStore();
const matchers = computed<Player[]>(() => {
return roomStore.players.filter((player: Player) => player.active && player.id !== gameStore.selector!.id);
return roomStore.players.filter((player: Player) => player.active && player.id !== gameStore.selector.id);
});
function endRound(): void {
Expand Down
28 changes: 14 additions & 14 deletions client/src/stores/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export const useGameStore = defineStore('game', {
getters: {
isSelector(): boolean {
const room = useRoomStore();
return this.selector?.id === room.self!.id;
return this.selector?.id === room.self.id;

Check failure on line 89 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 89 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
},
playerResponses() {
const room = useRoomStore();
return (id: string) => {
// default to self if not provided
if (!id) id = room.self!.id;
if (!id) id = room.self.id;

Check failure on line 95 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 95 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
return this.responses[id];
};
},
Expand All @@ -117,7 +117,7 @@ export const useGameStore = defineStore('game', {
},
canEndRound() {
const room = useRoomStore();
const self = room.self!.id;
const self = room.self.id;

Check failure on line 120 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 120 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
if (this.selector?.id !== self) return false;

let finishedMatching = true;
Expand Down Expand Up @@ -145,7 +145,7 @@ export const useGameStore = defineStore('game', {
},
resetResponses() {
const room = useRoomStore();
const selfId = room.self!.id;
const selfId = room.self.id;

Check failure on line 148 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 148 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
this.responses = {};
this.responses[selfId] = {
id: selfId,
Expand All @@ -157,20 +157,20 @@ export const useGameStore = defineStore('game', {
},
useResponse(response: string) {
const room = useRoomStore();
this.responses[room.self!.id].used.push(response);
this.responses[room.self.id].used.push(response);

Check failure on line 160 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 160 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
},
useSelectorResponse(response: string) {
const room = useRoomStore();
this.responses[room.self!.id].used.push(response);
this.responses[room.self.id].used.push(response);

Check failure on line 164 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 164 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
if (this.selectionType === 'strike') {
this.responses[room.self!.id].selectedStrike = response;
this.responses[room.self.id].selectedStrike = response;

Check failure on line 166 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 166 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
} else {
this.responses[room.self!.id].selectedSike = response;
this.responses[room.self.id].selectedSike = response;

Check failure on line 168 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 168 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
}
},
unuseResponse(response: string) {
const room = useRoomStore();
this.responses[room.self!.id].used = this.responses[room.self!.id].used.filter((r) => r !== response);
this.responses[room.self.id].used = this.responses[room.self.id].used.filter((r) => r !== response);

Check failure on line 173 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 173 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'room.self' is possibly 'undefined'.

Check failure on line 173 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.

Check failure on line 173 in client/src/stores/game.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'room.self' is possibly 'undefined'.
},
async startTimer() {
if (this.timeoutId) {
Expand Down Expand Up @@ -205,15 +205,15 @@ export const useGameStore = defineStore('game', {
exact: match.exact
});
}
if (match.player === room.self!.id) {
if (match.player === room.self.id) {
this.useResponse(match.response);
this.scene = 'MatchingSummary';
}
}
},
unmatch() {
const room = useRoomStore();
const selfId = room.self!.id;
const selfId = room.self.id;
const usedResponse = this.matches.find((match: Match) => match.player.id === selfId)!.response;
this.unuseResponse(usedResponse);
this.unmatched = true;
Expand Down Expand Up @@ -264,15 +264,15 @@ export const useGameStore = defineStore('game', {

socket.on('promptResponse', (response: string) => {
const room = useRoomStore();
this.responses[room.self!.id].all.push(response);
this.responses[room.self.id].all.push(response);
});

socket.on('nextSelection', (data: { selector: string; selectionType: string }) => {
const room = useRoomStore();
const selector = room.players.find((player: Player) => player.id === data.selector);
// before we clear matches, make sure we used our match, this can happen if a next selection happens between
// unmatch and match
const selfId = room.self!.id;
const selfId = room.self.id;
const selfMatch = this.matches.find((match: Match) => match.player.id === selfId);
if (selfMatch && !this.responses[selfId].used.includes(selfMatch.response))
this.useResponse(selfMatch.response);
Expand Down Expand Up @@ -337,7 +337,7 @@ export const useGameStore = defineStore('game', {
if (data.timer) {
void this.startTimer();
}
const isSelector = this.selector?.id === room.self!.id;
const isSelector = this.selector?.id === room.self.id;
let scene: Scene = 'Lobby';
//'lobby', 'response', 'selection', 'matching'
switch (data.stage) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/styles/_min-bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@import '~bootstrap/scss/list-group';
//@import "~bootstrap/scss/close";
//@import "~bootstrap/scss/toasts";
@import "~bootstrap/scss/modal";
@import '~bootstrap/scss/modal';
@import '~bootstrap/scss/tooltip';
//@import "~bootstrap/scss/popover";
//@import "~bootstrap/scss/carousel";
Expand Down
2 changes: 2 additions & 0 deletions common/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { z } from 'zod';
// good for hiding beta features, can be moved to exposed options schema if we want clients to be able to control it
type ConfigFlags = {
maxPlayers: number;
recPlayers: number;
minPlayers: number;
promptSkipping: boolean;
};
Expand Down Expand Up @@ -65,6 +66,7 @@ export const defaultOptions: Options = {
sikeRetries: 0,
promptSkipping: true,
minPlayers: 3,
recPlayers: 5,
maxPlayers: 12,
packs: {},
customPrompts: []
Expand Down

0 comments on commit b766022

Please sign in to comment.