Skip to content

Implement global attributes for GameConfiguration to replace per-class MoneyAmountRate#712

Merged
sven-n merged 4 commits intomasterfrom
copilot/refactor-money-drop-rate-implementation
Mar 20, 2026
Merged

Implement global attributes for GameConfiguration to replace per-class MoneyAmountRate#712
sven-n merged 4 commits intomasterfrom
copilot/refactor-money-drop-rate-implementation

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Replaces the per-character-class MoneyAmountRate base attribute with a global attribute system on GameConfiguration, making it configurable once for all characters rather than duplicated across every class.

Data Model

  • Added GlobalAttributeCombinations (ICollection<AttributeRelationship>) and GlobalBaseAttributeValues (ICollection<ConstValueAttribute>) to GameConfiguration, both marked [MemberOfAggregate]
  • Regenerated EF Core and BasicModel persistence files to include the new collections

Persistence / EF

  • ConstValueAttribute.CharacterClassId made nullable (was required) — values now belong to either a CharacterClass or GameConfiguration
  • Added nullable GameConfigurationId FK to ConstValueAttribute and AttributeRelationship
  • New migration AddGlobalAttributes applies the schema changes
  • Added ApplyGlobalAttributes() extension on EntityTypeBuilder<GameConfiguration> to wire the cascade-delete relationship for GlobalBaseAttributeValues

Game Logic

ItemAwareAttributeSystem now accepts GameConfiguration and concatenates global collections into the attribute system:

public ItemAwareAttributeSystem(Account account, Character character, GameConfiguration gameConfiguration)
    : base(
        character.Attributes.Concat(account.Attributes),
        character.CharacterClass!.BaseAttributeValues.Concat(gameConfiguration.GlobalBaseAttributeValues),
        character.CharacterClass.AttributeCombinations.Concat(gameConfiguration.GlobalAttributeCombinations))

Player passes this.GameContext.Configuration at construction time.

Initialization

  • GameConfigurationInitializerBase initializes MoneyAmountRate = 1f in GlobalBaseAttributeValues for all new data sets
  • Removed MoneyAmountRate from CharacterClassInitialization.AddCommonBaseAttributeValues (no longer per-class)
  • Three update plugins (075, 095d, Season6) migrate existing data: add the global attribute and remove per-class duplicates
Original prompt

This section details on the original issue you should resolve

<issue_title>Implement Global Attributes for the Money Drop Rate Implementation (see #661)</issue_title>
<issue_description>## Summary
PR #661 introduces a MoneyDropRate property on GameConfiguration to control money drop scaling.
We want to replace this dedicated property with a more flexible and consistent solution using a global attribute system.

Motivation

OpenMU already uses a powerful attribute system for character classes.
Extending this system to a global configuration avoids adding more one‑off properties and keeps the design consistent. Additionally, common attributes don't have to be configured on every character class anymore.

Task Description

Refactor the money drop rate implementation so that it is controlled via global attributes rather than a standalone configuration property.

Required Changes

1. Add Global Attribute Collections to GameConfiguration

Introduce the following collections (mirroring CharacterClass):

/// <summary>
/// Gets or sets the attribute combinations.
/// </summary>
[MemberOfAggregate]
public virtual ICollection<AttributeRelationship> GlobalAttributeCombinations { get; protected set; } = null!;

/// <summary>
/// Gets or sets the base attribute values.
/// </summary>
[MemberOfAggregate]
public virtual ICollection<ConstValueAttribute> GlobalBaseAttributeValues { get; protected set; } = null!;

These apply globally to all characters, independent of class.

2. Add a Global Base Attribute for Money Drop Rate

Add a ConstValueAttribute for:

Stats.MoneyAmountRate

to GlobalBaseAttributeValues.

Note: Stats.MoneyAmountRate already exists — no new stat definition is required.

It has to be added to the Persistence Initialization project for each game season. An configuration update plugin is required as well.

3. Update Game Logic

When creating the ItemAwareAttributeSystem for a Player instance, concat the introduced collections.

4. Remove the Old Implementation

Acceptance Criteria

  • Money drop rate is fully controlled via global attributes
  • No dedicated MoneyDropRate property required to fulfil the user requirement
  • Code structure matches the existing attribute patterns
  • All initializers and tests are updated accordingly
    </issue_description>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Refactor money drop rate to use global attributes Implement global attributes for GameConfiguration to replace per-class MoneyAmountRate Mar 20, 2026
Copilot AI requested a review from sven-n March 20, 2026 21:34
@sven-n sven-n marked this pull request as ready for review March 20, 2026 22:05
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant architectural improvement by replacing a per-character-class attribute with a more flexible and consistent global attribute system. The primary motivation is to centralize common attributes, such as the money drop rate, at the game configuration level, thereby reducing duplication and simplifying future attribute management. This change enhances the extensibility of the attribute system and streamlines game balance adjustments.

Highlights

  • Global Attribute System: Implemented a global attribute system on GameConfiguration by adding GlobalAttributeCombinations and GlobalBaseAttributeValues collections. This centralizes attributes that apply to all characters, moving away from per-character-class configurations.
  • MoneyAmountRate Refactoring: The MoneyAmountRate attribute, previously configured per character class, has been refactored to be a global attribute within the new system. This simplifies its management and ensures consistency across all character types.
  • Persistence Layer Updates: Modified the persistence layer to support the new global attributes. This includes making ConstValueAttribute.CharacterClassId nullable, adding GameConfigurationId foreign keys to ConstValueAttribute and AttributeRelationship, and generating a new EF Core migration (AddGlobalAttributes).
  • Game Logic Integration: Updated the ItemAwareAttributeSystem constructor to accept GameConfiguration and concatenate the global attribute collections, ensuring that global attributes are correctly applied to player characters.
  • Data Migration and Initialization: Developed three update plugins (075, 095d, Season6) to migrate existing data, moving MoneyAmountRate from individual character classes to the global configuration. New game configurations will initialize MoneyAmountRate as a global attribute.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully implements the global attribute system for MoneyAmountRate, replacing the previous per-class configuration. The changes are consistent across data models, persistence, game logic, and initialization. The migration and update plugins correctly handle the schema changes and data migration. The test helper has also been updated to reflect these changes.

public override bool IsMandatory => true;

/// <inheritdoc />
public override DateTime CreatedAt => new(2026, 03, 20, 20, 0, 0, DateTimeKind.Utc);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The CreatedAt property is set to a future date (2026, 03, 20). While this might be a placeholder, it's generally good practice to use the actual creation date of the update or the date it's intended to be released. Please update this to an appropriate past or current date.

@sven-n sven-n merged commit cfe526f into master Mar 20, 2026
3 checks passed
@sven-n sven-n deleted the copilot/refactor-money-drop-rate-implementation branch March 20, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Global Attributes for the Money Drop Rate Implementation (see #661)

2 participants