Files
Ninjaserver/scripts/test-multiple-achievements.js
2025-09-23 14:13:24 +02:00

76 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Test Script für mehrfache Achievements
*
* Demonstriert, wie Achievements mehrmals erreicht werden können
* und wie die Gesamtpunkte berechnet werden
*/
const AchievementSystem = require('../lib/achievementSystem');
require('dotenv').config();
async function testMultipleAchievements() {
console.log('🔄 Teste mehrfache Achievements...\n');
try {
const achievementSystem = new AchievementSystem();
// Lade Achievements
console.log('📋 Lade Achievements...');
await achievementSystem.loadAchievements();
// Teste mit Carsten Graf
const testPlayerId = '313ceee3-8040-44b4-98d2-e63703579e5d';
console.log(`\n👤 Teste mit Spieler: ${testPlayerId}`);
// Zeige aktuelle Punkte
console.log('\n📊 Aktuelle Gesamtpunkte:');
const currentPoints = await achievementSystem.getPlayerTotalPoints(testPlayerId);
console.log(` 🏆 Gesamtpunkte: ${currentPoints.totalPoints}`);
console.log(` 🔢 Gesamt-Completions: ${currentPoints.totalCompletions}`);
// Führe Achievement-Check durch
console.log('\n🎯 Führe Achievement-Check durch...');
const newAchievements = await achievementSystem.checkImmediateAchievements(testPlayerId);
if (newAchievements.length > 0) {
console.log(`\n🏆 ${newAchievements.length} neue Achievements vergeben:`);
newAchievements.forEach(achievement => {
console.log(` ${achievement.icon} ${achievement.name} (+${achievement.points} Punkte)`);
});
} else {
console.log('\n Keine neuen Achievements vergeben');
}
// Zeige neue Gesamtpunkte
console.log('\n📊 Neue Gesamtpunkte:');
const newPoints = await achievementSystem.getPlayerTotalPoints(testPlayerId);
console.log(` 🏆 Gesamtpunkte: ${newPoints.totalPoints} (${newPoints.totalPoints - currentPoints.totalPoints > 0 ? '+' : ''}${newPoints.totalPoints - currentPoints.totalPoints})`);
console.log(` 🔢 Gesamt-Completions: ${newPoints.totalCompletions} (${newPoints.totalCompletions - currentPoints.totalCompletions > 0 ? '+' : ''}${newPoints.totalCompletions - currentPoints.totalCompletions})`);
// Zeige alle Achievements mit Completions
console.log('\n📋 Alle Achievements mit Completions:');
await achievementSystem.loadPlayerAchievements(testPlayerId);
const playerAchievements = achievementSystem.playerAchievements.get(testPlayerId);
if (playerAchievements && playerAchievements.size > 0) {
for (const [achievementId, data] of playerAchievements) {
const achievement = Array.from(achievementSystem.achievements.values())
.find(a => a.id === achievementId);
if (achievement) {
console.log(` ${achievement.icon} ${achievement.name}: ${data.completion_count}x (${data.completion_count * achievement.points} Punkte)`);
}
}
}
console.log('\n✅ Mehrfache Achievement-Test erfolgreich abgeschlossen!');
} catch (error) {
console.error('❌ Test fehlgeschlagen:', error);
process.exit(1);
}
}
// Führe Test aus
testMultipleAchievements();