Loading world works

This commit is contained in:
2024-07-12 12:44:37 +02:00
parent 79bef033f3
commit 0fcd5c4d76
20 changed files with 228 additions and 177 deletions

View File

@ -25,13 +25,13 @@ export const useAssetStore = defineStore('assets', {
return fetch(config.server_endpoint + '/assets')
.then((response) => response.json())
.then((assets) => {
this.setAssets(assets);
return true;
this.setAssets(assets)
return true
})
.catch((error) => {
console.error('Error fetching assets:', error);
return false;
});
console.error('Error fetching assets:', error)
return false
})
}
}
})

View File

@ -1,14 +1,14 @@
import { defineStore } from 'pinia'
import type { Character } from '@/types'
import type { Character, Zone } from '@/types'
export const useZoneStore = defineStore('zone', {
state: () => ({
tiles: [] as number[][],
zone: null as Zone | null,
characters: [] as Character[]
}),
actions: {
setTiles(tiles: number[][]) {
this.tiles = tiles
setZone(zone: Zone | null) {
this.zone = zone
},
setCharacters(characters: Character[]) {
this.characters = characters
@ -25,7 +25,7 @@ export const useZoneStore = defineStore('zone', {
this.characters = this.characters.filter((c: Character) => c.id !== character.id)
},
reset() {
this.tiles = []
this.zone = null
this.characters = []
}
}

View File

@ -3,7 +3,7 @@ import type { Zone, Object, Tile } from '@/types'
export const useZoneEditorStore = defineStore('zoneEditor', {
state: () => ({
active: true,
active: false,
zone: null as Zone | null,
tool: 'move',
drawMode: 'tile',
@ -87,4 +87,4 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
this.isCreateZoneModalShown = false
}
}
})
})