diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 45e0fcb..777268e 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -4189,7 +4189,7 @@ class FalukantService extends BaseService { if (user.money - activityObject.cost < 0) { throw new Error('no money'); } - user.character.health -= activityObject.cost; + // Hinweis: health ist ein Status (0..100) und darf nicht mit Geldkosten vermischt werden. const healthChange = await this[activityObject.method](user); await HealthActivity.create({ characterId: user.character.id, @@ -4197,12 +4197,18 @@ class FalukantService extends BaseService { successPercentage: healthChange, cost: activityObject.cost }); - updateFalukantUserMoney(user.id, -activityObject.cost, 'health.' + activity); + const moneyResult = await updateFalukantUserMoney(user.id, -activityObject.cost, 'health.' + activity, user.id); + if (!moneyResult.success) throw new Error('Failed to update money'); // Status-Update Notification senden notifyUser(user.user.hashedId, 'falukantUpdateStatus', {}); - return { success: true }; + // Give client enough info to update UI without ambiguity + const updatedChar = await FalukantCharacter.findOne({ + where: { id: user.character.id }, + attributes: ['health'] + }); + return { success: true, delta: healthChange, health: updatedChar?.health ?? null }; } async healthChange(user, delta) {