diff --git a/src/stores/gameStore.ts b/src/stores/gameStore.ts index f39552d..db53fa5 100644 --- a/src/stores/gameStore.ts +++ b/src/stores/gameStore.ts @@ -5,23 +5,25 @@ import config from '@/config' import { useCookies } from '@vueuse/integrations/useCookies' export const useGameStore = defineStore('game', { - state: () => ({ - notifications: [] as Notification[], - assets: [] as Asset[], - token: '' as string | null, - connection: null as Socket | null, - user: null as User | null, - character: null as Character | null, - isPlayerDraggingCamera: false, - gameSettings: { - isCameraFollowingCharacter: false - }, - uiSettings: { - isChatOpen: false, - isUserPanelOpen: false, - isGmPanelOpen: false + state: () => { + return { + notifications: [] as Notification[], + assets: [] as Asset[], + token: '' as string | null, + connection: null as Socket | null, + user: null as User | null, + character: null as Character | null, + isPlayerDraggingCamera: false, + gameSettings: { + isCameraFollowingCharacter: false + }, + uiSettings: { + isChatOpen: false, + isUserPanelOpen: false, + isGmPanelOpen: false + } } - }), + }, getters: { getNotifications: (state: any) => state.notifications, getAssetByKey: (state) => { diff --git a/src/stores/zoneEditorStore.ts b/src/stores/zoneEditorStore.ts index bd4bd63..a97ae2a 100644 --- a/src/stores/zoneEditorStore.ts +++ b/src/stores/zoneEditorStore.ts @@ -10,37 +10,39 @@ type TeleportSettings = { } export const useZoneEditorStore = defineStore('zoneEditor', { - state: () => ({ - active: false, - zone: null as Zone | null, - tool: 'move', - drawMode: 'tile', - eraserMode: 'tile', - zoneList: [] as Zone[], - tileList: [] as Tile[], - objectList: [] as Object[], - selectedTile: null as Tile | null, - selectedObject: null as Object | null, - selectedZoneObject: null as ZoneObject | null, - objectDepth: 0, - isTileListModalShown: false, - isObjectListModalShown: false, - isZoneListModalShown: false, - isCreateZoneModalShown: false, - isSettingsModalShown: false, - zoneSettings: { - name: '', - width: 0, - height: 0, - pvp: false - }, - teleportSettings: { - toZoneId: 0, - toPositionX: 0, - toPositionY: 0, - toRotation: 0 + state: () => { + return { + active: false, + zone: null as Zone | null, + tool: 'move', + drawMode: 'tile', + eraserMode: 'tile', + zoneList: [] as Zone[], + tileList: [] as Tile[], + objectList: [] as Object[], + selectedTile: null as Tile | null, + selectedObject: null as Object | null, + selectedZoneObject: null as ZoneObject | null, + objectDepth: 0, + isTileListModalShown: false, + isObjectListModalShown: false, + isZoneListModalShown: false, + isCreateZoneModalShown: false, + isSettingsModalShown: false, + zoneSettings: { + name: '', + width: 0, + height: 0, + pvp: false + }, + teleportSettings: { + toZoneId: 0, + toPositionX: 0, + toPositionY: 0, + toRotation: 0 + } } - }), + }, actions: { toggleActive() { const gameStore = useGameStore() diff --git a/src/stores/zoneStore.ts b/src/stores/zoneStore.ts index c54f38f..a1a8c01 100644 --- a/src/stores/zoneStore.ts +++ b/src/stores/zoneStore.ts @@ -2,11 +2,13 @@ import { defineStore } from 'pinia' import type { ExtendedCharacter, Zone } from '@/types' export const useZoneStore = defineStore('zone', { - state: () => ({ - zone: null as Zone | null, - characters: [] as ExtendedCharacter[], - characterLoaded: false - }), + state: () => { + return { + zone: null as Zone | null, + characters: [] as ExtendedCharacter[], + characterLoaded: false + } + }, getters: { getCharacterById: (state) => { return (id: number) => state.characters.find((char) => char.id === id)