Bereinigen und Entfernen von nicht mehr benötigten TinyMCE-Dateien und -Plugins; Aktualisierung der Internationalisierung für Deutsch und Englisch in den Falukant- und Navigationsmodulen; Verbesserung der Statusleiste und Router-Implementierung.
This commit is contained in:
63
backend/utils/fixMatch3Data.js
Normal file
63
backend/utils/fixMatch3Data.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import { sequelize } from './sequelize.js';
|
||||
import Match3UserProgress from '../models/match3/userProgress.js';
|
||||
|
||||
/**
|
||||
* Korrigiert alle ungültigen currentLevel-Werte in der Match3-Datenbank
|
||||
*/
|
||||
async function fixMatch3Data() {
|
||||
try {
|
||||
console.log('🔧 Starte Korrektur der Match3-Daten...');
|
||||
|
||||
// Finde alle UserProgress-Einträge mit ungültigen currentLevel-Werten
|
||||
const invalidEntries = await Match3UserProgress.findAll({
|
||||
where: {
|
||||
currentLevel: {
|
||||
[sequelize.Op.or]: [
|
||||
{ [sequelize.Op.lt]: 1 },
|
||||
{ [sequelize.Op.gt]: 1000 }
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`📊 Gefunden: ${invalidEntries.length} ungültige Einträge`);
|
||||
|
||||
if (invalidEntries.length === 0) {
|
||||
console.log('✅ Alle currentLevel-Werte sind bereits korrekt');
|
||||
return;
|
||||
}
|
||||
|
||||
// Korrigiere jeden ungültigen Eintrag
|
||||
for (const entry of invalidEntries) {
|
||||
const oldValue = entry.currentLevel;
|
||||
const correctValue = entry.levelsCompleted + 1;
|
||||
|
||||
console.log(`🔧 Korrigiere User ${entry.userId}: currentLevel ${oldValue} → ${correctValue}`);
|
||||
|
||||
await entry.update({
|
||||
currentLevel: correctValue
|
||||
});
|
||||
}
|
||||
|
||||
console.log('✅ Alle ungültigen currentLevel-Werte wurden korrigiert');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Fehler beim Korrigieren der Match3-Daten:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Führe das Skript aus, wenn es direkt aufgerufen wird
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
fixMatch3Data()
|
||||
.then(() => {
|
||||
console.log('🎯 Match3-Datenkorrektur abgeschlossen');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('💥 Match3-Datenkorrektur fehlgeschlagen:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
export default fixMatch3Data;
|
||||
104
backend/utils/initializeMatch3.js
Normal file
104
backend/utils/initializeMatch3.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import Match3Campaign from '../models/match3/campaign.js';
|
||||
import Match3Level from '../models/match3/level.js';
|
||||
import Match3Objective from '../models/match3/objective.js';
|
||||
|
||||
export const initializeMatch3Data = async () => {
|
||||
try {
|
||||
// Prüfe ob bereits Daten vorhanden sind
|
||||
const existingCampaigns = await Match3Campaign.count();
|
||||
if (existingCampaigns > 0) {
|
||||
console.log('Match3 data already exists, skipping initialization');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Initializing Match3 data...');
|
||||
|
||||
// Erstelle erste Kampagne
|
||||
const campaign = await Match3Campaign.create({
|
||||
name: 'Juwelen-Meister',
|
||||
description: 'Meistere die Kunst des Juwelen-Matchings',
|
||||
isActive: true,
|
||||
order: 1
|
||||
});
|
||||
|
||||
// Erstelle erste Level
|
||||
const level1 = await Match3Level.create({
|
||||
campaignId: campaign.id,
|
||||
name: 'Der Anfang',
|
||||
description: 'Lerne die Grundlagen des Spiels',
|
||||
order: 1,
|
||||
boardSize: 6,
|
||||
tileTypes: ['gem', 'star', 'heart'],
|
||||
moveLimit: 15,
|
||||
isActive: true
|
||||
});
|
||||
|
||||
const level2 = await Match3Level.create({
|
||||
campaignId: campaign.id,
|
||||
name: 'Erste Herausforderung',
|
||||
description: 'Erweitere deine Fähigkeiten',
|
||||
order: 2,
|
||||
boardSize: 7,
|
||||
tileTypes: ['gem', 'star', 'heart', 'diamond'],
|
||||
moveLimit: 20,
|
||||
isActive: true
|
||||
});
|
||||
|
||||
// Erstelle Objectives für Level 1
|
||||
await Match3Objective.bulkCreate([
|
||||
{
|
||||
levelId: level1.id,
|
||||
type: 'score',
|
||||
description: 'Sammle 100 Punkte',
|
||||
target: 100,
|
||||
operator: '>=',
|
||||
order: 1,
|
||||
isRequired: true
|
||||
},
|
||||
{
|
||||
levelId: level1.id,
|
||||
type: 'matches',
|
||||
description: 'Mache 3 Matches',
|
||||
target: 3,
|
||||
operator: '>=',
|
||||
order: 2,
|
||||
isRequired: true
|
||||
}
|
||||
]);
|
||||
|
||||
// Erstelle Objectives für Level 2
|
||||
await Match3Objective.bulkCreate([
|
||||
{
|
||||
levelId: level2.id,
|
||||
type: 'score',
|
||||
description: 'Sammle 200 Punkte',
|
||||
target: 200,
|
||||
operator: '>=',
|
||||
order: 1,
|
||||
isRequired: true
|
||||
},
|
||||
{
|
||||
levelId: level2.id,
|
||||
type: 'matches',
|
||||
description: 'Mache 5 Matches',
|
||||
target: 5,
|
||||
operator: '>=',
|
||||
order: 2,
|
||||
isRequired: true
|
||||
},
|
||||
{
|
||||
levelId: level2.id,
|
||||
type: 'moves',
|
||||
description: 'Verwende weniger als 20 Züge',
|
||||
target: 20,
|
||||
operator: '<=',
|
||||
order: 3,
|
||||
isRequired: true
|
||||
}
|
||||
]);
|
||||
|
||||
console.log('Match3 data initialized successfully');
|
||||
} catch (error) {
|
||||
console.error('Error initializing Match3 data:', error);
|
||||
}
|
||||
};
|
||||
@@ -22,6 +22,7 @@ const createSchemas = async () => {
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS falukant_predefine');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS falukant_log');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS chat');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS match3');
|
||||
};
|
||||
|
||||
const initializeDatabase = async () => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import models from '../models/index.js';
|
||||
import { createTriggers } from '../models/trigger.js';
|
||||
import initializeForum from './initializeForum.js';
|
||||
import initializeChat from './initializeChat.js';
|
||||
import { initializeMatch3Data } from './initializeMatch3.js';
|
||||
|
||||
const syncDatabase = async () => {
|
||||
try {
|
||||
@@ -47,6 +48,9 @@ const syncDatabase = async () => {
|
||||
console.log("Initializing chat...");
|
||||
await initializeChat();
|
||||
|
||||
console.log("Initializing Match3...");
|
||||
await initializeMatch3Data();
|
||||
|
||||
console.log('Database synchronization complete.');
|
||||
} catch (error) {
|
||||
console.error('Unable to synchronize the database:', error);
|
||||
|
||||
Reference in New Issue
Block a user