Mercurial > boomslang
annotate gamelib/scenes/cryo.py @ 69:d4bbb26099cc
Some debug object cleanup.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 23 Aug 2010 20:50:36 +0200 |
parents | 6b0f7364f3bf |
children | 6bfebfbce42e |
rev | line source |
---|---|
39
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
1 """Cryo room where the prisoner starts out.""" |
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
2 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
3 import random |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
4 |
39
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
5 from gamelib.state import Scene, Item, Thing |
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
6 |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
7 |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
8 class Cryo(Scene): |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
9 |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
10 FOLDER = "cryo" |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
11 BACKGROUND = "cryo_room.png" |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
12 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
13 INITIAL_DATA = { |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
14 'accessible': True, |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
15 } |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
16 |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
17 def __init__(self, state): |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
18 super(Cryo, self).__init__(state) |
35 | 19 self.add_item(Triangle("triangle")) |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
20 self.add_item(TitaniumLeg("titanium_leg")) |
63
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
21 self.add_thing(CryoUnitAlpha("cryo.unit.1", (20, 20, 200, 200))) |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
22 self.add_thing(CryoRoomDoor("cryo.door", (200, 200, 400, 300))) |
35 | 23 |
24 | |
25 class Triangle(Item): | |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
26 "Test item. Needs to go away at some point." |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
27 |
35 | 28 INVENTORY_IMAGE = "triangle.png" |
29 | |
30 | |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
31 class TitaniumLeg(Item): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
32 "Titanium leg, found on a piratical corpse." |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
33 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
34 INVENTORY_IMAGE = "titanium_leg.png" |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
35 |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
36 |
39
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
37 class CryoUnitAlpha(Thing): |
67
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
38 "Cryo unit containing titanium leg." |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
39 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
40 FOLDER = "cryo" |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
41 IMAGE = "cryo_unit_alpha" |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
42 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
43 INITIAL_DATA = { |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
44 'contains_titanium_leg': True, |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
45 } |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
46 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
47 def interact_without(self): |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
48 self.message("The corpse in this cryo unit has a prosthetic leg made out of titanium. You take it.") |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
49 self.state.add_inventory_item('titanium_leg') |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
50 self.set_data('contains_titanium_leg', False) |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
51 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
52 def is_interactive(self): |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
53 return self.get_data('contains_titanium_leg') |
39
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
54 |
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
55 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
56 class CryoRoomDoor(Thing): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
57 "Door to the cryo room." |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
58 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
59 FOLDER = "cryo" |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
60 IMAGE = "cryo_door_closed" |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
61 |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
62 INITIAL_DATA = { |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
63 'open': False, |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
64 } |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
65 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
66 def interact_with_titanium_leg(self, item): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
67 self.message("You wedge the titanium leg into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.") |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
68 self.open_door() |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
69 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
70 def interact_without(self): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
71 self.message("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.") |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
72 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
73 def interact_default(self, item): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
74 self.message(random.choice([ |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
75 "Sadly, this isn't that sort of game.", |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
76 "Your valiant efforts are foiled by the Evil Game Designer.", |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
77 "The door resists. Try something else, perhaps?", |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
78 ])) |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
79 |
56
75bf3d3689e9
Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents:
55
diff
changeset
|
80 def is_interactive(self): |
75bf3d3689e9
Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents:
55
diff
changeset
|
81 return not self.get_data('open') |
75bf3d3689e9
Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents:
55
diff
changeset
|
82 |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
83 def open_door(self): |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
84 self.set_data('open', True) |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
85 self.state.scenes['bridge'].set_data('accessible', True) |
67
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
86 self.state.remove_inventory_item('titanium_leg') |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
87 |
63
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
88 def get_description(self): |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
89 if self.get_data('open'): |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
90 return 'An open doorway leads to the rest of the ship' |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
91 return 'A rusty door. It is currently closed' |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
92 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
93 |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
94 SCENES = [Cryo] |