feat(political-benefits): implement political powers and benefits system
All checks were successful
Deploy to production / deploy (push) Successful in 3m3s
All checks were successful
Deploy to production / deploy (push) Successful in 3m3s
- Added new political powers and benefits functionalities, including reputation ticks, tax jurisdiction management, and appointment capabilities. - Introduced a new job for periodic reputation updates and created necessary database tables for tracking political benefits. - Enhanced the FalukantController and services to support new endpoints for managing political powers and appointments. - Updated localization files to reflect new features and improve user experience across multiple languages. - Modified the UI to display new political powers and benefits, ensuring accurate representation in the PoliticsView.
This commit is contained in:
@@ -94,6 +94,9 @@ import Candidate from './falukant/data/candidate.js';
|
||||
import Vote from './falukant/data/vote.js';
|
||||
import PoliticalOfficeType from './falukant/type/political_office_type.js';
|
||||
import PoliticalOffice from './falukant/data/political_office.js';
|
||||
import PoliticalBenefitLastTick from './falukant/data/political_benefit_last_tick.js';
|
||||
import RegionTaxHistory from './falukant/data/region_tax_history.js';
|
||||
import PoliticalAppointment from './falukant/data/political_appointment.js';
|
||||
import PoliticalOfficeBenefit from './falukant/predefine/political_office_benefit.js';
|
||||
import PoliticalOfficeBenefitType from './falukant/type/political_office_benefit_type.js';
|
||||
import PoliticalOfficeRequirement from './falukant/predefine/political_office_prerequisite.js';
|
||||
@@ -792,6 +795,48 @@ export default function setupAssociations() {
|
||||
as: 'heldOffice'
|
||||
});
|
||||
|
||||
PoliticalBenefitLastTick.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(PoliticalBenefitLastTick, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'politicalBenefitTicks'
|
||||
});
|
||||
PoliticalBenefitLastTick.belongsTo(PoliticalOfficeBenefit, {
|
||||
foreignKey: 'politicalOfficeBenefitId',
|
||||
as: 'officeBenefit'
|
||||
});
|
||||
|
||||
RegionTaxHistory.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(RegionTaxHistory, { foreignKey: 'regionId', as: 'taxHistory' });
|
||||
RegionTaxHistory.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'setterCharacterId',
|
||||
as: 'setterCharacter'
|
||||
});
|
||||
RegionTaxHistory.belongsTo(PoliticalOffice, {
|
||||
foreignKey: 'politicalOfficeId',
|
||||
as: 'sourceOffice'
|
||||
});
|
||||
|
||||
PoliticalAppointment.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'appointerCharacterId',
|
||||
as: 'appointer'
|
||||
});
|
||||
PoliticalAppointment.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'targetCharacterId',
|
||||
as: 'targetCharacter'
|
||||
});
|
||||
PoliticalAppointment.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalAppointment.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
PoliticalAppointment.belongsTo(PoliticalOffice, {
|
||||
foreignKey: 'completedPoliticalOfficeId',
|
||||
as: 'completedOffice'
|
||||
});
|
||||
|
||||
// elections
|
||||
Election.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
|
||||
56
backend/models/falukant/data/political_appointment.js
Normal file
56
backend/models/falukant/data/political_appointment.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PoliticalAppointment extends Model {}
|
||||
|
||||
PoliticalAppointment.init(
|
||||
{
|
||||
appointerCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'appointer_character_id'
|
||||
},
|
||||
targetCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'target_character_id'
|
||||
},
|
||||
officeTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'office_type_id'
|
||||
},
|
||||
regionId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'region_id'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.STRING(32),
|
||||
allowNull: false,
|
||||
defaultValue: 'completed'
|
||||
},
|
||||
expiresAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
field: 'expires_at'
|
||||
},
|
||||
completedPoliticalOfficeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
field: 'completed_political_office_id'
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'PoliticalAppointment',
|
||||
tableName: 'political_appointment',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: false,
|
||||
underscored: true
|
||||
}
|
||||
);
|
||||
|
||||
export default PoliticalAppointment;
|
||||
40
backend/models/falukant/data/political_benefit_last_tick.js
Normal file
40
backend/models/falukant/data/political_benefit_last_tick.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PoliticalBenefitLastTick extends Model {}
|
||||
|
||||
PoliticalBenefitLastTick.init(
|
||||
{
|
||||
characterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'character_id'
|
||||
},
|
||||
politicalOfficeBenefitId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'political_office_benefit_id'
|
||||
},
|
||||
lastTickAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
field: 'last_tick_at'
|
||||
},
|
||||
ticksCount: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'ticks_count'
|
||||
}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'PoliticalBenefitLastTick',
|
||||
tableName: 'political_benefit_last_tick',
|
||||
schema: 'falukant_data',
|
||||
timestamps: false,
|
||||
underscored: true
|
||||
}
|
||||
);
|
||||
|
||||
export default PoliticalBenefitLastTick;
|
||||
46
backend/models/falukant/data/region_tax_history.js
Normal file
46
backend/models/falukant/data/region_tax_history.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class RegionTaxHistory extends Model {}
|
||||
|
||||
RegionTaxHistory.init(
|
||||
{
|
||||
regionId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'region_id'
|
||||
},
|
||||
oldTaxPercent: {
|
||||
type: DataTypes.DECIMAL(12, 4),
|
||||
allowNull: false,
|
||||
field: 'old_tax_percent'
|
||||
},
|
||||
newTaxPercent: {
|
||||
type: DataTypes.DECIMAL(12, 4),
|
||||
allowNull: false,
|
||||
field: 'new_tax_percent'
|
||||
},
|
||||
setterCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'setter_character_id'
|
||||
},
|
||||
politicalOfficeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
field: 'political_office_id'
|
||||
}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'RegionTaxHistory',
|
||||
tableName: 'region_tax_history',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: false,
|
||||
underscored: true
|
||||
}
|
||||
);
|
||||
|
||||
export default RegionTaxHistory;
|
||||
@@ -116,6 +116,9 @@ import PoliticalOfficeRequirement from './falukant/predefine/political_office_pr
|
||||
import PoliticalOfficeBenefitType from './falukant/type/political_office_benefit_type.js';
|
||||
import PoliticalOfficeBenefit from './falukant/predefine/political_office_benefit.js';
|
||||
import PoliticalOffice from './falukant/data/political_office.js';
|
||||
import PoliticalBenefitLastTick from './falukant/data/political_benefit_last_tick.js';
|
||||
import RegionTaxHistory from './falukant/data/region_tax_history.js';
|
||||
import PoliticalAppointment from './falukant/data/political_appointment.js';
|
||||
import Election from './falukant/data/election.js';
|
||||
import Candidate from './falukant/data/candidate.js';
|
||||
import Vote from './falukant/data/vote.js';
|
||||
@@ -262,6 +265,9 @@ const models = {
|
||||
PoliticalOfficeBenefitType,
|
||||
PoliticalOfficeBenefit,
|
||||
PoliticalOffice,
|
||||
PoliticalBenefitLastTick,
|
||||
RegionTaxHistory,
|
||||
PoliticalAppointment,
|
||||
Election,
|
||||
Candidate,
|
||||
Vote,
|
||||
|
||||
Reference in New Issue
Block a user