Mercurial > boomslang
annotate gamelib/scenes/cryo.py @ 86:593bddfacf18
Refactor Things a bit to render images.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 00:14:23 +0200 |
parents | 6bfebfbce42e |
children | 4c6fea1b242b |
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 |
86
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
5 from gamelib.state import Scene, Item, Thing, Result, \ |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
6 InteractImage, InteractNoImage |
39
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
7 |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
8 |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
9 class Cryo(Scene): |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
10 |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
11 FOLDER = "cryo" |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
12 BACKGROUND = "cryo_room.png" |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
13 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
14 INITIAL_DATA = { |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
15 'accessible': True, |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
16 } |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
17 |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
18 def __init__(self, state): |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
19 super(Cryo, self).__init__(state) |
35 | 20 self.add_item(Triangle("triangle")) |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
21 self.add_item(TitaniumLeg("titanium_leg")) |
86
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
22 self.add_thing(CryoUnitAlpha()) |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
23 self.add_thing(CryoRoomDoor()) |
35 | 24 |
25 | |
26 class Triangle(Item): | |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
27 "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
|
28 |
35 | 29 INVENTORY_IMAGE = "triangle.png" |
30 | |
31 | |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
32 class TitaniumLeg(Item): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
33 "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
|
34 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
35 INVENTORY_IMAGE = "titanium_leg.png" |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
36 |
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
37 |
39
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
38 class CryoUnitAlpha(Thing): |
67
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
39 "Cryo unit containing titanium leg." |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
40 |
86
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
41 NAME = "cryo.unit.1" |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
42 |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
43 INTERACTS = { |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
44 "unit": InteractNoImage(100, 300, 100, 100), |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
45 } |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
46 |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
47 INITIAL = "unit" |
67
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
48 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
49 INITIAL_DATA = { |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
50 'contains_titanium_leg': True, |
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 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
53 def interact_without(self): |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
54 self.state.add_inventory_item('titanium_leg') |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
55 self.set_data('contains_titanium_leg', False) |
78 | 56 return Result("The corpse in this cryo unit has a prosthetic leg made out of titanium. You take it.") |
67
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
57 |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
58 def is_interactive(self): |
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
59 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
|
60 |
088a101f5b94
Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
35
diff
changeset
|
61 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
62 class CryoRoomDoor(Thing): |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
63 "Door to the cryo room." |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
64 |
86
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
65 NAME = "cryo.door" |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
66 |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
67 INTERACTS = { |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
68 "ajar": InteractImage(200, 200, "door_ajar.png"), |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
69 "open": InteractImage(200, 200, "door_open.png"), |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
70 } |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
71 |
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
72 INITIAL = "ajar" |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
73 |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
74 INITIAL_DATA = { |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
75 'open': False, |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
76 } |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
77 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
78 def interact_with_titanium_leg(self, item): |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
79 self.open_door() |
78 | 80 return Result("You wedge the titanium leg into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.") |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
81 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
82 def interact_without(self): |
78 | 83 return Result("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.") |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
84 |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
85 def interact_default(self, item): |
78 | 86 return Result(random.choice([ |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
87 "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
|
88 "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
|
89 "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
|
90 ])) |
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
91 |
56
75bf3d3689e9
Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents:
55
diff
changeset
|
92 def is_interactive(self): |
75bf3d3689e9
Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents:
55
diff
changeset
|
93 return not self.get_data('open') |
75bf3d3689e9
Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents:
55
diff
changeset
|
94 |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
95 def open_door(self): |
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
96 self.set_data('open', True) |
86
593bddfacf18
Refactor Things a bit to render images.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
78
diff
changeset
|
97 self.set_interact("open") |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
98 self.state.scenes['bridge'].set_data('accessible', True) |
67
6b0f7364f3bf
Inventory-related game state.
Jeremy Thurgood <firxen@gmail.com>
parents:
63
diff
changeset
|
99 self.state.remove_inventory_item('titanium_leg') |
55
2e2f6ff54780
Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents:
41
diff
changeset
|
100 |
63
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
101 def get_description(self): |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
102 if self.get_data('open'): |
3087be3463e0
Some framework support for better message handling
Neil Muller <neil@dip.sun.ac.za>
parents:
56
diff
changeset
|
103 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
|
104 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
|
105 |
41
ad6f56bfa8b7
Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents:
39
diff
changeset
|
106 |
28
0f25f7b9b37a
Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff
changeset
|
107 SCENES = [Cryo] |