Mercurial > skaapsteker
annotate skaapsteker/sprites/items.py @ 470:3b680634c546
Start of tails.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 21:10:16 +0200 |
parents | a084af91d5dc |
children | 14cab059bf39 |
rev | line source |
---|---|
383 | 1 from .. import engine |
442
a084af91d5dc
Make breakable items break
Neil Muller <drnlmuller@gmail.com>
parents:
434
diff
changeset
|
2 from .base import Item, PC_LAYER, PROJECTILE_LAYER |
a084af91d5dc
Make breakable items break
Neil Muller <drnlmuller@gmail.com>
parents:
434
diff
changeset
|
3 |
127 | 4 |
5 | |
388 | 6 def notify(text): |
7 engine.OpenNotification.post(text=text) | |
8 | |
9 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
10 class BreakableItem(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
11 whole_image_file = None |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
12 broken_image_file = None |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
13 |
442
a084af91d5dc
Make breakable items break
Neil Muller <drnlmuller@gmail.com>
parents:
434
diff
changeset
|
14 collides_with = set([PC_LAYER, PROJECTILE_LAYER]) |
a084af91d5dc
Make breakable items break
Neil Muller <drnlmuller@gmail.com>
parents:
434
diff
changeset
|
15 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
16 def setup(self, broken, **opts): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
17 super(BreakableItem, self).setup(**opts) |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
18 self.broken = broken |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
19 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
20 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
21 def setup_image_data(self, pos): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
22 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
|
23 super(BreakableItem, self).setup_image_data(pos) |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
24 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
25 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
26 def smash(self): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
27 self._me.broken = True |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
28 self.broken = True |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
29 self.setup_image_data(self._starting_tile_pos) |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
30 |
442
a084af91d5dc
Make breakable items break
Neil Muller <drnlmuller@gmail.com>
parents:
434
diff
changeset
|
31 def damage(self, damage): |
a084af91d5dc
Make breakable items break
Neil Muller <drnlmuller@gmail.com>
parents:
434
diff
changeset
|
32 self.smash() |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
33 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
34 |
335 | 35 ################################################## |
36 # Collectibles | |
37 | |
38 class Aburage(Item): | |
397 | 39 image_file = 'props/tofu.png' |
335 | 40 |
41 def player_action(self, player): | |
42 player.eat_aburage() | |
43 self.remove() | |
44 | |
45 | |
340 | 46 class HaikuScroll(Item): |
397 | 47 image_file = 'props/haiku-scroll.png' |
340 | 48 |
49 def player_action(self, player): | |
50 player.collect_scroll(self) | |
51 self.remove() | |
52 | |
53 | |
54 def setup(self, text, **opts): | |
55 super(HaikuScroll, self).setup(**opts) | |
56 self.text = text | |
57 | |
58 | |
335 | 59 |
60 ################################################## | |
61 # Monk tea mission | |
62 | |
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
|
63 class TeaCup(Item): |
397 | 64 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
|
65 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
66 |
9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
Simon Cross <hodgestar@gmail.com>
parents:
162
diff
changeset
|
67 class TeaLeaf(Item): |
397 | 68 image_file = 'props/tealeaf.png' |
127 | 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 |
191 | 71 class TeaCupFull(Item): |
397 | 72 image_file = 'props/teacup_full.png' |
191 | 73 |
74 | |
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
|
75 class TeaPot(Item): |
397 | 76 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
|
77 |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
78 def setup(self, brewed, **opts): |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
79 super(TeaPot, self).setup(**opts) |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
80 |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
81 |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
82 def player_action(self, player): |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
83 if player.has_item('tealeaf'): |
335 | 84 self._me.brewed = True |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
85 player.discard_item() |
388 | 86 notify("A nice cup of tea is brewing.") |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
87 return |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
88 if player.has_item('teacup'): |
335 | 89 if self._me.brewed: |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
90 player.discard_item() |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
91 player.take_item_by_name('teacupfull') |
335 | 92 self._me.brewed = False |
403 | 93 notify("You pour a cup of tea.") |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
94 else: |
388 | 95 notify("Sadly, the teapot is empty.") |
383 | 96 return |
388 | 97 notify("A proper tea ceremony requires a cup.") |
296
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
98 |
15b2be883a40
Ancient and honorable tea ceremony.
Jeremy Thurgood <firxen@gmail.com>
parents:
237
diff
changeset
|
99 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
100 |
335 | 101 ################################################## |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
102 # Guard seduction |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
103 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
104 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
105 class Fan(Item): |
397 | 106 image_file = 'props/fan.png' |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
107 |
395 | 108 def player_action(self, player): |
109 player.get_fan(self) | |
110 | |
111 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
112 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
113 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
114 # Samurai distraction |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
115 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
116 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
117 class Kindling(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
118 image_file = 'props/kindling.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
119 |
412 | 120 def player_action(self, player): |
121 if player.has_item('oil'): | |
122 set_fire(player, self) | |
123 else: | |
124 player.take_item(self) | |
125 | |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
126 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
127 class Oil(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
128 image_file = 'props/oil.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
129 |
412 | 130 def player_action(self, player): |
131 if player.has_item('kindling'): | |
132 set_fire(player, self) | |
133 else: | |
134 player.take_item(self) | |
135 | |
136 | |
137 | |
138 # TODO: Finish this thing's behaviour | |
139 class SignalFire(Item): | |
432
e65f6783a9f7
placed fire on the road; animation not yet hooked up
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
417
diff
changeset
|
140 image_file = 'props/signal_fire/signal_fire_unlit.png' |
412 | 141 |
142 def setup(self, litness, **opts): | |
143 super(SignalFire, self).setup(**opts) | |
144 | |
145 | |
146 def player_action(self, player): | |
147 if self._me.litness == 'set': | |
148 if player.has_item('kindling'): | |
417 | 149 notify("You put the kindling in the signal fire.") |
412 | 150 elif player.has_item('oil'): |
417 | 151 notify("You pour the oil on the signal fire.") |
412 | 152 else: |
153 return | |
154 player.discard_item() | |
155 self._me.litness = 'kindled' | |
156 elif self._me.litness == 'kindled': | |
157 if player.has_item('kindling'): | |
417 | 158 notify("You put the kindling on the signal fire and light it.") |
412 | 159 elif player.has_item('oil'): |
417 | 160 notify("You pour the oil on the signal fire and light it.") |
412 | 161 else: |
162 return | |
163 player.discard_item() | |
164 self._me.litness = 'burning' | |
165 self.world.missions.fire_started_on_road = True | |
354
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 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
168 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
169 # Cannon destruction |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
170 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
171 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
172 class Cannon(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
173 whole_image_file = 'props/cannon-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
174 broken_image_file = 'props/cannon-broken.png' |
335 | 175 |
434
827c5d045cf5
Don't allow the cannon to be picked up
Neil Muller <drnlmuller@gmail.com>
parents:
432
diff
changeset
|
176 liftable = False |
827c5d045cf5
Don't allow the cannon to be picked up
Neil Muller <drnlmuller@gmail.com>
parents:
432
diff
changeset
|
177 |
335 | 178 |
237
e06c54d7701f
Add vase to demonstrate item state testing in dialogues.
Simon Cross <hodgestar@gmail.com>
parents:
191
diff
changeset
|
179 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
180 ################################################## |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
181 # Geisha character assassination |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
182 |
237
e06c54d7701f
Add vase to demonstrate item state testing in dialogues.
Simon Cross <hodgestar@gmail.com>
parents:
191
diff
changeset
|
183 |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
184 class Vase(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
185 whole_image_file = 'props/vase-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
186 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
|
187 |
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
|
188 |
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
|
189 class Salmon(Item): |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
190 image_file = 'props/fish.png' |
335 | 191 |
192 | |
193 | |
354
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 # Theatrical debut |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
196 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
197 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
198 class NoMask(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
199 whole_image_file = 'props/no-mask-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
200 broken_image_file = 'props/no-mask-broken.png' |
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 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
203 class NoCostume(Item): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
204 image_file = 'props/no-costume.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
205 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
206 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
207 |
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 # Big business |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
210 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
211 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
212 class Rice(BreakableItem): |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
213 whole_image_file = 'props/rice-whole.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
214 broken_image_file = 'props/rice-broken.png' |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
215 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
216 |
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
217 class Documents(Item): |
406
9c043be746fa
stuff in the teahouse
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
403
diff
changeset
|
218 image_file = 'props/haiku-scroll.png' |
354
b37dbc557ae0
Stub classes for all items.
Jeremy Thurgood <firxen@gmail.com>
parents:
340
diff
changeset
|
219 |
470 | 220 ################################################## |
221 # Tails | |
222 | |
223 class Tail(Item): | |
224 | |
225 image_file = None | |
226 tail_type = None | |
227 | |
228 def player_action(self, player): | |
229 player.add_tail(self.tail_type) | |
230 self.remove() | |
231 | |
232 | |
233 class ShapeshiftTail(Tail): | |
234 image_file = 'icons/tails/shapeshifted.png' | |
235 tail_type = 'shapeshift' | |
236 | |
237 | |
238 class FireballTail(Tail): | |
239 image_file = 'icons/tails/fireball.png' | |
240 tail_type = 'fireball' |