Änderung: Hinzufügen von TaxiHighscore-Logik und Verbesserung der API-Integration
Änderungen: - Implementierung des neuen Routers für TaxiHighscore zur Verwaltung von Highscore-Daten. - Anpassung der Datenbankmodelle zur Unterstützung von TaxiHighscore-Associations. - Erweiterung der Vue-Komponenten zur Anzeige und Speicherung von Highscores im Taxi-Spiel. - Verbesserung der Statusanzeige im AppHeader zur besseren Benutzerinteraktion. Diese Anpassungen erweitern die Spielmechanik und Benutzererfahrung, indem sie die Verwaltung von Highscores integrieren und die Benutzeroberfläche optimieren.
This commit is contained in:
@@ -110,6 +110,7 @@ import TaxiMapTile from './taxi/taxiMapTile.js';
|
||||
import TaxiMapTileHouse from './taxi/taxiMapTileHouse.js';
|
||||
import TaxiStreetName from './taxi/taxiStreetName.js';
|
||||
import TaxiMapTileStreet from './taxi/taxiMapTileStreet.js';
|
||||
import TaxiHighscore from './minigames/taxiHighscore.js';
|
||||
|
||||
export default function setupAssociations() {
|
||||
// RoomType 1:n Room
|
||||
@@ -820,4 +821,12 @@ export default function setupAssociations() {
|
||||
// Houses per tile (one row per corner)
|
||||
TaxiMap.hasMany(TaxiMapTileHouse, { foreignKey: 'map_id', as: 'tileHouses' });
|
||||
TaxiMapTileHouse.belongsTo(TaxiMap, { foreignKey: 'map_id', as: 'map' });
|
||||
|
||||
// Taxi Highscore associations
|
||||
TaxiHighscore.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
||||
User.hasMany(TaxiHighscore, { foreignKey: 'userId', as: 'taxiHighscores' });
|
||||
|
||||
TaxiHighscore.belongsTo(TaxiMap, { foreignKey: 'mapId', as: 'map' });
|
||||
TaxiMap.hasMany(TaxiHighscore, { foreignKey: 'mapId', as: 'highscores' });
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ import Match3UserLevelProgress from './match3/userLevelProgress.js';
|
||||
|
||||
// — Taxi Minigame —
|
||||
import { TaxiGameState, TaxiLevelStats, TaxiMapType, TaxiMap, TaxiMapTile, TaxiStreetName, TaxiMapTileStreet, TaxiMapTileHouse } from './taxi/index.js';
|
||||
import TaxiHighscore from './minigames/taxiHighscore.js';
|
||||
|
||||
// — Politische Ämter (Politics) —
|
||||
import PoliticalOfficeType from './falukant/type/political_office_type.js';
|
||||
@@ -243,6 +244,7 @@ const models = {
|
||||
TaxiStreetName,
|
||||
TaxiMapTileStreet,
|
||||
TaxiMapTileHouse,
|
||||
TaxiHighscore,
|
||||
};
|
||||
|
||||
export default models;
|
||||
|
||||
100
backend/models/minigames/taxiHighscore.js
Normal file
100
backend/models/minigames/taxiHighscore.js
Normal file
@@ -0,0 +1,100 @@
|
||||
import { DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
|
||||
const TaxiHighscore = sequelize.define('TaxiHighscore', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
userId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true, // Kann null sein, falls User gelöscht wird
|
||||
references: {
|
||||
model: {
|
||||
tableName: 'user',
|
||||
schema: 'community'
|
||||
},
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
nickname: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: true, // Kann null sein, falls User gelöscht wird
|
||||
comment: 'Nickname zum Zeitpunkt des Spiels - bleibt erhalten wenn User gelöscht wird'
|
||||
},
|
||||
passengersDelivered: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: 'Anzahl der abgelieferten Passagiere'
|
||||
},
|
||||
playtime: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: 'Spielzeit in Sekunden'
|
||||
},
|
||||
points: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: 'Erreichte Punkte'
|
||||
},
|
||||
mapId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: {
|
||||
tableName: 'taxi_map',
|
||||
schema: 'taxi'
|
||||
},
|
||||
key: 'id'
|
||||
},
|
||||
comment: 'ID der gespielten Map'
|
||||
},
|
||||
mapName: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: true,
|
||||
comment: 'Name der Map zum Zeitpunkt des Spiels'
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW
|
||||
}
|
||||
}, {
|
||||
tableName: 'taxi_highscores',
|
||||
schema: 'taxi',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{
|
||||
fields: ['user_id']
|
||||
},
|
||||
{
|
||||
fields: ['points']
|
||||
},
|
||||
{
|
||||
fields: ['passengers_delivered']
|
||||
},
|
||||
{
|
||||
fields: ['map_id']
|
||||
},
|
||||
{
|
||||
fields: ['created_at']
|
||||
},
|
||||
{
|
||||
unique: true,
|
||||
fields: ['user_id', 'map_id'],
|
||||
name: 'unique_user_map_highscore'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
export default TaxiHighscore;
|
||||
Reference in New Issue
Block a user