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

Make custom entities override built-in entities #2241

Merged
merged 2 commits into from
Dec 28, 2024
Merged

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Dec 28, 2024

Fixes #2239. The comments on the Semigroup instance for EntityMap say "it is possible for the latter 'EntityMap' to override members of the former with the same name. This replacement happens automatically with 'Map'...", however, this was not correct. The Semigroup instance for Map calls Map.union, which is left-biased (https://hackage.haskell.org/package/containers-0.7/docs/Data-Map-Lazy.html#t:Map). So we want n2 <> n1 here instead of n1 <> n2, so that the second EntityMap properly overrides the first.

Note that c1 <> c2 is not correct either, for a more subtle reason. In the case of overrides it needs to be manually adjusted, in a similar way to what is already done for d1; see #2240. I will address that in a separate PR.

The attached scenario will succeed only if the rock entity is properly overridden so that it can provide the move capability.

Also had to apply a couple minor fixes to the pied-piper scenario, which it turns out tried to define custom entities named key and wall which were silently being ignored in preference to the standard entities of the same name; but then the solution inadvertently ended up depending on a property of the standard key (namely pickable) which the custom one did not have.

@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Dec 28, 2024
@mergify mergify bot merged commit 8ff21fe into main Dec 28, 2024
14 checks passed
@mergify mergify bot deleted the fix/issue-2239 branch December 28, 2024 04:45
mergify bot pushed a commit that referenced this pull request Dec 31, 2024
…when there are overridden devices (#2242)

Fixes #2240.  Fixes the `Semigroup EntityMap` instance so that devices which are overridden are removed from the lists of devices providing certain capabilities.

- Also adds a test scenario which generated an incorrect error message before this fix.
- Also adds the test scenario from #2241 to the test suite which was missed previously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Defining custom entities with the same name as an existing built-in entity has no effect
2 participants