Skip to content

Commit

Permalink
Auto-select all players with the same record if one player is selecte…
Browse files Browse the repository at this point in the history
…d inside CreatePlayOffModal
  • Loading branch information
phrasmotica committed Apr 27, 2024
1 parent 1adcc84 commit c6bd0c3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/components/modals/CreatePlayOffModal.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { computed, ref } from "vue"
import { computed, ref, watch } from "vue"
import { useI18n } from "vue-i18n"
import ConfirmModal from "./ConfirmModal.vue"
import PlayerSelector from "../results/PlayerSelector.vue"
import Stepper from "../setup/Stepper.vue"
import ConfirmModal from "./ConfirmModal.vue"
import { useArray } from "@/composables/useArray"
import { useFlyer } from "@/composables/useFlyer"
Expand Down Expand Up @@ -41,6 +41,22 @@ const {
const raceTo = ref(1)
watch(playerIds, () => {
if (playerIds.value.length === 1) {
// select all the other players with the same record
const theirRecord = overallStandings.value.find(s => s.playerId === playerIds.value[0])!
const otherPlayers = overallStandings.value.filter(s => {
// MEDIUM: move this logic into composable, deduplicate in PlayerSelector.vue
return s.wins === theirRecord.wins
&& s.draws === theirRecord.draws
&& s.losses === theirRecord.losses
}).map(s => s.playerId)
playerIds.value = [...playerIds.value, ...otherPlayers]
}
})
const selectedRecords = computed(() => overallStandings.value.filter(s => {
return playerIds.value.includes(s.playerId)
}))
Expand Down

0 comments on commit c6bd0c3

Please sign in to comment.