forked from noxious/client
Almost finalised refactoring
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import type { Map, MapCharacter } from '@/application/types'
|
||||
import type { Map, MapCharacter, UUID } from '@/application/types'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useMapStore = defineStore('map', {
|
||||
@ -11,7 +11,7 @@ export const useMapStore = defineStore('map', {
|
||||
},
|
||||
getters: {
|
||||
getCharacterById: (state) => {
|
||||
return (id: number) => state.characters.find((char) => char.character.id === id)
|
||||
return (id: UUID) => state.characters.find((char) => char.character.id === id)
|
||||
},
|
||||
getCharacterCount: (state) => {
|
||||
return state.characters.length
|
||||
@ -34,13 +34,13 @@ export const useMapStore = defineStore('map', {
|
||||
const index = this.characters.findIndex((char) => char.character.id === updatedCharacter.character.id)
|
||||
if (index !== -1) this.characters[index] = updatedCharacter
|
||||
},
|
||||
removeCharacter(characterId: number) {
|
||||
removeCharacter(characterId: UUID) {
|
||||
this.characters = this.characters.filter((char) => char.character.id !== characterId)
|
||||
},
|
||||
setCharacterLoaded(loaded: boolean) {
|
||||
this.characterLoaded = loaded
|
||||
},
|
||||
updateCharacterPosition(data: { characterId: number; positionX: number; positionY: number; rotation: number; isMoving: boolean }) {
|
||||
updateCharacterPosition(data: { characterId: UUID; positionX: number; positionY: number; rotation: number; isMoving: boolean }) {
|
||||
const character = this.characters.find((char) => char.character.id === data.characterId)
|
||||
if (character) {
|
||||
character.character.positionX = data.positionX
|
||||
|
Reference in New Issue
Block a user