From 935928af7551a7a8ec6e0ec37fd6424eb432f436 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 15 Sep 2025 19:28:57 +0200 Subject: [PATCH] =?UTF-8?q?=C3=84nderung:=20Bereinigung=20und=20Optimierun?= =?UTF-8?q?g=20der=20Taxi-Map-Logik?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Änderungen: - Entfernen der Methode `getMapByPosition` aus dem `TaxiMapController` und der zugehörigen Logik im `TaxiMapService`, um die Komplexität zu reduzieren. - Anpassung der Datenbankmodelle für `TaxiMap`, `TaxiLevelStats` und `TaxiMapType`, um die Tabellennamen zu vereinheitlichen. - Aktualisierung der Routen im `taxiMapRouter`, um die entfernte Funktionalität zu reflektieren. - Hinzufügung von neuen Importen in `index.js`, um die neuen Modelle zu integrieren. - Verbesserung der Benutzeroberfläche durch neue Erfolgsmeldungen in den Übersetzungsdateien für die Admin-Oberfläche. Diese Anpassungen tragen zur Vereinfachung der Codebasis und zur Verbesserung der Benutzererfahrung im Taxi-Minispiel bei. --- backend/controllers/taxiMapController.js | 19 ----- backend/models/index.js | 4 + backend/models/taxi/taxiGameState.js | 2 +- backend/models/taxi/taxiLevelStats.js | 2 +- backend/models/taxi/taxiMap.js | 19 +---- backend/models/taxi/taxiMapType.js | 2 +- backend/routers/taxiMapRouter.js | 1 - backend/services/taxiMapService.js | 56 +------------ frontend/src/i18n/locales/de/admin.json | 5 +- frontend/src/i18n/locales/en/admin.json | 5 +- frontend/src/views/admin/TaxiToolsView.vue | 91 ++++------------------ frontend/src/views/minigames/TaxiGame.vue | 1 + 12 files changed, 35 insertions(+), 172 deletions(-) diff --git a/backend/controllers/taxiMapController.js b/backend/controllers/taxiMapController.js index 136b2ca..5808c02 100644 --- a/backend/controllers/taxiMapController.js +++ b/backend/controllers/taxiMapController.js @@ -8,7 +8,6 @@ class TaxiMapController { this.getMapTypes = this.getMapTypes.bind(this); this.getMaps = this.getMaps.bind(this); this.getMapById = this.getMapById.bind(this); - this.getMapByPosition = this.getMapByPosition.bind(this); this.getDefaultMap = this.getDefaultMap.bind(this); this.createMap = this.createMap.bind(this); this.updateMap = this.updateMap.bind(this); @@ -52,24 +51,6 @@ class TaxiMapController { } } - async getMapByPosition(req, res) { - try { - const { positionX, positionY } = req.params; - const map = await this.taxiMapService.getMapByPosition( - parseInt(positionX), - parseInt(positionY) - ); - - if (!map) { - return res.status(404).json({ success: false, message: 'Map an Position nicht gefunden' }); - } - - res.json({ success: true, data: map }); - } catch (error) { - console.error('Error getting map by position:', error); - res.status(500).json({ success: false, message: 'Fehler beim Laden der Map' }); - } - } async getDefaultMap(req, res) { try { diff --git a/backend/models/index.js b/backend/models/index.js index b8641d8..fa81a33 100644 --- a/backend/models/index.js +++ b/backend/models/index.js @@ -97,6 +97,8 @@ import Match3UserLevelProgress from './match3/userLevelProgress.js'; // — Taxi Minigame — import { TaxiGameState, TaxiLevelStats } from './taxi/index.js'; +import TaxiMap from './taxi/taxiMap.js'; +import TaxiMapType from './taxi/taxiMapType.js'; // — Politische Ämter (Politics) — import PoliticalOfficeType from './falukant/type/political_office_type.js'; @@ -237,6 +239,8 @@ const models = { // Taxi Minigame TaxiGameState, TaxiLevelStats, + TaxiMap, + TaxiMapType, }; export default models; diff --git a/backend/models/taxi/taxiGameState.js b/backend/models/taxi/taxiGameState.js index 4bbca38..0991d96 100644 --- a/backend/models/taxi/taxiGameState.js +++ b/backend/models/taxi/taxiGameState.js @@ -52,7 +52,7 @@ const TaxiGameState = sequelize.define('TaxiGameState', { defaultValue: DataTypes.NOW } }, { - tableName: 'taxi_game_states', + tableName: 'taxi_game_state', schema: 'taxi', timestamps: true, indexes: [ diff --git a/backend/models/taxi/taxiLevelStats.js b/backend/models/taxi/taxiLevelStats.js index 4977138..c23da16 100644 --- a/backend/models/taxi/taxiLevelStats.js +++ b/backend/models/taxi/taxiLevelStats.js @@ -56,7 +56,7 @@ const TaxiLevelStats = sequelize.define('TaxiLevelStats', { defaultValue: DataTypes.NOW } }, { - tableName: 'taxi_level_stats', + tableName: 'taxi_level_stat', schema: 'taxi', timestamps: true, indexes: [ diff --git a/backend/models/taxi/taxiMap.js b/backend/models/taxi/taxiMap.js index 90fa641..f9f7aff 100644 --- a/backend/models/taxi/taxiMap.js +++ b/backend/models/taxi/taxiMap.js @@ -43,16 +43,6 @@ const TaxiMap = sequelize.define('TaxiMap', { allowNull: false, comment: '2D array of map type IDs for each tile position' }, - positionX: { - type: DataTypes.INTEGER, - allowNull: false, - comment: 'X position as continuous integer (1, 2, 3, ...)' - }, - positionY: { - type: DataTypes.INTEGER, - allowNull: false, - comment: 'Y position as continuous integer (1, 2, 3, ...)' - }, isActive: { type: DataTypes.BOOLEAN, allowNull: false, @@ -75,7 +65,7 @@ const TaxiMap = sequelize.define('TaxiMap', { defaultValue: DataTypes.NOW } }, { - tableName: 'taxi_maps', + tableName: 'taxi_map', schema: 'taxi', timestamps: true, indexes: [ @@ -88,13 +78,6 @@ const TaxiMap = sequelize.define('TaxiMap', { { fields: ['is_default'] }, - { - fields: ['position_x', 'position_y'] - }, - { - unique: true, - fields: ['position_x', 'position_y'] - } ] }); diff --git a/backend/models/taxi/taxiMapType.js b/backend/models/taxi/taxiMapType.js index 3701947..688d07c 100644 --- a/backend/models/taxi/taxiMapType.js +++ b/backend/models/taxi/taxiMapType.js @@ -37,7 +37,7 @@ const TaxiMapType = sequelize.define('TaxiMapType', { defaultValue: DataTypes.NOW } }, { - tableName: 'taxi_map_types', + tableName: 'taxi_map_type', schema: 'taxi', timestamps: true, indexes: [ diff --git a/backend/routers/taxiMapRouter.js b/backend/routers/taxiMapRouter.js index 3c9ebc0..183bad4 100644 --- a/backend/routers/taxiMapRouter.js +++ b/backend/routers/taxiMapRouter.js @@ -14,7 +14,6 @@ router.get('/map-types', (req, res) => taxiMapController.getMapTypes(req, res)); // Maps routes router.get('/maps', (req, res) => taxiMapController.getMaps(req, res)); router.get('/maps/default', (req, res) => taxiMapController.getDefaultMap(req, res)); -router.get('/maps/position/:positionX/:positionY', (req, res) => taxiMapController.getMapByPosition(req, res)); router.get('/maps/:mapId', (req, res) => taxiMapController.getMapById(req, res)); // Map management routes (admin only - you might want to add admin middleware) diff --git a/backend/services/taxiMapService.js b/backend/services/taxiMapService.js index 66ff785..72dec58 100644 --- a/backend/services/taxiMapService.js +++ b/backend/services/taxiMapService.js @@ -34,7 +34,7 @@ class TaxiMapService extends BaseService { model: TaxiMapType, as: 'mapType' }], - order: [['positionY', 'ASC'], ['positionX', 'ASC']] + order: [['name', 'ASC']] }); return maps; } catch (error) { @@ -65,28 +65,6 @@ class TaxiMapService extends BaseService { } } - /** - * Holt eine Map nach Position - */ - async getMapByPosition(positionX, positionY) { - try { - const map = await TaxiMap.findOne({ - where: { - positionX: positionX, - positionY: positionY, - isActive: true - }, - include: [{ - model: TaxiMapType, - as: 'mapType' - }] - }); - return map; - } catch (error) { - console.error('Error getting map by position:', error); - throw error; - } - } /** * Holt die Standard-Map @@ -231,38 +209,6 @@ class TaxiMapService extends BaseService { * Erstellt eine Standard-Map */ async createDefaultMap() { - try { - // 8x8 Standard-Map mit verschiedenen Tile-Typen - const mapData = [ - ['cornerTopLeft', 'horizontal', 'horizontal', 'horizontal', 'horizontal', 'horizontal', 'horizontal', 'cornerTopRight'], - ['vertical', 'cross', 'cross', 'cross', 'cross', 'cross', 'cross', 'vertical'], - ['vertical', 'cross', 'cross', 'cross', 'cross', 'cross', 'cross', 'vertical'], - ['vertical', 'cross', 'cross', 'cross', 'cross', 'cross', 'cross', 'vertical'], - ['vertical', 'cross', 'cross', 'cross', 'cross', 'cross', 'cross', 'vertical'], - ['vertical', 'cross', 'cross', 'cross', 'cross', 'cross', 'cross', 'vertical'], - ['vertical', 'cross', 'cross', 'cross', 'cross', 'cross', 'cross', 'vertical'], - ['cornerBottomLeft', 'horizontal', 'horizontal', 'horizontal', 'horizontal', 'horizontal', 'horizontal', 'cornerBottomRight'] - ]; - - const map = await TaxiMap.create({ - name: 'Standard City Map', - description: 'A standard 8x8 city map with roads and intersections', - width: 8, - height: 8, - tileSize: 50, - mapTypeId: 1, // Assuming first map type - mapData: mapData, - positionX: 1, - positionY: 1, - isDefault: true, - isActive: true - }); - - return map; - } catch (error) { - console.error('Error creating default map:', error); - throw error; - } } } diff --git a/frontend/src/i18n/locales/de/admin.json b/frontend/src/i18n/locales/de/admin.json index 0c4c66b..0d764c6 100644 --- a/frontend/src/i18n/locales/de/admin.json +++ b/frontend/src/i18n/locales/de/admin.json @@ -218,7 +218,10 @@ "delete": "Löschen", "update": "Aktualisieren", "cancel": "Abbrechen", - "create": "Erstellen" + "create": "Erstellen", + "createSuccess": "Map wurde erfolgreich erstellt!", + "updateSuccess": "Map wurde erfolgreich aktualisiert!", + "deleteSuccess": "Map wurde erfolgreich gelöscht!" } } } diff --git a/frontend/src/i18n/locales/en/admin.json b/frontend/src/i18n/locales/en/admin.json index 42f6055..2d2d7b8 100644 --- a/frontend/src/i18n/locales/en/admin.json +++ b/frontend/src/i18n/locales/en/admin.json @@ -218,7 +218,10 @@ "delete": "Delete", "update": "Update", "cancel": "Cancel", - "create": "Create" + "create": "Create", + "createSuccess": "Map created successfully!", + "updateSuccess": "Map updated successfully!", + "deleteSuccess": "Map deleted successfully!" } } } diff --git a/frontend/src/views/admin/TaxiToolsView.vue b/frontend/src/views/admin/TaxiToolsView.vue index 43d8304..638cc78 100644 --- a/frontend/src/views/admin/TaxiToolsView.vue +++ b/frontend/src/views/admin/TaxiToolsView.vue @@ -8,7 +8,7 @@ - +

{{ $t('admin.taxiTools.mapEditor.title') }}

@@ -68,14 +68,6 @@
-
-

Größe: {{ boardWidth }}x{{ boardHeight }}

-

Position: ({{ minX }}, {{ minY }}) - ({{ maxX }}, {{ maxY }})

-
-

Ausgewählte Position: ({{ getCellPosition(selectedCellKey).x }}, {{ getCellPosition(selectedCellKey).y }})

-

Wählen Sie rechts ein Tile aus, um es hier zu platzieren.

-
-
-
{{x}},{{y}}
@@ -171,14 +162,6 @@
-
-

Größe: {{ boardWidth }}x{{ boardHeight }}

-

Position: ({{ minX }}, {{ minY }}) - ({{ maxX }}, {{ maxY }})

-
-

Ausgewählte Position: ({{ getCellPosition(selectedCellKey).x }}, {{ getCellPosition(selectedCellKey).y }})

-

Wählen Sie rechts ein Tile aus, um es hier zu platzieren.

-
-
-
{{x}},{{y}}
@@ -240,17 +222,22 @@
+ + +