Anyone have a general design pattern for when you have multiple objects that have overlapping vocabulary and, specifically, want specific objects to be the default in individual complex situations?
The specific design case I’m thinking about is with playing cards, where “cards” might refer to the deck of cards (>SHUFFLE CARDS
), the player’s hand (>X CARDS
when the player is holding them), or might be abstract and not refer to a specific in-game object at all (>PLAY CARDS
, which ends up just being a special case Action
).
A lot of this can be handled by making vocabLikelihood
a method encapsulating a bunch of complex logic.
One of the solutions I was toying with was putting problematic vocabulary like this on an Unthing
, not putting it on other in-game objects, and having the Unthing
remapping the action to the appropriate object based on context. This feels very much like a kludge, however.
One of the problems with doing it with overlapping vocabulary on in-game objects is that this produces ambiguous object announcements (the response to >X CARDS
starting out with (your hand)
if the player is holding cards and (deck of cards)
if they’re not and so the deck handles the action, for example). And I don’t think there’s any way to block announceAmbigActionObject()
, like via something like tryImplicitActionMsg()
and using &silentImplicitAction
, like you would with an implicit action.
Basically I’ve got some stuff that more or less works for this, but it feels like an elaborate mess of special cases for something that feels like it ought to be a fairly common problem in IF. So I’m just wondering if I’m missing any obvious/simpler approaches.