Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency checks can come up with wrong result if the object that has the dependency also modifies the dependency #6

Open
spuxx1701 opened this issue Jun 9, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@spuxx1701
Copy link
Contributor

spuxx1701 commented Jun 9, 2024

If an object that has both a dependency and a modifier targeting the same value, the dependency check will behave differently depending on whether the object has already been added to the owner that will be checked.

An example:

  {
    name: 'character.ability.reflexes-1',
    category: 'character.ability-category.general',
    usageType: 'character.ability-usage-type.passive',
    cost: 300,
    dependencies: [
      {
        name: 'character.primary-attribute.intuition',
        key: 'current',
        value: 12,
      } as Dependency<PrimaryAttribute>,
      {
        name: 'character.secondary-attribute.reaction',
        key: 'total',
        value: 10,
      } as Dependency<SecondaryAttribute>,
    ],
    modifiers: [
      {
        targetName: 'character.secondary-attribute.reaction',
        keys: 'total',
        amount: 4,
      } as Modifier<SecondaryAttribute>,
    ],
  },

Assuming that the new owner is a character that has the object character.secondary-attribute.reaction with a value of 9, the dependency check for the object character.ability.reflexes-1 will fail when the object has not yet been added (9 < 10), but will pass after the object has been added (13 > 10). This doesn't matter if the dependency check prevents the object from being added, but in general, dependency checks should be agnostic to whether they are ran before or after an object has been added to an owner.

We could solve this by making sure that dependency checks ignore modifiers modifying the very same object, but this could pose some engineering challenges I'm not seeing yet. This is where such a check could be implemented: https://github.com/satellite-games/orbit/blob/main/lib/modifier/modifier.ts#L66

I'll leave this open until I know whether this becomes an actual issue.

@spuxx1701 spuxx1701 added the bug Something isn't working label Jun 9, 2024
@spuxx1701 spuxx1701 added this to the v1.0.0 milestone Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant