text adventure game problem

Terry Reedy tjreedy at udel.edu
Wed Apr 9 00:09:37 EDT 2008

<corvettecraz92 at gmail.com> wrote in message 
news:cea9f806-a85d-4187-ac93-4f876a1be39c at l64g2000hse.googlegroups.com...
| In the above function, there's the option to examine a cabinet and get
| 8 gold. (everyone here knows that...but I'm just trying to state my
| problem...)
| Unfortunately, it kind of doesn't work.
| After the first time I 'examine cabinet 1' in my game, I get 8 gold
| and I can't get it again.
| But, If I leave the room and come back to it, then it's as if I had
| never gotten the gold the first time, and I can get it again.
| How do I fix this?

I would define a container class.  The init function gives it a name and 
contents (8 gold, for instance).  Give kitchen a container('cabinet', 8).
Give containers a .examine() method which gives the contents to the player.
and a message which varies with the contents.  You can even make some 
container 'refreshable' if you want.


More information about the Python-list mailing list