Make custom entities override built-in entities #2241
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2239. The comments on the
Semigroup
instance forEntityMap
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. TheSemigroup
instance forMap
callsMap.union
, which is left-biased (https://hackage.haskell.org/package/containers-0.7/docs/Data-Map-Lazy.html#t:Map). So we wantn2 <> n1
here instead ofn1 <> n2
, so that the secondEntityMap
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 ford1
; 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 themove
capability.Also had to apply a couple minor fixes to the
pied-piper
scenario, which it turns out tried to define custom entities namedkey
andwall
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 standardkey
(namelypickable
) which the custom one did not have.