Add new requirements for nobility titles and enhance service logic: Introduce checks for reputation, house position, house condition, office rank, and lover count in the FalukantService. Update title requirements in the initialization script to include these new criteria. Enhance localization for requirements in English, German, and Spanish, ensuring accurate translations for new conditions.

This commit is contained in:
Torsten Schulz (local)
2026-03-23 10:31:32 +01:00
parent b3607849d2
commit 80d8caee88
8 changed files with 763 additions and 33 deletions

View File

@@ -25,7 +25,7 @@
</p>
<ul class="prerequisites" v-if="next.requirements && next.requirements.length > 0">
<li v-for="req in next.requirements" :key="req.titleId">
{{ $t(`falukant.nobility.requirement.${req.requirementType}`, { amount: formatCost(req.requirementValue) }) }}
{{ formatRequirement(req.requirementType, req.requirementValue) }}
</li>
</ul>
<button v-if="canAdvance" @click="applyAdvance" class="button" :disabled="isAdvancing">
@@ -133,12 +133,7 @@
this.$root.$refs.errorDialog?.open(retryStr ? `${msg}${this.$t('falukant.nobility.cooldown', { date: retryStr })}` : msg);
} else if (resp.data?.message === 'nobilityRequirements') {
const unmet = resp.data?.unmet || [];
const items = unmet.map(u => {
if (u.type === 'money') return this.$t('falukant.nobility.requirement.money', { amount: this.formatCost(u.required) });
if (u.type === 'cost') return this.$t('falukant.nobility.requirement.cost', { amount: this.formatCost(u.required) });
if (u.type === 'branches') return this.$t('falukant.nobility.requirement.branches', { amount: u.required });
return `${u.type}: ${u.required}`;
}).join('\n');
const items = unmet.map(u => this.formatRequirement(u.type, u.required)).join('\n');
const base = this.$t('falukant.nobility.errors.unmet');
this.$root.$refs.errorDialog?.open(`${base}\n${items}`);
} else {
@@ -159,6 +154,37 @@
formatCost(val) {
return new Intl.NumberFormat(navigator.language, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(val);
},
formatRequirement(type, rawValue) {
const numericValue = Number(rawValue);
const amount = ['money', 'cost'].includes(type)
? this.formatCost(numericValue)
: rawValue;
const key = `falukant.nobility.requirement.${type}`;
const translated = this.$t(key, { amount });
if (translated && translated !== key) {
return translated;
}
switch (type) {
case 'money':
return `Vermögen mindestens ${amount}`;
case 'cost':
return `Kosten: ${amount}`;
case 'branches':
return `Mindestens ${amount} Niederlassungen`;
case 'reputation':
return `Beliebtheit mindestens ${amount}`;
case 'house_position':
return `Hausstand mindestens Stufe ${amount}`;
case 'house_condition':
return `Hauszustand mindestens ${amount}`;
case 'office_rank_any':
return `Höchstes politisches oder kirchliches Amt mindestens Rang ${amount}`;
case 'lover_count_max':
return `Höchstens ${amount} Liebhaber oder Mätressen`;
default:
return `${type}: ${amount}`;
}
},
formatDate(isoString) {
const d = new Date(isoString);
const now = new Date();