Enhance mood change calculation in FalukantService

- Updated the mood change calculation to include a random bonus between 0 and 7 points, improving variability in user experience.
- Refactored the calculation logic for clarity, separating the base change value from the random bonus.
This commit is contained in:
Torsten Schulz (local)
2025-11-24 15:51:27 +01:00
parent 29b6db7ee9
commit 23725c20ee

View File

@@ -1725,8 +1725,11 @@ class FalukantService extends BaseService {
throw new Error('noMoodData');
}
const moodSuitability = moodRecord.suitability;
// Gleiche Berechnung wie im Frontend: (moodValue + highestCharacterValue) / 2
const changeValue = Math.round((moodSuitability + highestCharacterValue) / 2);
// Basis-Berechnung wie im Frontend: (moodValue + highestCharacterValue) / 2
const baseChangeValue = Math.round((moodSuitability + highestCharacterValue) / 2);
// Zusätzlicher zufälliger Bonus zwischen 0 und 7 Punkten
const randomBonus = Math.floor(Math.random() * 8); // 07 inklusive
const changeValue = baseChangeValue + randomBonus;
await updateFalukantUserMoney(user.id, -cost, 'Gift cost', user.id);
await relation.update({ nextStepProgress: relation.nextStepProgress + changeValue });
await PromotionalGiftLog.create({