Enhance NobilityView with new house position and condition formatting: Introduce methods to format house position labels and house condition descriptions based on numeric values. Update requirement translations to utilize these new methods for improved clarity and localization.
This commit is contained in:
@@ -13,6 +13,14 @@
|
||||
{{ $t(`falukant.titles.${gender}.${current.labelTr}`) }}
|
||||
</strong>
|
||||
</p>
|
||||
<p>
|
||||
{{ $t('falukant.nobility.highestPoliticalOffice') }}:
|
||||
<strong>{{ formatOfficeInfo(highestPoliticalOffice, 'political') }}</strong>
|
||||
</p>
|
||||
<p>
|
||||
{{ $t('falukant.nobility.highestOfficeAny') }}:
|
||||
<strong>{{ formatOfficeInfo(highestOfficeAny, highestOfficeAny?.source) }}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -63,6 +71,8 @@
|
||||
],
|
||||
current: { labelTr: '', requirements: [], charactersWithNobleTitle: [] },
|
||||
next: { labelTr: '', requirements: [] },
|
||||
highestPoliticalOffice: null,
|
||||
highestOfficeAny: null,
|
||||
nextAdvanceAt: null,
|
||||
isAdvancing: false
|
||||
};
|
||||
@@ -111,6 +121,8 @@
|
||||
const { data } = await apiClient.get('/api/falukant/nobility');
|
||||
this.current = data.current || { labelTr: '', requirements: [], charactersWithNobleTitle: [] };
|
||||
this.next = data.next || { labelTr: '', requirements: [] };
|
||||
this.highestPoliticalOffice = data.highestPoliticalOffice || null;
|
||||
this.highestOfficeAny = data.highestOfficeAny || null;
|
||||
this.nextAdvanceAt = data.nextAdvanceAt || null;
|
||||
} catch (err) {
|
||||
console.error('Error loading nobility:', err);
|
||||
@@ -161,7 +173,7 @@
|
||||
: rawValue;
|
||||
const key = `falukant.nobility.requirement.${type}`;
|
||||
const translated = this.$t(key, { amount });
|
||||
if (translated && translated !== key) {
|
||||
if (translated && translated !== key && !['house_position', 'house_condition'].includes(type)) {
|
||||
return translated;
|
||||
}
|
||||
switch (type) {
|
||||
@@ -174,17 +186,54 @@
|
||||
case 'reputation':
|
||||
return `Beliebtheit mindestens ${amount}`;
|
||||
case 'house_position':
|
||||
return `Hausstand mindestens Stufe ${amount}`;
|
||||
return `Hausstand mindestens ${this.getHousePositionLabel(numericValue)}`;
|
||||
case 'house_condition':
|
||||
return `Hauszustand mindestens ${amount}`;
|
||||
return `Hauszustand mindestens ${this.formatHouseCondition(numericValue)}`;
|
||||
case 'office_rank_any':
|
||||
return `Höchstes politisches oder kirchliches Amt mindestens Rang ${amount}`;
|
||||
case 'office_rank_political':
|
||||
return `Höchstes politisches Amt mindestens Rang ${amount}`;
|
||||
case 'lover_count_min':
|
||||
return `Mindestens ${amount} Liebhaber oder Mätressen`;
|
||||
case 'lover_count_max':
|
||||
return `Höchstens ${amount} Liebhaber oder Mätressen`;
|
||||
default:
|
||||
return `${type}: ${amount}`;
|
||||
}
|
||||
},
|
||||
formatOfficeInfo(info, source) {
|
||||
if (!info?.name) {
|
||||
return this.$t('falukant.nobility.none');
|
||||
}
|
||||
const baseKey = source === 'church' ? 'falukant.church.offices' : 'falukant.politics.positions';
|
||||
const label = this.$te(`${baseKey}.${info.name}`) ? this.$t(`${baseKey}.${info.name}`) : info.name;
|
||||
return `${label} (Rang ${info.rank})`;
|
||||
},
|
||||
getHousePositionLabel(position) {
|
||||
const labels = {
|
||||
1: 'Unter der Brücke',
|
||||
2: 'eine Strohhütte',
|
||||
3: 'ein Holzhaus',
|
||||
4: 'ein Hinterhofzimmer',
|
||||
5: 'ein kleines Familienhaus',
|
||||
6: 'ein Stadthaus',
|
||||
7: 'eine Villa',
|
||||
8: 'ein Herrenhaus',
|
||||
9: 'ein Schloss'
|
||||
};
|
||||
return labels[position] || `Haus-Stufe ${position}`;
|
||||
},
|
||||
formatHouseCondition(value) {
|
||||
if (Number.isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value >= 0.95) return 'nahezu makellos';
|
||||
if (value >= 0.9) return 'sehr gut';
|
||||
if (value >= 0.8) return 'gut';
|
||||
if (value >= 0.7) return 'ordentlich';
|
||||
if (value >= 0.6) return 'brauchbar';
|
||||
return `${Math.round(value * 100)} %`;
|
||||
},
|
||||
formatDate(isoString) {
|
||||
const d = new Date(isoString);
|
||||
const now = new Date();
|
||||
|
||||
Reference in New Issue
Block a user