Add TitleBenefit model and integrate benefits into FalukantService: Introduced TitleBenefit for managing title-related advantages, including tax exemptions and office eligibility. Updated service methods to utilize these benefits for character reputation, tax distribution, and allowed office types, enhancing gameplay mechanics and user experience.
This commit is contained in:
@@ -45,6 +45,7 @@ import FalukantStockType from './falukant/type/stock.js';
|
||||
import Knowledge from './falukant/data/product_knowledge.js';
|
||||
import ProductType from './falukant/type/product.js';
|
||||
import TitleOfNobility from './falukant/type/title_of_nobility.js';
|
||||
import TitleBenefit from './falukant/type/title_benefit.js';
|
||||
import TitleRequirement from './falukant/type/title_requirement.js';
|
||||
import Branch from './falukant/data/branch.js';
|
||||
import BranchType from './falukant/type/branch.js';
|
||||
@@ -352,6 +353,8 @@ export default function setupAssociations() {
|
||||
|
||||
TitleRequirement.belongsTo(TitleOfNobility, { foreignKey: 'titleId', as: 'title' });
|
||||
TitleOfNobility.hasMany(TitleRequirement, { foreignKey: 'titleId', as: 'requirements' });
|
||||
TitleOfNobility.hasMany(TitleBenefit, { foreignKey: 'titleId', as: 'benefits' });
|
||||
TitleBenefit.belongsTo(TitleOfNobility, { foreignKey: 'titleId', as: 'title' });
|
||||
|
||||
Branch.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(Branch, { foreignKey: 'regionId', as: 'branches' });
|
||||
|
||||
41
backend/models/falukant/type/title_benefit.js
Normal file
41
backend/models/falukant/type/title_benefit.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
/**
|
||||
* Vorteile pro Stand (Adelstitel).
|
||||
* benefit_type: 'tax_share' | 'tax_exempt' | 'office_eligibility' | 'free_party_type' | 'reputation_bonus'
|
||||
* parameters: JSONB, z.B. { officeTypeNames: [] }, { partyTypeIds: [] }, { minPercent: 5, maxPercent: 15 }
|
||||
*/
|
||||
class TitleBenefit extends Model {}
|
||||
|
||||
TitleBenefit.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
titleId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'title_id'
|
||||
},
|
||||
benefitType: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
field: 'benefit_type'
|
||||
},
|
||||
parameters: {
|
||||
type: DataTypes.JSONB,
|
||||
allowNull: true,
|
||||
defaultValue: {}
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'TitleBenefit',
|
||||
tableName: 'title_benefit',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true
|
||||
});
|
||||
|
||||
export default TitleBenefit;
|
||||
@@ -51,6 +51,7 @@ import ProductType from './falukant/type/product.js';
|
||||
import Knowledge from './falukant/data/product_knowledge.js';
|
||||
import TitleRequirement from './falukant/type/title_requirement.js';
|
||||
import TitleOfNobility from './falukant/type/title_of_nobility.js';
|
||||
import TitleBenefit from './falukant/type/title_benefit.js';
|
||||
import BranchType from './falukant/type/branch.js';
|
||||
import Branch from './falukant/data/branch.js';
|
||||
import Production from './falukant/data/production.js';
|
||||
@@ -201,6 +202,7 @@ const models = {
|
||||
ProductType,
|
||||
Knowledge,
|
||||
TitleOfNobility,
|
||||
TitleBenefit,
|
||||
TitleRequirement,
|
||||
BranchType,
|
||||
Branch,
|
||||
|
||||
Reference in New Issue
Block a user