Skip to content

Commit

Permalink
Don't allow auto-starting/auto-completing in debug mode if the next f…
Browse files Browse the repository at this point in the history
…ixture cannot progress
  • Loading branch information
phrasmotica committed Apr 27, 2024
1 parent 4270699 commit 3c9a0f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions src/components/play/DebugButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { useFlyer } from "@/composables/useFlyer"
import { usePhase } from "@/composables/usePhase"
import { usePhaseEvents } from "@/composables/usePhaseEvents"
import { usePhaseSpecification } from "@/composables/useSpecification"
import { useStandings } from "@/composables/useStandings"
import { useTables } from "@/composables/useTables"
import { FixtureStatus } from "@/data/FixtureStatus"
import { useFlyerStore } from "@/stores/flyer"
import { useUiStore } from "@/stores/ui"
import { useStandings } from "@/composables/useStandings"
const props = defineProps<{
hideInstead?: boolean
Expand All @@ -28,6 +30,7 @@ const phaseEvents = usePhaseEvents(currentPhase.value)
const {
phase,
freeTables,
getFixtureStatus,
} = usePhase(currentPhase.value)
const {
Expand Down Expand Up @@ -58,8 +61,18 @@ const showAutoCompleteButton = computed(() => {
return remainingCount.value > 0 || !props.hideInstead
})
const canProgress = computed(() => {
const validStatuses = [
FixtureStatus.WaitingForAssignment,
FixtureStatus.WaitingForBreaker,
FixtureStatus.ReadyToStart,
]
return validStatuses.includes(getFixtureStatus(nextFixture.value))
})
const autoStart = () => {
if (!currentPhase.value || !nextFixture.value || freeTables.value.length <= 0) {
if (!currentPhase.value || !nextFixture.value || !canProgress.value) {
return
}
Expand All @@ -74,7 +87,7 @@ const autoStart = () => {
}
const autoComplete = () => {
if (!currentPhase.value || !nextFixture.value) {
if (!currentPhase.value || !nextFixture.value || !canProgress.value) {
return
}
Expand Down Expand Up @@ -120,23 +133,23 @@ const autoCompleteRemaining = () => {
class="mb-2"
label="Auto-start"
severity="help"
:disabled="!isFixtures || remainingCount <= 0"
:disabled="!isFixtures || !canProgress || remainingCount <= 0"
@click="autoStart" />

<Button
v-if="showAutoCompleteButton"
class="mb-2"
label="Auto-complete"
severity="help"
:disabled="!isFixtures || remainingCount <= 0"
:disabled="!isFixtures || !canProgress || remainingCount <= 0"
@click="autoComplete" />

<Button
v-if="showAutoCompleteButton"
class="mb-2"
label="Auto-complete remaining"
severity="help"
:disabled="!isFixtures || remainingCount <= 0"
:disabled="!isFixtures || !canProgress || remainingCount <= 0"
@click="autoCompleteRemaining" />
</div>
</template>
2 changes: 1 addition & 1 deletion src/composables/useFixtureList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useFixtureList = (p: Phase | null) => {
const isComplete = computed(() => fixtures.value.every(x => x.startTime && x.finishTime))
const remainingCount = computed(() => fixtures.value.filter(f => !f.finishTime && !f.cancelledTime).length)

const nextFixture = computed(() => fixtures.value.find(f => !f.tableId))
const nextFixture = computed(() => fixtures.value.find(f => !f.tableId && !f.finishTime))

const getFixtures = (playerId: string) => {
return fixtures.value.filter(f => f.scores.some(s => s.playerId === playerId))
Expand Down

0 comments on commit 3c9a0f9

Please sign in to comment.