annotate gamelib/scenes/scene_widgets.py @ 252:dfc89bc64fdb

Start of walkthrough "unit test" and associated fixes and tweaks.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 27 Aug 2010 16:45:47 +0200
parents 12c4f87ea424
children 3b4a78422201
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
242
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
1 """Generic, game specific widgets"""
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
2
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
3 import random
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
4
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
5 from gamelib.state import Thing, Result
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
6
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
7
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
8 class Door(Thing):
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
9 """A door somewhere"""
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
10
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
11 DEST = "map"
252
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents: 242
diff changeset
12 SCENE = None
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents: 242
diff changeset
13
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents: 242
diff changeset
14 def __init__(self):
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents: 242
diff changeset
15 self.NAME = self.SCENE + '.door'
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents: 242
diff changeset
16 Thing.__init__(self)
242
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
17
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
18 def is_interactive(self):
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
19 return True
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
20
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
21 def interact_without(self):
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
22 """Go to map."""
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
23 self.state.set_current_scene("map")
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
24
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
25 def get_description(self):
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
26 return 'An open doorway leads to the rest of the ship.'
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
27
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
28 def interact_default(self, item):
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
29 return Result(random.choice([
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
30 "Sadly, this isn't that sort of game.",
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
31 "Your valiant efforts are foiled by the Evil Game Designer.",
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
32 "Waving that in the doorway does nothing. Try something else, perhaps?",
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
33 ]))
12c4f87ea424 Unify doors a bit
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
34