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:
@@ -1725,8 +1725,11 @@ class FalukantService extends BaseService {
|
|||||||
throw new Error('noMoodData');
|
throw new Error('noMoodData');
|
||||||
}
|
}
|
||||||
const moodSuitability = moodRecord.suitability;
|
const moodSuitability = moodRecord.suitability;
|
||||||
// Gleiche Berechnung wie im Frontend: (moodValue + highestCharacterValue) / 2
|
// Basis-Berechnung wie im Frontend: (moodValue + highestCharacterValue) / 2
|
||||||
const changeValue = Math.round((moodSuitability + 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 updateFalukantUserMoney(user.id, -cost, 'Gift cost', user.id);
|
||||||
await relation.update({ nextStepProgress: relation.nextStepProgress + changeValue });
|
await relation.update({ nextStepProgress: relation.nextStepProgress + changeValue });
|
||||||
await PromotionalGiftLog.create({
|
await PromotionalGiftLog.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user