diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 9092b7c..6dbe06d 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -905,7 +905,8 @@ class FalukantService extends BaseService { { model: FalukantPredefineLastname, as: 'definedLastName', attributes: ['name'] }, { model: TitleOfNobility, as: 'nobleTitle', attributes: ['labelTr', 'id'] } ], - attributes: ['id', 'birthdate', 'gender', 'moodId', 'health'] + // reputation: für Adel-Voraussetzungen u.a. (checkReputationRequirement nutzt user.character ohne Nachladen) + attributes: ['id', 'birthdate', 'gender', 'moodId', 'health', 'reputation'] }, ] }); @@ -5905,11 +5906,15 @@ class FalukantService extends BaseService { } async checkReputationRequirement(user, requirement) { - const character = user.character || await FalukantCharacter.findOne({ - where: { userId: user.id }, - attributes: ['reputation'] - }); - return Number(character?.reputation || 0) >= Number(requirement.requirementValue || 0); + let rep = user.character?.reputation; + if (rep === undefined || rep === null) { + const row = await FalukantCharacter.findOne({ + where: { userId: user.id }, + attributes: ['reputation'] + }); + rep = row?.reputation; + } + return Number(rep ?? 0) >= Number(requirement.requirementValue || 0); } async checkHousePositionRequirement(user, requirement) {