feat(falukant): enhance reputation handling in character checks
All checks were successful
Deploy to production / deploy (push) Successful in 2m52s
All checks were successful
Deploy to production / deploy (push) Successful in 2m52s
- Added the 'reputation' attribute to the character query in FalukantService, improving data retrieval for nobility requirements. - Refactored the `checkReputationRequirement` method to streamline reputation checks, ensuring it handles undefined or null values more effectively, enhancing reliability in user character evaluations.
This commit is contained in:
@@ -905,7 +905,8 @@ class FalukantService extends BaseService {
|
|||||||
{ model: FalukantPredefineLastname, as: 'definedLastName', attributes: ['name'] },
|
{ model: FalukantPredefineLastname, as: 'definedLastName', attributes: ['name'] },
|
||||||
{ model: TitleOfNobility, as: 'nobleTitle', attributes: ['labelTr', 'id'] }
|
{ 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) {
|
async checkReputationRequirement(user, requirement) {
|
||||||
const character = user.character || await FalukantCharacter.findOne({
|
let rep = user.character?.reputation;
|
||||||
|
if (rep === undefined || rep === null) {
|
||||||
|
const row = await FalukantCharacter.findOne({
|
||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
attributes: ['reputation']
|
attributes: ['reputation']
|
||||||
});
|
});
|
||||||
return Number(character?.reputation || 0) >= Number(requirement.requirementValue || 0);
|
rep = row?.reputation;
|
||||||
|
}
|
||||||
|
return Number(rep ?? 0) >= Number(requirement.requirementValue || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkHousePositionRequirement(user, requirement) {
|
async checkHousePositionRequirement(user, requirement) {
|
||||||
|
|||||||
Reference in New Issue
Block a user