Komplettes AdivmentSystem überarbeitet!

This commit is contained in:
2025-09-11 17:07:43 +02:00
parent 28616b3b0c
commit 6d5dc9eb7a
9 changed files with 1087 additions and 16 deletions

View File

@@ -0,0 +1,75 @@
/**
* 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();