Änderung: Hinzufügung des Taxi-Minispiels und zugehöriger Funktionen

Änderungen:
- Integration des Taxi-Minispiels mit neuen Routen und Komponenten im Backend und Frontend.
- Erstellung von Modellen und Datenbank-Schemas für das Taxi-Spiel, einschließlich TaxiGameState, TaxiLevelStats und TaxiMap.
- Erweiterung der Navigationsstruktur und der Benutzeroberfläche, um das Taxi-Spiel und die zugehörigen Tools zu unterstützen.
- Aktualisierung der Übersetzungen für das Taxi-Minispiel in Deutsch und Englisch.

Diese Anpassungen erweitern die Funktionalität der Anwendung um ein neues Minispiel und verbessern die Benutzererfahrung durch neue Features und Inhalte.
This commit is contained in:
Torsten Schulz (local)
2025-09-15 17:59:42 +02:00
parent 4699488ce1
commit f230849a5c
72 changed files with 7698 additions and 133 deletions

View File

@@ -0,0 +1,144 @@
import TaxiMapService from '../services/taxiMapService.js';
class TaxiMapController {
constructor() {
this.taxiMapService = new TaxiMapService();
// Bind all methods to the class instance
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);
this.deleteMap = this.deleteMap.bind(this);
this.setDefaultMap = this.setDefaultMap.bind(this);
}
async getMapTypes(req, res) {
try {
const mapTypes = await this.taxiMapService.getMapTypes();
res.json({ success: true, data: mapTypes });
} catch (error) {
console.error('Error getting map types:', error);
res.status(500).json({ success: false, message: 'Fehler beim Laden der Map-Typen' });
}
}
async getMaps(req, res) {
try {
const maps = await this.taxiMapService.getMaps();
res.json({ success: true, data: maps });
} catch (error) {
console.error('Error getting maps:', error);
res.status(500).json({ success: false, message: 'Fehler beim Laden der Maps' });
}
}
async getMapById(req, res) {
try {
const { mapId } = req.params;
const map = await this.taxiMapService.getMapById(mapId);
if (!map) {
return res.status(404).json({ success: false, message: 'Map nicht gefunden' });
}
res.json({ success: true, data: map });
} catch (error) {
console.error('Error getting map by ID:', error);
res.status(500).json({ success: false, message: 'Fehler beim Laden der Map' });
}
}
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 {
const map = await this.taxiMapService.getDefaultMap();
if (!map) {
return res.status(404).json({ success: false, message: 'Keine Standard-Map gefunden' });
}
res.json({ success: true, data: map });
} catch (error) {
console.error('Error getting default map:', error);
res.status(500).json({ success: false, message: 'Fehler beim Laden der Standard-Map' });
}
}
async createMap(req, res) {
try {
const mapData = req.body;
const map = await this.taxiMapService.createMap(mapData);
res.status(201).json({ success: true, data: map });
} catch (error) {
console.error('Error creating map:', error);
res.status(500).json({ success: false, message: 'Fehler beim Erstellen der Map' });
}
}
async updateMap(req, res) {
try {
const { mapId } = req.params;
const updateData = req.body;
const map = await this.taxiMapService.updateMap(mapId, updateData);
res.json({ success: true, data: map });
} catch (error) {
console.error('Error updating map:', error);
if (error.message === 'Map not found') {
return res.status(404).json({ success: false, message: 'Map nicht gefunden' });
}
res.status(500).json({ success: false, message: 'Fehler beim Aktualisieren der Map' });
}
}
async deleteMap(req, res) {
try {
const { mapId } = req.params;
await this.taxiMapService.deleteMap(mapId);
res.json({ success: true, message: 'Map erfolgreich gelöscht' });
} catch (error) {
console.error('Error deleting map:', error);
if (error.message === 'Map not found') {
return res.status(404).json({ success: false, message: 'Map nicht gefunden' });
}
res.status(500).json({ success: false, message: 'Fehler beim Löschen der Map' });
}
}
async setDefaultMap(req, res) {
try {
const { mapId } = req.params;
await this.taxiMapService.setDefaultMap(mapId);
res.json({ success: true, message: 'Standard-Map erfolgreich gesetzt' });
} catch (error) {
console.error('Error setting default map:', error);
if (error.message === 'Map not found') {
return res.status(404).json({ success: false, message: 'Map nicht gefunden' });
}
res.status(500).json({ success: false, message: 'Fehler beim Setzen der Standard-Map' });
}
}
}
export default TaxiMapController;