From 110fd4e6088573212b04026928f55540042f7129 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Fri, 14 Feb 2025 02:49:14 +0100 Subject: [PATCH] TS improvements --- src/application/types.ts | 2 +- .../gameMaster/mapEditor/mapPartials/MapEventTiles.vue | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/application/types.ts b/src/application/types.ts index 61e3b3d..f930451 100644 --- a/src/application/types.ts +++ b/src/application/types.ts @@ -100,7 +100,7 @@ export enum MapEventTileType { export type MapEventTile = { id: string - mapid: string + mapId: string type: MapEventTileType positionX: number positionY: number diff --git a/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue b/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue index 7adcc93..3ffbc95 100644 --- a/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue +++ b/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue @@ -46,7 +46,9 @@ class EventTileCommand implements EditorCommand { } } -function createCommandUpdate(tile?: MapEventTile, operation: 'draw' | 'erase' | 'clear') { +function createCommandUpdate(tile?: MapEventTile | null, operation: 'draw' | 'erase' | 'clear' = 'draw') { + if (!tile) return + if (!currentCommand) { currentCommand = new EventTileCommand(operation) } @@ -106,9 +108,9 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) { : undefined } - createCommandUpdate(newEventTile, 'draw') + createCommandUpdate(newEventTile as MapEventTile, 'draw') - map.mapEventTiles.push(newEventTile) + map.mapEventTiles.push(newEventTile as MapEventTile) } function erase(pointer: Phaser.Input.Pointer, map: MapT) { @@ -149,7 +151,7 @@ function handlePointer(pointer: Phaser.Input.Pointer) { } function clearTiles() { - if (mapEditor.currentMap.value.mapEventTiles.length === 0) return + if (mapEditor.currentMap.value?.mapEventTiles.length === 0) return createCommandUpdate(null, 'clear') finalizeCommand() }