#137 : Added logic to set effects per zone in zone editor
This commit is contained in:
parent
3c9b92ccbd
commit
5d288772b5
@ -48,6 +48,7 @@ function save() {
|
|||||||
height: zoneEditorStore.zoneSettings.height,
|
height: zoneEditorStore.zoneSettings.height,
|
||||||
tiles: zoneEditorStore.zone.tiles,
|
tiles: zoneEditorStore.zone.tiles,
|
||||||
pvp: zoneEditorStore.zone.pvp,
|
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 })),
|
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 }))
|
zoneObjects: zoneEditorStore.zone.zoneObjects.map(({ id, zoneId, objectId, depth, isRotated, positionX, positionY }) => ({ id, zoneId, objectId, depth, isRotated, positionX, positionY }))
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,23 @@
|
|||||||
|
|
||||||
<template #modalBody>
|
<template #modalBody>
|
||||||
<div class="m-4">
|
<div class="m-4">
|
||||||
<form method="post" @submit.prevent="" class="inline">
|
<div class="space-x-2">
|
||||||
<div class="gap-2.5 flex flex-wrap">
|
<button class="btn-cyan py-1.5 px-4" type="button" @click.prevent="screen = 'settings'">Settings</button>
|
||||||
|
<button class="btn-cyan py-1.5 px-4" type="button" @click.prevent="screen = 'effects'">Effects</button>
|
||||||
|
</div>
|
||||||
|
<form method="post" @submit.prevent="" class="inline" v-if="screen === 'settings'">
|
||||||
|
<div class="gap-2.5 flex flex-wrap mt-4">
|
||||||
<div class="form-field-full">
|
<div class="form-field-full">
|
||||||
<label for="name">Name</label>
|
<label for="name">Name</label>
|
||||||
<input class="input-field" v-model="name" name="name" id="name" />
|
<input class="input-field" v-model="name" name="name" id="name" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-field-half">
|
<div class="form-field-half">
|
||||||
<label for="name">Width</label>
|
<label for="width">Width</label>
|
||||||
<input class="input-field" v-model="width" name="name" id="name" type="number" />
|
<input class="input-field" v-model="width" name="width" id="width" type="number" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-field-half">
|
<div class="form-field-half">
|
||||||
<label for="name">Height</label>
|
<label for="height">Height</label>
|
||||||
<input class="input-field" v-model="height" name="name" id="name" type="number" />
|
<input class="input-field" v-model="height" name="height" id="height" type="number" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-field-full">
|
<div class="form-field-full">
|
||||||
<label for="pvp">PVP enabled</label>
|
<label for="pvp">PVP enabled</label>
|
||||||
@ -29,6 +33,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<form method="post" @submit.prevent="" class="inline" v-if="screen === 'effects'">
|
||||||
|
<div v-for="(effect, index) in zoneEffects" :key="effect.id" class="mb-2 flex items-center space-x-2 mt-4">
|
||||||
|
<input class="input-field flex-grow" v-model="effect.effect" placeholder="Effect name" />
|
||||||
|
<input class="input-field w-20" v-model.number="effect.strength" type="number" placeholder="Strength" />
|
||||||
|
<button class="btn-red py-1 px-2" type="button" @click="removeEffect(index)">Delete</button>
|
||||||
|
</div>
|
||||||
|
<button class="btn-green py-1 px-2 mt-2" type="button" @click="addEffect">Add Effect</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Modal>
|
</Modal>
|
||||||
@ -40,16 +52,19 @@ import Modal from '@/components/utilities/Modal.vue'
|
|||||||
import { useZoneEditorStore } from '@/stores/zoneEditorStore'
|
import { useZoneEditorStore } from '@/stores/zoneEditorStore'
|
||||||
|
|
||||||
const zoneEditorStore = useZoneEditorStore()
|
const zoneEditorStore = useZoneEditorStore()
|
||||||
|
const screen = ref('settings')
|
||||||
|
|
||||||
zoneEditorStore.setZoneName(zoneEditorStore.zone?.name)
|
zoneEditorStore.setZoneName(zoneEditorStore.zone?.name)
|
||||||
zoneEditorStore.setZoneWidth(zoneEditorStore.zone?.width)
|
zoneEditorStore.setZoneWidth(zoneEditorStore.zone?.width)
|
||||||
zoneEditorStore.setZoneHeight(zoneEditorStore.zone?.height)
|
zoneEditorStore.setZoneHeight(zoneEditorStore.zone?.height)
|
||||||
zoneEditorStore.setZonePvp(zoneEditorStore.zone?.pvp)
|
zoneEditorStore.setZonePvp(zoneEditorStore.zone?.pvp)
|
||||||
|
zoneEditorStore.setZoneEffects(zoneEditorStore.zone?.zoneEffects)
|
||||||
|
|
||||||
const name = ref(zoneEditorStore.zoneSettings?.name)
|
const name = ref(zoneEditorStore.zoneSettings?.name)
|
||||||
const width = ref(zoneEditorStore.zoneSettings?.width)
|
const width = ref(zoneEditorStore.zoneSettings?.width)
|
||||||
const height = ref(zoneEditorStore.zoneSettings?.height)
|
const height = ref(zoneEditorStore.zoneSettings?.height)
|
||||||
const pvp = ref(zoneEditorStore.zoneSettings?.pvp)
|
const pvp = ref(zoneEditorStore.zoneSettings?.pvp)
|
||||||
|
const zoneEffects = ref(zoneEditorStore.zoneSettings?.zoneEffects || [])
|
||||||
|
|
||||||
watch(name, (value) => {
|
watch(name, (value) => {
|
||||||
zoneEditorStore.setZoneName(value)
|
zoneEditorStore.setZoneName(value)
|
||||||
@ -66,4 +81,22 @@ watch(height, (value) => {
|
|||||||
watch(pvp, (value) => {
|
watch(pvp, (value) => {
|
||||||
zoneEditorStore.setZonePvp(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)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
@ -1,6 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
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 = {
|
export type TeleportSettings = {
|
||||||
toZoneId: number
|
toZoneId: number
|
||||||
@ -33,7 +33,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
pvp: false,
|
pvp: false,
|
||||||
effects: [] as ZoneEffects[]
|
zoneEffects: [] as ZoneEffect[]
|
||||||
},
|
},
|
||||||
teleportSettings: {
|
teleportSettings: {
|
||||||
toZoneId: 0,
|
toZoneId: 0,
|
||||||
@ -66,9 +66,9 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
if (!this.zone) return
|
if (!this.zone) return
|
||||||
this.zone.pvp = pvp
|
this.zone.pvp = pvp
|
||||||
},
|
},
|
||||||
setZoneEffects(zoneEffects: ZoneEffects) {
|
setZoneEffects(zoneEffects: ZoneEffect[]) {
|
||||||
if (!this.zone) return
|
if (!this.zone) return
|
||||||
this.zone.zoneEffects = zoneEffects
|
this.zoneSettings.zoneEffects = zoneEffects
|
||||||
},
|
},
|
||||||
setTool(tool: string) {
|
setTool(tool: string) {
|
||||||
this.tool = tool
|
this.tool = tool
|
||||||
|
@ -53,7 +53,7 @@ export type Zone = {
|
|||||||
height: number
|
height: number
|
||||||
tiles: any | null
|
tiles: any | null
|
||||||
pvp: boolean
|
pvp: boolean
|
||||||
zoneEffects: ZoneEffects
|
zoneEffects: ZoneEffect[]
|
||||||
zoneEventTiles: ZoneEventTile[]
|
zoneEventTiles: ZoneEventTile[]
|
||||||
zoneObjects: ZoneObject[]
|
zoneObjects: ZoneObject[]
|
||||||
characters: Character[]
|
characters: Character[]
|
||||||
@ -62,7 +62,7 @@ export type Zone = {
|
|||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ZoneEffects = {
|
export type ZoneEffect = {
|
||||||
id: string
|
id: string
|
||||||
zoneId: number
|
zoneId: number
|
||||||
zone: Zone
|
zone: Zone
|
||||||
|
Loading…
x
Reference in New Issue
Block a user