import { computed, reactive, ref } from 'vue' import { getEmptyOperation, isOperationReady } from '../algo' import { GameState } from '../globals' import { Operation, Plaquette } from '../types' export const gameState = ref(GameState.Undefined) export const operations = reactive([getEmptyOperation()]) export const plaquettes = ref([]) export const result = ref(0) export const currentOperation = computed( () => operations[operations.length - 1], ) export const gameIsRunning = computed(() => gameState.value > GameState.Loading) export const isEndGame = computed( () => (operations.length === 5 && isOperationReady(currentOperation.value)) || isResultPerfect.value, ) export const isResultPerfect = computed( () => !!operations.some(o => o.result?.value === result.value), )