Mercurial > pyntnclick
comparison gamelib/scenes/mess.py @ 191:278774b31d3c
CloneableItems.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Wed, 25 Aug 2010 21:32:38 +0200 |
parents | 3d3efc5648cc |
children | b1f4262139e7 |
comparison
equal
deleted
inserted
replaced
190:30f2308c1efc | 191:278774b31d3c |
---|---|
1 """Mess where crew eat. Fun stuff.""" | 1 """Mess where crew eat. Fun stuff.""" |
2 | 2 |
3 from random import choice | 3 from random import choice |
4 | 4 |
5 from gamelib.state import Scene, Item, Thing, InteractImage, InteractNoImage, Result | 5 from gamelib.state import Scene, Item, CloneableItem, Thing, InteractImage, InteractNoImage, Result |
6 from gamelib.cursor import CursorSprite | 6 from gamelib.cursor import CursorSprite |
7 | 7 |
8 | 8 |
9 class Mess(Scene): | 9 class Mess(Scene): |
10 | 10 |
24 self.add_thing(CansOnShelf()) | 24 self.add_thing(CansOnShelf()) |
25 self.add_thing(Tubes()) | 25 self.add_thing(Tubes()) |
26 self.add_thing(ToMap()) | 26 self.add_thing(ToMap()) |
27 | 27 |
28 | 28 |
29 class EmptyCan(Item): | 29 class EmptyCan(CloneableItem): |
30 "After emptying the full can." | 30 "After emptying the full can." |
31 | 31 |
32 INVENTORY_IMAGE = "empty_can.png" | 32 INVENTORY_IMAGE = "empty_can.png" |
33 CURSOR = CursorSprite('empty_can_cursor.png', 20, 30) | 33 CURSOR = CursorSprite('empty_can_cursor.png', 20, 30) |
34 | 34 |
35 class FullCan(Item): | 35 |
36 class FullCan(CloneableItem): | |
36 "Found on the shelf." | 37 "Found on the shelf." |
37 | 38 |
38 INVENTORY_IMAGE = "full_can.png" | 39 INVENTORY_IMAGE = "full_can.png" |
39 CURSOR = CursorSprite('full_can_cursor.png', 20, 30) | 40 CURSOR = CursorSprite('full_can_cursor.png', 20, 30) |
40 | 41 |
41 def interact_with_titanium_leg(self, tool, state): | 42 def interact_with_titanium_leg(self, item, state): |
42 dented = DentedCan("dented_can") | 43 dented = DentedCan("dented_can") |
44 state.add_item(dented) | |
43 state.replace_inventory_item(self, dented) | 45 state.replace_inventory_item(self, dented) |
44 return Result("You club the can with the femur. The can gets dented, but doesn't open.") | 46 return Result("You club the can with the femur. The can gets dented, but doesn't open.") |
45 | 47 |
46 | 48 |
47 class DentedCan(FullCan): | 49 class DentedCan(CloneableItem): |
48 "A can banged on with the femur" | 50 "A can banged on with the femur" |
49 | 51 |
50 INVENTORY_IMAGE = "dented_can.png" | 52 INVENTORY_IMAGE = "dented_can.png" |
51 CURSOR = CursorSprite('dented_can_cursor.png', 20, 30) | 53 CURSOR = CursorSprite('dented_can_cursor.png', 20, 30) |
52 | 54 |
53 def interact_with_titanium_leg(self, tool, inventory): | 55 def interact_with_titanium_leg(self, item, state): |
54 return Result("You club the can with the femur. The dents shift around, but it still doesn't open.") | 56 return Result("You club the can with the femur. The dents shift around, but it still doesn't open.") |
55 | 57 |
56 | 58 |
57 class TubeFragments(Item): | 59 class TubeFragments(Item): |
58 "Old tubes that need repair." | 60 "Old tubes that need repair." |
82 INITIAL_DATA = { | 84 INITIAL_DATA = { |
83 'taken_one': False, | 85 'taken_one': False, |
84 } | 86 } |
85 | 87 |
86 def interact_without(self): | 88 def interact_without(self): |
87 self.state.add_inventory_item('full_can') | 89 can = FullCan("full_can") |
90 self.state.add_item(can) | |
91 self.state.add_inventory_item(can.name) | |
88 if not self.data['taken_one']: | 92 if not self.data['taken_one']: |
89 self.set_data('taken_one', True) | 93 self.set_data('taken_one', True) |
90 return Result("Best before along time in the past. Better not eat these.") | 94 return Result("Best before along time in the past. Better not eat these.") |
91 else: | 95 else: |
92 return Result(choice(( | 96 return Result(choice(( |