Änderung: Hinzufügung der Ampel-Logik zur Taxi-Map
Änderungen: - Erweiterung des TaxiMapTile-Modells um die Spalte trafficLight zur Verwaltung von Ampelzuständen. - Anpassung der TaxiMapService-Logik zur Unterstützung der Ampel-Updates und -Zustände. - Implementierung von Methoden zur Steuerung und Anzeige von Ampeln in der Benutzeroberfläche, einschließlich der neuen Funktionen in TaxiToolsView.vue und TaxiGame.vue. - Verbesserung der Darstellung und Logik zur Ampelsteuerung im Spiel, einschließlich der visuellen Darstellung und der Interaktion mit Ampeln. Diese Anpassungen verbessern die Funktionalität und Benutzererfahrung im Taxi-Minispiel erheblich, indem sie eine realistischere Verkehrssteuerung ermöglichen.
This commit is contained in:
@@ -23,6 +23,12 @@ const TaxiMapTile = sequelize.define('TaxiMapTile', {
|
||||
type: DataTypes.STRING(50),
|
||||
allowNull: false,
|
||||
},
|
||||
trafficLight: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
comment: 'Whether this tile has a traffic light'
|
||||
},
|
||||
meta: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
@@ -36,6 +42,7 @@ const TaxiMapTile = sequelize.define('TaxiMapTile', {
|
||||
{ unique: true, fields: ['map_id','x','y'] },
|
||||
{ fields: ['map_id'] },
|
||||
{ fields: ['tile_type'] },
|
||||
{ fields: ['traffic_light'] },
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const UserRightType = sequelize.define('user_right_type', {
|
||||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
tableName: 'user_right',
|
||||
tableName: 'user_right_type',
|
||||
schema: 'type',
|
||||
underscored: true
|
||||
});
|
||||
|
||||
@@ -209,7 +209,9 @@ class TaxiMapService extends BaseService {
|
||||
where: { mapId, x, y },
|
||||
defaults: { mapId, x, y, tileType, meta: meta || null }
|
||||
});
|
||||
await row.update({ tileType, meta: meta || null });
|
||||
// trafficLight kann in meta.trafficLight oder künftig in eigener Spalte liegen
|
||||
const trafficLight = !!(meta && meta.trafficLight);
|
||||
await row.update({ tileType, meta: meta && Object.keys(meta).length ? meta : null, trafficLight });
|
||||
}
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -45,8 +45,10 @@ const createSchemas = async () => {
|
||||
|
||||
const initializeDatabase = async () => {
|
||||
await createSchemas();
|
||||
const { default: models } = await import('../models/index.js');
|
||||
await syncModels(models);
|
||||
// Modelle nur laden, aber an dieser Stelle NICHT syncen.
|
||||
// Das Syncing (inkl. alter: true bei Bedarf) wird anschließend zentral
|
||||
// über syncModelsWithUpdates()/syncModelsAlways gesteuert.
|
||||
await import('../models/index.js');
|
||||
};
|
||||
|
||||
const syncModels = async (models) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// syncDatabase.js
|
||||
|
||||
import { initializeDatabase, syncModelsWithUpdates, syncModelsAlways } from './sequelize.js';
|
||||
import { initializeDatabase, syncModelsWithUpdates, syncModelsAlways, sequelize } from './sequelize.js';
|
||||
import initializeTypes from './initializeTypes.js';
|
||||
import initializeSettings from './initializeSettings.js';
|
||||
import initializeUserRights from './initializeUserRights.js';
|
||||
@@ -33,11 +33,32 @@ const syncDatabase = async () => {
|
||||
console.log("Initializing database schemas...");
|
||||
await initializeDatabase();
|
||||
|
||||
console.log("Synchronizing models...");
|
||||
await syncModelsWithUpdates(models);
|
||||
// Vorab: Stelle kritische Spalten sicher, damit Index-Erstellung nicht fehlschlägt
|
||||
console.log("Pre-ensure Taxi columns (traffic_light) ...");
|
||||
try {
|
||||
await sequelize.query(`
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'taxi' AND table_name = 'taxi_map_tile' AND column_name = 'traffic_light'
|
||||
) THEN
|
||||
ALTER TABLE taxi.taxi_map_tile
|
||||
ADD COLUMN traffic_light BOOLEAN NOT NULL DEFAULT false;
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
`);
|
||||
console.log("✅ traffic_light-Spalte ist vorhanden");
|
||||
} catch (e) {
|
||||
console.warn('⚠️ Konnte traffic_light-Spalte nicht vorab sicherstellen:', e?.message || e);
|
||||
}
|
||||
|
||||
console.log("Setting up associations...");
|
||||
setupAssociations();
|
||||
setupAssociations();
|
||||
|
||||
console.log("Synchronizing models...");
|
||||
await syncModelsWithUpdates(models);
|
||||
|
||||
console.log("Initializing settings...");
|
||||
await initializeSettings();
|
||||
@@ -91,11 +112,32 @@ const syncDatabaseForDeployment = async () => {
|
||||
console.log("Initializing database schemas...");
|
||||
await initializeDatabase();
|
||||
|
||||
console.log("Synchronizing models with schema updates...");
|
||||
await syncModelsAlways(models);
|
||||
// Vorab: Stelle kritische Spalten sicher, damit Index-Erstellung nicht fehlschlägt
|
||||
console.log("Pre-ensure Taxi columns (traffic_light) ...");
|
||||
try {
|
||||
await sequelize.query(`
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'taxi' AND table_name = 'taxi_map_tile' AND column_name = 'traffic_light'
|
||||
) THEN
|
||||
ALTER TABLE taxi.taxi_map_tile
|
||||
ADD COLUMN traffic_light BOOLEAN NOT NULL DEFAULT false;
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
`);
|
||||
console.log("✅ traffic_light-Spalte ist vorhanden");
|
||||
} catch (e) {
|
||||
console.warn('⚠️ Konnte traffic_light-Spalte nicht vorab sicherstellen:', e?.message || e);
|
||||
}
|
||||
|
||||
console.log("Setting up associations...");
|
||||
setupAssociations();
|
||||
setupAssociations();
|
||||
|
||||
console.log("Synchronizing models with schema updates...");
|
||||
await syncModelsAlways(models);
|
||||
|
||||
console.log("Initializing settings...");
|
||||
await initializeSettings();
|
||||
|
||||
Reference in New Issue
Block a user