Skip to content

Commit

Permalink
Fix bug where fixtures were being auto-completed incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
phrasmotica committed Apr 27, 2024
1 parent 3c9a0f9 commit d7adcf7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
20 changes: 17 additions & 3 deletions src/components/play/DebugButtons.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed } from "vue"
import { computed, watch } from "vue"
import { useFixtureList } from "@/composables/useFixtureList"
import { useFlyer } from "@/composables/useFlyer"
Expand All @@ -11,6 +11,8 @@ import { useTables } from "@/composables/useTables"
import { FixtureStatus } from "@/data/FixtureStatus"
import { useFixture } from "@/composables/useFixture"
import { useRounds } from "@/composables/useRounds"
import { useFlyerStore } from "@/stores/flyer"
import { useUiStore } from "@/stores/ui"
Expand All @@ -28,18 +30,25 @@ const {
const phaseEvents = usePhaseEvents(currentPhase.value)
const {
phase,
freeTables,
getFixtureStatus,
} = usePhase(currentPhase.value)
const {
getRound,
} = useRounds(currentPhase.value)
const {
remainingCount,
nextFixture,
} = useFixtureList(phase.value)
} = useFixtureList(currentPhase.value)
const {
round,
raceTo,
} = useFixture("debug", nextFixture.value, getRound(nextFixture.value?.id || ""), currentPhase.value)
const {
fixturesCanBeDrawn,
} = usePhaseSpecification(currentPhase.value)
Expand All @@ -51,6 +60,10 @@ const {
tables,
} = useTables(currentPhase.value)
watch(nextFixture, () => {
round.value = getRound(nextFixture.value?.id || "")
})
const isFixtures = computed(() => uiStore.isFixtures)
const showAutoStartButton = computed(() => {
Expand Down Expand Up @@ -111,6 +124,7 @@ const autoCompleteRemaining = () => {
return
}
// BUG: this could be different for each fixture
const fixtureRaceTo = raceTo.value || 1
flyerStore.autoCompletePhase(
Expand Down
11 changes: 8 additions & 3 deletions src/composables/useFixture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ref, computed, watch } from "vue"
import { useArrayUnique } from "@vueuse/core"
import { differenceInMilliseconds } from "date-fns"
import { computed, ref, watch } from "vue"

import { useArray } from "./useArray"
import { useClock } from "./useClock"
Expand All @@ -16,6 +16,7 @@ import type { Round } from "@/data/Round"
// where the argument can currently be undefined (see FixtureModal.vue)
export const useFixture = (name: string, f: Fixture | undefined, r: Round | undefined, p: Phase | null) => {
const fixture = ref(f)
const round = ref(r)

const {
clockable,
Expand All @@ -25,9 +26,13 @@ export const useFixture = (name: string, f: Fixture | undefined, r: Round | unde
} = useClock("FixtureClock " + name, fixture.value || null)

const {
round,
round: roundInternal,
raceTo,
} = useRound(r, p)
} = useRound(round.value, p)

watch(round, () => {
roundInternal.value = round.value
})

const {
settings,
Expand Down

0 comments on commit d7adcf7

Please sign in to comment.