Ergänze individuelle Charakterentwicklung und klare Hochzeitshinweise
Some checks failed
Deploy to production / deploy (push) Failing after 1m18s

This commit is contained in:
Torsten Schulz (local)
2026-11-04 14:16:11 +01:00
parent fddb97b385
commit 343bf64115
13 changed files with 350 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ import FalukantPredefineFirstname from '../models/falukant/predefine/firstname.j
import FalukantPredefineLastname from '../models/falukant/predefine/lastname.js';
import FalukantUser from '../models/falukant/data/user.js';
import FalukantCharacter from '../models/falukant/data/character.js';
import { getCharacterDevelopment, hasReachedFertility } from '../utils/falukant/characterDevelopment.js';
import RegionData from '../models/falukant/data/region.js';
import RegionType from '../models/falukant/type/region.js';
import FalukantStock from '../models/falukant/data/stock.js';
@@ -96,7 +97,6 @@ function calcAge(birthdate) {
const FAMILY_AGE = Object.freeze({
MIN_WOOING: 10,
MIN_MARRIAGE: 14,
MIN_HOUSEHOLD_AND_CHILDREN: 14,
});
async function getFalukantUserOrFail(hashedId) {
@@ -979,7 +979,7 @@ class FalukantService extends BaseService {
{ model: TitleOfNobility, as: 'nobleTitle', attributes: ['labelTr', 'id', 'level'] }
],
// reputation: für Adel-Voraussetzungen u.a. (checkReputationRequirement nutzt user.character ohne Nachladen)
attributes: ['id', 'birthdate', 'gender', 'moodId', 'health', 'reputation']
attributes: ['id', 'birthdate', 'gender', 'moodId', 'health', 'reputation', 'pubertyStartAge', 'fertileFromAge']
},
]
});
@@ -1141,7 +1141,7 @@ class FalukantService extends BaseService {
{
model: FalukantCharacter,
as: 'character',
attributes: ['id', 'birthdate', 'health', 'reputation', 'titleOfNobility'],
attributes: ['id', 'birthdate', 'health', 'reputation', 'titleOfNobility', 'pubertyStartAge', 'fertileFromAge'],
include: [
{ model: FalukantPredefineFirstname, as: 'definedFirstName', attributes: ['name'] },
{ model: FalukantPredefineLastname, as: 'definedLastName', attributes: ['name'] },
@@ -3649,11 +3649,11 @@ class FalukantService extends BaseService {
const parents = await FalukantCharacter.unscoped().findAll({
where: { id: [motherId, fatherId] },
attributes: ['id', 'birthdate'],
attributes: ['id', 'birthdate', 'fertileFromAge'],
});
if (
parents.length !== 2
|| parents.some((parent) => calcAge(parent.birthdate) < FAMILY_AGE.MIN_HOUSEHOLD_AND_CHILDREN)
|| parents.some((parent) => !hasReachedFertility(parent, calcAge(parent.birthdate)))
) {
return { scheduled: false };
}
@@ -3733,7 +3733,7 @@ class FalukantService extends BaseService {
RelationshipType.findAll({ where: { id: typeIds }, attributes: ['id', 'tr'] }),
FalukantCharacter.findAll({
where: { id: char2Ids },
attributes: ['id', 'birthdate', 'gender', 'moodId'],
attributes: ['id', 'birthdate', 'gender', 'moodId', 'pubertyStartAge', 'fertileFromAge'],
include: [
{ model: FalukantPredefineFirstname, as: 'definedFirstName', attributes: ['name'] },
{ model: TitleOfNobility, as: 'nobleTitle', attributes: ['labelTr'] },
@@ -3774,6 +3774,7 @@ class FalukantService extends BaseService {
character2: c2 ? {
id: c2.id,
age: calcAge(c2.birthdate),
development: getCharacterDevelopment(c2, calcAge(c2.birthdate)),
gender: c2.gender,
firstName: c2.definedFirstName?.name || 'Unknown',
nobleTitle: c2.nobleTitle?.labelTr || '',
@@ -3820,7 +3821,7 @@ class FalukantService extends BaseService {
const childChars = childCharIds.length
? await FalukantCharacter.findAll({
where: { id: childCharIds },
attributes: ['id', 'birthdate', 'gender', 'regionId', 'titleOfNobility'],
attributes: ['id', 'birthdate', 'gender', 'regionId', 'titleOfNobility', 'pubertyStartAge', 'fertileFromAge'],
include: [{ model: FalukantPredefineFirstname, as: 'definedFirstName', attributes: ['name'] }]
})
: [];
@@ -3882,6 +3883,7 @@ class FalukantService extends BaseService {
name: kid?.definedFirstName?.name || 'Unknown',
gender: kid?.gender,
age: kid?.birthdate ? calcAge(kid.birthdate) : null,
development: getCharacterDevelopment(kid, kid?.birthdate ? calcAge(kid.birthdate) : null),
hasName: rel.nameSet,
isHeir: rel.isHeir || false,
legitimacy: rel.legitimacy || 'legitimate',
@@ -3998,8 +4000,13 @@ class FalukantService extends BaseService {
label: baseTension.label
};
const family = {
development: getCharacterDevelopment(character, calcAge(character.birthdate)),
minMarriageAge: FAMILY_AGE.MIN_MARRIAGE,
relationships: activeRelationships.map((r) => ({
...r,
canCelebrateWedding: r.relationshipType === 'engaged'
&& calcAge(character.birthdate) >= FAMILY_AGE.MIN_MARRIAGE
&& r.character2?.age >= FAMILY_AGE.MIN_MARRIAGE,
marriageSatisfaction: r.relationshipType === 'married'
? (r.state?.marriageSatisfaction ?? 100)
: null,
@@ -5739,7 +5746,7 @@ class FalukantService extends BaseService {
});
const musicTypes = await MusicType.findAll();
const banquetteTypes = await BanquetteType.findAll();
return { partyTypes, musicTypes, banquetteTypes, weddingCandidates };
return { partyTypes, musicTypes, banquetteTypes, weddingCandidates, minMarriageAge: FAMILY_AGE.MIN_MARRIAGE };
}
async createParty(hashedUserId, partyTypeId, musicId, banquetteId, nobilityIds = [], servantRatio, relationshipId = null) {