28 lines
684 B
TypeScript
28 lines
684 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref, shallowRef } from 'vue'
|
|
import type { SceneNode, Choice } from '@engine/types'
|
|
|
|
export const useGameStore = defineStore('game', () => {
|
|
const currentScene = shallowRef<SceneNode | null>(null)
|
|
const choices = ref<Choice[]>([])
|
|
const gameEnded = ref(false)
|
|
|
|
function setScene(scene: SceneNode) {
|
|
currentScene.value = scene
|
|
}
|
|
|
|
function setChoices(list: Choice[]) {
|
|
choices.value = list
|
|
}
|
|
|
|
function clearChoices() {
|
|
choices.value = []
|
|
}
|
|
|
|
function setGameEnded(val: boolean) {
|
|
gameEnded.value = val
|
|
}
|
|
|
|
return { currentScene, choices, gameEnded, setScene, setChoices, clearChoices, setGameEnded }
|
|
})
|