feat(politics): add new political office benefits and enhance database migration
All checks were successful
Deploy to production / deploy (push) Successful in 2m54s
All checks were successful
Deploy to production / deploy (push) Successful in 2m54s
- Introduced new benefits including 'reputation_periodic', 'appoint_politicians', 'set_regional_tax', 'free_lover_slots', 'guard_protection', and 'court_immunity' to the political office system. - Updated database migration to add and remove the 'last_political_daily_salary_on' column using SQL queries for better performance. - Enhanced localization files for multiple languages to support new benefits, improving user experience across the application. - Updated UI components to display new benefits correctly in the PoliticsView, ensuring accurate representation of political office functionalities.
This commit is contained in:
@@ -356,6 +356,7 @@ const politicalOfficeBenefitTypes = [
|
||||
{ tr: 'salary' },
|
||||
{ tr: 'daily_salary' },
|
||||
{ tr: 'reputation' },
|
||||
{ tr: 'reputation_periodic' },
|
||||
{ tr: 'influence' },
|
||||
{ tr: 'access_level' },
|
||||
{ tr: 'housing_allowance' },
|
||||
@@ -363,6 +364,60 @@ const politicalOfficeBenefitTypes = [
|
||||
{ tr: 'guard_protection' },
|
||||
{ tr: 'court_immunity' },
|
||||
{ tr: 'set_regionl_tax' },
|
||||
{ tr: 'set_regional_tax' },
|
||||
{ tr: 'appoint_politicians' },
|
||||
{ tr: 'free_lover_slots' },
|
||||
];
|
||||
|
||||
/** Zusätzliche Amtsvorteile (Anzeige; Spielmechanik z. T. noch offen). SQL-Pendant: backend/sql/falukant_political_office_extra_benefits.sql */
|
||||
const politicalOfficeExtraBenefitSeeds = [
|
||||
{ officeTr: 'assessor', benefitTr: 'reputation_periodic', value: { intervalDays: 28, gain: 1 } },
|
||||
{ officeTr: 'master-builder', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 1 } },
|
||||
{ officeTr: 'village-major', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 1 } },
|
||||
{ officeTr: 'councillor', benefitTr: 'reputation_periodic', value: { intervalDays: 28, gain: 1 } },
|
||||
{ officeTr: 'council', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 1 } },
|
||||
{ officeTr: 'mayor', benefitTr: 'reputation_periodic', value: { intervalDays: 14, gain: 2 } },
|
||||
{ officeTr: 'town-clerk', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 1 } },
|
||||
{ officeTr: 'judge', benefitTr: 'reputation_periodic', value: { intervalDays: 14, gain: 2 } },
|
||||
{ officeTr: 'bailif', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 1 } },
|
||||
{ officeTr: 'sheriff', benefitTr: 'reputation_periodic', value: { intervalDays: 14, gain: 2 } },
|
||||
{ officeTr: 'taxman', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 2 } },
|
||||
{ officeTr: 'treasurer', benefitTr: 'reputation_periodic', value: { intervalDays: 14, gain: 3 } },
|
||||
{ officeTr: 'consultant', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 2 } },
|
||||
{ officeTr: 'hangman', benefitTr: 'reputation_periodic', value: { intervalDays: 21, gain: 1 } },
|
||||
{ officeTr: 'territorial-council', benefitTr: 'reputation_periodic', value: { intervalDays: 14, gain: 2 } },
|
||||
{ officeTr: 'territorial-council-speaker', benefitTr: 'reputation_periodic', value: { intervalDays: 10, gain: 3 } },
|
||||
{ officeTr: 'ruler-consultant', benefitTr: 'reputation_periodic', value: { intervalDays: 10, gain: 3 } },
|
||||
{ officeTr: 'state-administrator', benefitTr: 'reputation_periodic', value: { intervalDays: 10, gain: 3 } },
|
||||
{ officeTr: 'super-state-administrator', benefitTr: 'reputation_periodic', value: { intervalDays: 7, gain: 4 } },
|
||||
{ officeTr: 'governor', benefitTr: 'reputation_periodic', value: { intervalDays: 7, gain: 4 } },
|
||||
{ officeTr: 'minister', benefitTr: 'reputation_periodic', value: { intervalDays: 10, gain: 3 } },
|
||||
{ officeTr: 'ministry-helper', benefitTr: 'reputation_periodic', value: { intervalDays: 14, gain: 2 } },
|
||||
{ officeTr: 'chancellor', benefitTr: 'reputation_periodic', value: { intervalDays: 7, gain: 5 } },
|
||||
|
||||
{ officeTr: 'mayor', benefitTr: 'appoint_politicians', value: { officeTrs: ['beadle', 'town-clerk'] } },
|
||||
{ officeTr: 'judge', benefitTr: 'appoint_politicians', value: { officeTrs: ['bailif'] } },
|
||||
{ officeTr: 'governor', benefitTr: 'appoint_politicians', value: { officeTrs: ['state-administrator', 'consultant'] } },
|
||||
{ officeTr: 'super-state-administrator', benefitTr: 'appoint_politicians', value: { officeTrs: ['territorial-council', 'hangman'] } },
|
||||
{ officeTr: 'chancellor', benefitTr: 'appoint_politicians', value: { officeTrs: ['minister', 'ministry-helper', 'super-state-administrator'] } },
|
||||
|
||||
{ officeTr: 'taxman', benefitTr: 'set_regional_tax', value: { scope: 'local' } },
|
||||
{ officeTr: 'treasurer', benefitTr: 'set_regional_tax', value: { scope: 'shire' } },
|
||||
{ officeTr: 'super-state-administrator', benefitTr: 'set_regional_tax', value: { scope: 'duchy' } },
|
||||
{ officeTr: 'chancellor', benefitTr: 'set_regional_tax', value: { scope: 'national' } },
|
||||
|
||||
{ officeTr: 'councillor', benefitTr: 'free_lover_slots', value: { count: 1 } },
|
||||
{ officeTr: 'mayor', benefitTr: 'free_lover_slots', value: { count: 1 } },
|
||||
{ officeTr: 'minister', benefitTr: 'free_lover_slots', value: { count: 1 } },
|
||||
{ officeTr: 'governor', benefitTr: 'free_lover_slots', value: { count: 2 } },
|
||||
{ officeTr: 'chancellor', benefitTr: 'free_lover_slots', value: { count: 3 } },
|
||||
|
||||
{ officeTr: 'sheriff', benefitTr: 'guard_protection', value: {} },
|
||||
{ officeTr: 'hangman', benefitTr: 'guard_protection', value: {} },
|
||||
{ officeTr: 'minister', benefitTr: 'guard_protection', value: {} },
|
||||
{ officeTr: 'judge', benefitTr: 'court_immunity', value: {} },
|
||||
{ officeTr: 'councillor', benefitTr: 'court_immunity', value: {} },
|
||||
{ officeTr: 'chancellor', benefitTr: 'court_immunity', value: {} },
|
||||
];
|
||||
|
||||
const politicalOffices = [
|
||||
@@ -1092,8 +1147,24 @@ export const initializePoliticalOfficeBenefits = async () => {
|
||||
if (wasCreated) dailyCreated += 1;
|
||||
}
|
||||
|
||||
let extraCreated = 0;
|
||||
for (const { officeTr, benefitTr, value } of politicalOfficeExtraBenefitSeeds) {
|
||||
const office = await PoliticalOfficeType.findOne({ where: { name: officeTr } });
|
||||
const bType = await PoliticalOfficeBenefitType.findOne({ where: { tr: benefitTr } });
|
||||
if (!office || !bType) continue;
|
||||
const [, wasCreated] = await PoliticalOfficeBenefit.findOrCreate({
|
||||
where: { officeTypeId: office.id, benefitTypeId: bType.id },
|
||||
defaults: {
|
||||
officeTypeId: office.id,
|
||||
benefitTypeId: bType.id,
|
||||
value: value && typeof value === 'object' ? value : {}
|
||||
}
|
||||
});
|
||||
if (wasCreated) extraCreated += 1;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[Falukant] PoliticalOfficeBenefits: Steuer neu=${taxCreated}, Tageslohn neu=${dailyCreated} (gesamt Ämter=${allOffices.length})`
|
||||
`[Falukant] PoliticalOfficeBenefits: Steuer neu=${taxCreated}, Tageslohn neu=${dailyCreated}, weitere Vorteile neu=${extraCreated} (Ämter gesamt=${allOffices.length})`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user