Skip to content

Copy component relations between distinct keys on the same entity - #59

Merged
HexDecimal merged 2 commits into
HexDecimal:mainfrom
antonsoo:fix/copy-between-component-relation-keys
Oct 14, 2026
Merged

HexDecimal merged 2 commits into
HexDecimal:mainfrom
antonsoo:fix/copy-between-component-relation-keys

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

Assigning a component relation view to another key on the same entity silently returns without copying:

from tcod.ecs import Registry

world = Registry()
mage, enemy = world["mage"], world["enemy"]
mage.relation_components["fire", int][enemy] = 5
mage.relation_components["poison", int] = mage.relation_components["fire", int]
print(mage.relation_components["poison", int].get(enemy))

This currently prints None; it should print 5. The self-view shortcut checks the owner entity but ignores the component key. Require both to match before treating assignment as a no-op, then reuse the existing replacement path for different keys.

Regression checks cover ordinary/named source keys, removing old destination targets, source preservation and an unchanged copy from another entity. On 36 native combat-effect map configurations, the change corrects 522 wrong target values and the corresponding 522 cached query results. All 18 different-owner controls and every source map remain exactly unchanged. The full pytest/doctest suite, mypy and project-pinned Ruff checks pass, retaining the same baseline xpasses and warning.

This changes only the self-view shortcut. It does not change copying depth, relation storage or the save format.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.16%. Comparing base (a1d4980) to head (e88e94c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #59   +/-   ##
=======================================
  Coverage   99.16%   99.16%           
=======================================
  Files           9        9           
  Lines         956      956           
=======================================
  Hits          948      948           
  Misses          8        8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HexDecimal HexDecimal self-assigned this Oct 14, 2026
@HexDecimal
HexDecimal force-pushed the fix/copy-between-component-relation-keys branch from e232511 to e88e94c Compare October 14, 2026 08:24
@HexDecimal
HexDecimal merged commit 2cd1b19 into HexDecimal:main Oct 14, 2026
12 checks passed
@HexDecimal

Copy link
Copy Markdown
Owner

I've added the missing changelog note. Otherwise this has been another good fix.

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.

2 participants