diff options
Diffstat (limited to 'stores')
| -rw-r--r-- | stores/export.ts | 6 | ||||
| -rw-r--r-- | stores/loader.ts | 8 | ||||
| -rw-r--r-- | stores/session.ts | 83 |
3 files changed, 50 insertions, 47 deletions
diff --git a/stores/export.ts b/stores/export.ts index 3f48aa3..f0ff260 100644 --- a/stores/export.ts +++ b/stores/export.ts @@ -1,4 +1,4 @@ -import { defineStore } from 'pinia' +import { defineStore } from 'pinia'; export type ZipLoaderStatus = 'inactive' | 'preparing' | 'compressing' | 'ready' | 'failed'; @@ -7,7 +7,7 @@ export const useExportStore = defineStore('export', { zip: { status: 'inactive' as ZipLoaderStatus, contents: null as Blob | null, - } + }, }), getters: { getZipStatus: (state) => () => { @@ -27,5 +27,5 @@ export const useExportStore = defineStore('export', { setZipContents(contents: Blob) { this.zip.contents = contents; }, - } + }, }); diff --git a/stores/loader.ts b/stores/loader.ts index fe3742c..9d4b7ad 100644 --- a/stores/loader.ts +++ b/stores/loader.ts @@ -1,4 +1,4 @@ -import { defineStore } from 'pinia' +import { defineStore } from 'pinia'; import type { EditorCategory, EditorItem } from './session'; export type FileSystemLoaderStatus = 'inactive' | 'pending' | 'loaded' | 'invalid' | 'valid'; @@ -11,7 +11,7 @@ export const useLoaderStore = defineStore('loader', { quests: [] as EditorQuest[], categories: [] as EditorCategory[], items: [] as EditorItem[], - } + }, }), getters: { getFileSystemLoaderStatus: (state) => () => { @@ -50,6 +50,6 @@ export const useLoaderStore = defineStore('loader', { }, setItems(items: EditorItem[]) { this.fileSystem.items = items; - } - } + }, + }, }); diff --git a/stores/session.ts b/stores/session.ts index 50bcde7..c593b78 100644 --- a/stores/session.ts +++ b/stores/session.ts @@ -1,4 +1,4 @@ -import { defineStore } from 'pinia' +import { defineStore } from 'pinia'; export interface EditorQuest { id: string; @@ -7,9 +7,9 @@ export interface EditorQuest { lore: { normal: string[]; started: string[]; - } + }; type: string; - } + }; tasks: { [key: string]: EditorTask }; rewards: string[]; startCommands?: string[]; @@ -26,18 +26,18 @@ export interface EditorQuest { cooldown: { enabled: boolean; time: number; - } + }; timeLimit: { enabled: boolean; time: number; - } + }; sortOrder: number; autostart: boolean; completedDisplay?: string; cooldownDisplay?: string; permissionDisplay?: string; lockedDisplay?: string; - } + }; } export interface EditorTask { @@ -45,7 +45,7 @@ export interface EditorTask { config: { type: string; [key: string]: any; - } + }; } export interface EditorCategory { @@ -54,14 +54,14 @@ export interface EditorCategory { name: string; lore: string[]; type: string; - } + }; permissionRequired: string; } export interface EditorItem { id: string; type: string; - config: any + config: any; } export interface TaskDefinition { @@ -69,7 +69,7 @@ export interface TaskDefinition { icon: { style: string; name: string; - } + }; configuration: { [key: string]: { type: string | string[]; @@ -77,8 +77,8 @@ export interface TaskDefinition { default?: any; required?: boolean; note?: string; - } - } + }; + }; } export interface QuestItemDefinition { @@ -89,8 +89,8 @@ export interface QuestItemDefinition { [key: string]: { type: string | string[]; description: string; - } - } + }; + }; } export type SessionType = 'none' | 'filesystem' | 'demo'; @@ -104,69 +104,72 @@ export const useSessionStore = defineStore('session', { items: [] as EditorItem[], taskDefinitions: {} as { [key: string]: TaskDefinition }, taskTypeAliases: {} as { [key: string]: string }, - questItemDefinitions: {} as { [key: string]: QuestItemDefinition } - } + questItemDefinitions: {} as { [key: string]: QuestItemDefinition }, + }, }), getters: { getSessionType: (state) => () => { - return state.sessionType + return state.sessionType; }, getQuests: (state) => () => { - return state.session.quests + return state.session.quests; }, getCategories: (state) => () => { - return state.session.categories + return state.session.categories; }, getItems: (state) => () => { - return state.session.items + return state.session.items; }, getQuestById: (state) => (id: string) => { if (!id) return null; - return state.session.quests.find(quest => quest.id === id) + return state.session.quests.find((quest) => quest.id === id); }, getCategoryById: (state) => (id: string) => { if (!id) return null; - return state.session.categories.find(quest => quest.id === id) + return state.session.categories.find((quest) => quest.id === id); }, getItemById: (state) => (id: string) => { if (!id) return null; - return state.session.items.find(item => item.id === id); + return state.session.items.find((item) => item.id === id); }, getQuestsInCategory: (state) => (id: string) => { if (!id) return []; - return state.session.quests.filter(quest => quest.options.category === id) + return state.session.quests.filter((quest) => quest.options.category === id); }, getTaskDefinitions: (state) => { - return state.session.taskDefinitions + return state.session.taskDefinitions; }, getTaskDefinitionByTaskType: (state) => (type: string) => { - return state.session.taskDefinitions[type] || state.session.taskDefinitions[state.session.taskTypeAliases[type]] + return ( + state.session.taskDefinitions[type] || + state.session.taskDefinitions[state.session.taskTypeAliases[type]] + ); }, getKnownTaskTypes: (state) => () => { - return Object.keys(state.session.taskDefinitions) + return Object.keys(state.session.taskDefinitions); }, getQuestItemDefintions: (state) => { - return state.session.questItemDefinitions + return state.session.questItemDefinitions; }, getQuestItemDefinitionByTaskType: (state) => (type: string) => { - return state.session.questItemDefinitions[type] + return state.session.questItemDefinitions[type]; }, getKnownQuestItemTypes: (state) => () => { - return Object.keys(state.session.questItemDefinitions) - } + return Object.keys(state.session.questItemDefinitions); + }, }, actions: { setSessionType(type: SessionType) { - this.sessionType = type + this.sessionType = type; }, setQuests(quests: EditorQuest[]) { - this.session.quests = quests + this.session.quests = quests; }, setCategories(categories: EditorCategory[]) { - this.session.categories = categories + this.session.categories = categories; }, setItems(items: EditorItem[]) { - this.session.items = items + this.session.items = items; }, setTaskDefinitions(definitions: { [key: string]: TaskDefinition }) { this.session.taskDefinitions = definitions; @@ -181,12 +184,12 @@ export const useSessionStore = defineStore('session', { const quest = this.getQuestById(oldId); if (!quest) return; - quest.id = newId + quest.id = newId; }, deleteQuest(id: string) { - const index = this.session.quests.findIndex(quest => quest.id === id) + const index = this.session.quests.findIndex((quest) => quest.id === id); if (index === -1) return; - this.session.quests.splice(index, 1) + this.session.quests.splice(index, 1); }, duplicateQuest(id: string, newQuestId: string) { const quest = this.getQuestById(id); @@ -195,6 +198,6 @@ export const useSessionStore = defineStore('session', { const newQuest = JSON.parse(JSON.stringify(quest)); newQuest.id = newQuestId; this.session.quests.push(newQuest); - } - } + }, + }, }); |
