diff --git a/src/components/gameMaster/zoneEditor/ZoneEditor.vue b/src/components/gameMaster/zoneEditor/ZoneEditor.vue index a8c3b07..dc9ee28 100644 --- a/src/components/gameMaster/zoneEditor/ZoneEditor.vue +++ b/src/components/gameMaster/zoneEditor/ZoneEditor.vue @@ -48,6 +48,7 @@ function save() { height: zoneEditorStore.zoneSettings.height, tiles: zoneEditorStore.zone.tiles, pvp: zoneEditorStore.zone.pvp, + zoneEffects: zoneEditorStore.zone.zoneEffects.map(({ id, zoneId, effect, strength }) => ({ id, zoneId, effect, strength })), zoneEventTiles: zoneEditorStore.zone.zoneEventTiles.map(({ id, zoneId, type, positionX, positionY, teleport }) => ({ id, zoneId, type, positionX, positionY, teleport })), zoneObjects: zoneEditorStore.zone.zoneObjects.map(({ id, zoneId, objectId, depth, isRotated, positionX, positionY }) => ({ id, zoneId, objectId, depth, isRotated, positionX, positionY })) } diff --git a/src/components/gameMaster/zoneEditor/partials/ZoneSettings.vue b/src/components/gameMaster/zoneEditor/partials/ZoneSettings.vue index f6f305a..c8daed8 100644 --- a/src/components/gameMaster/zoneEditor/partials/ZoneSettings.vue +++ b/src/components/gameMaster/zoneEditor/partials/ZoneSettings.vue @@ -6,19 +6,23 @@ @@ -40,16 +52,19 @@ import Modal from '@/components/utilities/Modal.vue' import { useZoneEditorStore } from '@/stores/zoneEditorStore' const zoneEditorStore = useZoneEditorStore() +const screen = ref('settings') zoneEditorStore.setZoneName(zoneEditorStore.zone?.name) zoneEditorStore.setZoneWidth(zoneEditorStore.zone?.width) zoneEditorStore.setZoneHeight(zoneEditorStore.zone?.height) zoneEditorStore.setZonePvp(zoneEditorStore.zone?.pvp) +zoneEditorStore.setZoneEffects(zoneEditorStore.zone?.zoneEffects) const name = ref(zoneEditorStore.zoneSettings?.name) const width = ref(zoneEditorStore.zoneSettings?.width) const height = ref(zoneEditorStore.zoneSettings?.height) const pvp = ref(zoneEditorStore.zoneSettings?.pvp) +const zoneEffects = ref(zoneEditorStore.zoneSettings?.zoneEffects || []) watch(name, (value) => { zoneEditorStore.setZoneName(value) @@ -66,4 +81,22 @@ watch(height, (value) => { watch(pvp, (value) => { zoneEditorStore.setZonePvp(value) }) - + +watch(zoneEffects, (value) => { + zoneEditorStore.setZoneEffects(value) +}, { deep: true }) + +const addEffect = () => { + zoneEffects.value.push({ + id: Date.now().toString(), // Simple unique id generation + zoneId: zoneEditorStore.zone?.id, + zone: zoneEditorStore.zone, + effect: '', + strength: 1 + }) +} + +const removeEffect = (index) => { + zoneEffects.value.splice(index, 1) +} + \ No newline at end of file diff --git a/src/stores/zoneEditorStore.ts b/src/stores/zoneEditorStore.ts index 4276f90..0981b16 100644 --- a/src/stores/zoneEditorStore.ts +++ b/src/stores/zoneEditorStore.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia' import { useGameStore } from '@/stores/gameStore' -import type { Zone, Object, Tile, ZoneObject, ZoneEffects } from '@/types' +import type { Zone, Object, Tile, ZoneEffect } from '@/types' export type TeleportSettings = { toZoneId: number @@ -33,7 +33,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', { width: 0, height: 0, pvp: false, - effects: [] as ZoneEffects[] + zoneEffects: [] as ZoneEffect[] }, teleportSettings: { toZoneId: 0, @@ -66,9 +66,9 @@ export const useZoneEditorStore = defineStore('zoneEditor', { if (!this.zone) return this.zone.pvp = pvp }, - setZoneEffects(zoneEffects: ZoneEffects) { + setZoneEffects(zoneEffects: ZoneEffect[]) { if (!this.zone) return - this.zone.zoneEffects = zoneEffects + this.zoneSettings.zoneEffects = zoneEffects }, setTool(tool: string) { this.tool = tool diff --git a/src/types.ts b/src/types.ts index 0c73dcb..0a7d20e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -53,7 +53,7 @@ export type Zone = { height: number tiles: any | null pvp: boolean - zoneEffects: ZoneEffects + zoneEffects: ZoneEffect[] zoneEventTiles: ZoneEventTile[] zoneObjects: ZoneObject[] characters: Character[] @@ -62,7 +62,7 @@ export type Zone = { updatedAt: Date } -export type ZoneEffects = { +export type ZoneEffect = { id: string zoneId: number zone: Zone