From 23725c20ee03f22e7d4a08d141e0ffb96fe749b1 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 24 Nov 2025 15:51:27 +0100 Subject: [PATCH] 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. --- backend/services/falukantService.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index fdea1dd..bfe9c73 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -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); // 0–7 inklusive + const changeValue = baseChangeValue + randomBonus; await updateFalukantUserMoney(user.id, -cost, 'Gift cost', user.id); await relation.update({ nextStepProgress: relation.nextStepProgress + changeValue }); await PromotionalGiftLog.create({