feat(match3): Erweiterung der Match3-Admin-Funktionalitäten und -Modelle
- Implementierung neuer Endpunkte für die Verwaltung von Match3-Kampagnen, Levels, Objectives und Tile-Typen im Admin-Bereich. - Anpassung der Admin-Services zur Unterstützung von Benutzerberechtigungen und Fehlerbehandlung. - Einführung von neuen Modellen und Assoziationen für Match3-Levels und Tile-Typen in der Datenbank. - Verbesserung der Internationalisierung für Match3-spezifische Texte in Deutsch und Englisch. - Aktualisierung der Frontend-Routen und -Komponenten zur Verwaltung von Match3-Inhalten.
This commit is contained in:
74
backend/utils/updateExistingMatch3Levels.js
Normal file
74
backend/utils/updateExistingMatch3Levels.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import { sequelize } from './sequelize.js';
|
||||
import Match3Level from '../models/match3/level.js';
|
||||
|
||||
/**
|
||||
* Aktualisiert existierende Match3-Level mit Standard-Layouts
|
||||
* und neuen Feldern
|
||||
*/
|
||||
async function updateExistingMatch3Levels() {
|
||||
try {
|
||||
console.log('🔧 Aktualisiere existierende Match3-Level...');
|
||||
|
||||
// Finde alle existierenden Level ohne boardLayout
|
||||
const existingLevels = await Match3Level.findAll({
|
||||
where: {
|
||||
boardLayout: null
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`📊 Gefunden: ${existingLevels.length} Level ohne boardLayout`);
|
||||
|
||||
if (existingLevels.length === 0) {
|
||||
console.log('✅ Alle Level haben bereits boardLayout');
|
||||
return;
|
||||
}
|
||||
|
||||
// Aktualisiere jeden Level mit Standard-Layout
|
||||
for (const level of existingLevels) {
|
||||
const oldBoardSize = level.boardSize || 6;
|
||||
|
||||
// Erstelle Standard-Layout basierend auf alter boardSize
|
||||
let boardLayout = '';
|
||||
for (let i = 0; i < oldBoardSize; i++) {
|
||||
for (let j = 0; j < oldBoardSize; j++) {
|
||||
boardLayout += 'x';
|
||||
}
|
||||
if (i < oldBoardSize - 1) boardLayout += '\n';
|
||||
}
|
||||
|
||||
// Aktualisiere den Level mit allen neuen Feldern
|
||||
await level.update({
|
||||
boardLayout: boardLayout,
|
||||
boardWidth: oldBoardSize,
|
||||
boardHeight: oldBoardSize,
|
||||
// Stelle sicher, dass alle erforderlichen Felder gesetzt sind
|
||||
tileTypes: level.tileTypes || ['gem', 'star', 'heart'],
|
||||
moveLimit: level.moveLimit || 20,
|
||||
isActive: level.isActive !== undefined ? level.isActive : true
|
||||
});
|
||||
|
||||
console.log(`🔧 Level ${level.id} aktualisiert: ${oldBoardSize}x${oldBoardSize} → alle neuen Felder gesetzt`);
|
||||
}
|
||||
|
||||
console.log('✅ Alle existierenden Level wurden aktualisiert');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Fehler beim Aktualisieren der Match3-Level:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Führe das Skript aus, wenn es direkt aufgerufen wird
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
updateExistingMatch3Levels()
|
||||
.then(() => {
|
||||
console.log('🎯 Match3-Level-Update abgeschlossen');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('💥 Match3-Level-Update fehlgeschlagen:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
export default updateExistingMatch3Levels;
|
||||
Reference in New Issue
Block a user