Hey, so I'm trying to now write a VERY simple engine for text adventure games.
One of the aspects of it are Exits. These are attached to Door objects and
check to see if the way is locked, and if the user is using a particular item
on it. I've written a version of this engine in Python (it's the language I
have the most experience with), and I was wondering if I could have the keys in
the table be of differing types. Here's the code I have working,
type
Item* = object
name: string
description: string
Container* = object
name: string
description: string
contained: seq[Item]
Exit* = object
locked: bool
uses: Table[Object, proc(engine: Engine)]
room: int
Run
So basically, where there is 'Table[Object ...]' in Exit, I would like it to
either accept a Container or Item object as a valid key. Would I need to wrap
both up as a single object? Or is there a way I could have the table accept
either object as valid keys? Thank you for the help! :)