Skip to content

Commit

Permalink
Fix mass refactor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jengu288 committed Mar 12, 2024
1 parent 90a90bf commit cc180c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
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
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;
},
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;
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;
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;
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);
},
useSelectorResponse(response: string) {
const room = useRoomStore();
this.responses[room.self.id].used.push(response);
this.responses[room.self!.id].used.push(response);
if (this.selectionType === 'strike') {
this.responses[room.self.id].selectedStrike = response;
this.responses[room.self!.id].selectedStrike = response;
} else {
this.responses[room.self.id].selectedSike = response;
this.responses[room.self!.id].selectedSike = response;
}
},
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);
},
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

0 comments on commit cc180c9

Please sign in to comment.