text adventure game problem
pavlovevidence at gmail.com
Wed Apr 9 02:26:06 EDT 2008
On Apr 9, 1:24 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Tue, 8 Apr 2008 18:01:01 -0700 (PDT), corvettecra... at gmail.com
> declaimed the following in comp.lang.python:
> > okay, I'm having this one problem with a text adventure game. It's
> > kind of hard to explain, but I'll do my best.
> > [code]
> > def prompt_kitchen():
> > global gold
> > gold_taken = False
> > while True:
> > prompt_kit = raw_input('>')
> > if prompt_kit == 'examine cabinet 1' and not gold_taken:
> > print '''This cabinet has a lot of cups in it with all
> > different
> > designs and shapes. Where are the people anyway? How come there's
> > nobody here?
> > In one of the cups you find 8 gold.'''
> Forgive me, but.... Ugh!
> It looks like you are defining a function for each possible room
> which incorporates code for the actions possible in that room...
> I suspect I'd try to create a generic room class which has as
> attributes a dictionary of actions and a dictionary of movable objects.
> Along with methods that work on objects... Working an action that digs
> into other objects may take some doing.
I don't know about you, but I usually start with specific cases like
this and then generalize them. This could be a baby step, or merely a
first stage of evolution.
More information about the Python-list