Handling topic phrases is a bit tricky, because they can't be resolved to definitive game-world objects the way ordinary noun phrases can. Topic phrases can refer to things that aren't physically present, but which are known to the actor performing the command; they can refer to abstract Topic objects, that have no physical existence in the game world at all; and they can ever be arbitrary text that doesn't match any vocabulary defined by the game.
Our strategy in matching topics is to first narrow the list down to the physical and abstract game objects that both match the vocabulary used in the command and are part of the memory of the actor performing the command. That much is handled by the normal topic phrase resolution rules, and gives us a list of possible matches. Then, given this narrowed list of possibilities, we look through the list of objects that we're associated with; we effectively intersect the two lists, and if the result is non-empty, we consider it a match. Finally, we also consider any regular expression that we're associated with; if we have one, and the topic phrase text in the command matches the input, we'll consider it a match.
TopicMatchTopic : TopicEntry
Note that both the object (or object list) and the regular expression pattern can be included for a single topic entry object. This allows a topic entry to match several different ways of entering the topic name, or to match several different topics with the same response.
'topic' is a ResolvedTopic object describing the player's text input and the list of objects that the parser matched to the text.
Subclasses can override this as desired to use other ways of matching.