Mercurial > skaapsteker
annotate skaapsteker/sprites/items.py @ 417:e289a111c743
edited item text
author | anna <annamalczyk@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 17:43:39 +0200 |
parents | 8ac5b3d619fe |
children | e65f6783a9f7 |
rev | line source |
---|---|
383 | 1 from .. import engine |
2 from .base import Item | |
127 | 3 |
4 | |
388 | 5 def notify(text): |
6 engine.OpenNotification.post(text=text) | |
7 | |
8 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
9 class BreakableItem(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
10 whole_image_file = None |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
11 broken_image_file = None |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
12 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
13 def setup(self, broken, **opts): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
14 super(BreakableItem, self).setup(**opts) |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
15 self.broken = broken |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
16 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
17 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
18 def setup_image_data(self, pos): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
19 self.image_file = self.broken_image_file if self._me.broken else self.whole_image_file |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
20 super(BreakableItem, self).setup_image_data(pos) |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
21 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
22 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
23 def smash(self): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
24 self._me.broken = True |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
25 self.broken = True |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
26 self.setup_image_data(self._starting_tile_pos) |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
27 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
28 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
29 |
335 | 30 ################################################## |
31 # Collectibles | |
32 | |
33 class Aburage(Item): | |
397 | 34 image_file = 'props/tofu.png' |
335 | 35 |
36 def player_action(self, player): | |
37 player.eat_aburage() | |
38 self.remove() | |
39 | |
40 | |
340 | 41 class HaikuScroll(Item): |
397 | 42 image_file = 'props/haiku-scroll.png' |
340 | 43 |
44 def player_action(self, player): | |
45 player.collect_scroll(self) | |
46 self.remove() | |
47 | |
48 | |
49 def setup(self, text, **opts): | |
50 super(HaikuScroll, self).setup(**opts) | |
51 self.text = text | |
52 | |
53 | |
335 | 54 |
55 ################################################## | |
56 # Monk tea mission | |
57 | |
189
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
58 class TeaCup(Item): |
397 | 59 image_file = 'props/teacup_empty.png' |
189
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
60 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
61 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
62 class TeaLeaf(Item): |
397 | 63 image_file = 'props/tealeaf.png' |
127 | 64 |
189
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
65 |
191 | 66 class TeaCupFull(Item): |
397 | 67 image_file = 'props/teacup_full.png' |
191 | 68 |
69 | |
189
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
70 class TeaPot(Item): |
397 | 71 image_file = 'props/teapot.png' |
237
e06c54d7701f
Add vase to demonstrate item state testing in dialogues.
Simon Cross <hodgestar@gmail.com>
parents:
191
diff
changeset
|
72 |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
73 def setup(self, brewed, **opts): |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
74 super(TeaPot, self).setup(**opts) |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
75 |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
76 |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
77 def player_action(self, player): |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
78 if player.has_item('tealeaf'): |
335 | 79 self._me.brewed = True |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
80 player.discard_item() |
388 | 81 notify("A nice cup of tea is brewing.") |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
82 return |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
83 if player.has_item('teacup'): |
335 | 84 if self._me.brewed: |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
85 player.discard_item() |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
86 player.take_item_by_name('teacupfull') |
335 | 87 self._me.brewed = False |
403 | 88 notify("You pour a cup of tea.") |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
89 else: |
388 | 90 notify("Sadly, the teapot is empty.") |
383 | 91 return |
388 | 92 notify("A proper tea ceremony requires a cup.") |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
93 |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
94 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
95 |
335 | 96 ################################################## |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
97 # Guard seduction |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
98 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
99 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
100 class Fan(Item): |
397 | 101 image_file = 'props/fan.png' |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
102 |
395 | 103 def player_action(self, player): |
104 player.get_fan(self) | |
105 | |
106 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
107 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
108 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
109 # Samurai distraction |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
110 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
111 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
112 class Kindling(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
113 image_file = 'props/kindling.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
114 |
412 | 115 def player_action(self, player): |
116 if player.has_item('oil'): | |
117 set_fire(player, self) | |
118 else: | |
119 player.take_item(self) | |
120 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
121 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
122 class Oil(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
123 image_file = 'props/oil.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
124 |
412 | 125 def player_action(self, player): |
126 if player.has_item('kindling'): | |
127 set_fire(player, self) | |
128 else: | |
129 player.take_item(self) | |
130 | |
131 | |
132 | |
133 # TODO: Finish this thing's behaviour | |
134 class SignalFire(Item): | |
135 image_file = 'dummy.png' | |
136 | |
137 def setup(self, litness, **opts): | |
138 super(SignalFire, self).setup(**opts) | |
139 | |
140 | |
141 def player_action(self, player): | |
142 if self._me.litness == 'set': | |
143 if player.has_item('kindling'): | |
417 | 144 notify("You put the kindling in the signal fire.") |
412 | 145 elif player.has_item('oil'): |
417 | 146 notify("You pour the oil on the signal fire.") |
412 | 147 else: |
148 return | |
149 player.discard_item() | |
150 self._me.litness = 'kindled' | |
151 elif self._me.litness == 'kindled': | |
152 if player.has_item('kindling'): | |
417 | 153 notify("You put the kindling on the signal fire and light it.") |
412 | 154 elif player.has_item('oil'): |
417 | 155 notify("You pour the oil on the signal fire and light it.") |
412 | 156 else: |
157 return | |
158 player.discard_item() | |
159 self._me.litness = 'burning' | |
160 self.world.missions.fire_started_on_road = True | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
161 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
162 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
163 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
164 # Cannon destruction |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
165 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
166 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
167 class Cannon(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
168 whole_image_file = 'props/cannon-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
169 broken_image_file = 'props/cannon-broken.png' |
335 | 170 |
171 | |
237
e06c54d7701f
Add vase to demonstrate item state testing in dialogues.
Simon Cross <hodgestar@gmail.com>
parents:
191
diff
changeset
|
172 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
173 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
174 # Geisha character assassination |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
175 |
237
e06c54d7701f
Add vase to demonstrate item state testing in dialogues.
Simon Cross <hodgestar@gmail.com>
parents:
191
diff
changeset
|
176 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
177 class Vase(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
178 whole_image_file = 'props/vase-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
179 broken_image_file = 'props/vase-broken.png' |
297
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
296
diff
changeset
|
180 |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
296
diff
changeset
|
181 |
2844edb6c1cc
Hook up maneki, kaneda2 and the fishmonger who were hiding in limbo (i.e. not in game.json).
Simon Cross <hodgestar@gmail.com>
parents:
296
diff
changeset
|
182 class Salmon(Item): |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
183 image_file = 'props/fish.png' |
335 | 184 |
185 | |
186 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
187 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
188 # Theatrical debut |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
189 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
190 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
191 class NoMask(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
192 whole_image_file = 'props/no-mask-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
193 broken_image_file = 'props/no-mask-broken.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
194 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
195 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
196 class NoCostume(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
197 image_file = 'props/no-costume.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
198 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
199 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
200 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
201 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
202 # Big business |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
203 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
204 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
205 class Rice(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
206 whole_image_file = 'props/rice-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
207 broken_image_file = 'props/rice-broken.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
208 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
209 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
210 class Documents(Item): |
406
9c043be746fa
stuff in the teahouse
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
403
diff
changeset
|
211 image_file = 'props/haiku-scroll.png' |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
212 |