comparison gamelib/scenes/mess.py @ 491:9f488671c02e engine_refactor

No more state in Item interacts.
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 29 Aug 2010 19:58:35 +0200
parents af2a23b9787d
children 8f3c82c685a4
comparison
equal deleted inserted replaced
490:2e784f978d1a 491:9f488671c02e
48 48
49 49
50 class BaseCan(CloneableItem): 50 class BaseCan(CloneableItem):
51 """Base class for the cans""" 51 """Base class for the cans"""
52 52
53 def interact_with_full_can(self, item, state): 53 def interact_with_full_can(self, item):
54 return Result("You bang the cans together. It sounds like two cans being banged together.", soundfile="can_hit.ogg") 54 return Result("You bang the cans together. It sounds like two cans being banged together.", soundfile="can_hit.ogg")
55 55
56 def interact_with_dented_can(self, item, state): 56 def interact_with_dented_can(self, item):
57 return self.interact_with_full_can(item, state) 57 return self.interact_with_full_can(item)
58 58
59 def interact_with_empty_can(self, item, state): 59 def interact_with_empty_can(self, item):
60 return self.interact_with_full_can(item, state) 60 return self.interact_with_full_can(item)
61 61
62 def interact_with_machete(self, item, state): 62 def interact_with_machete(self, item):
63 return Result("You'd mangle it beyond usefulness.") 63 return Result("You'd mangle it beyond usefulness.")
64 64
65 def interact_with_canopener(self, item, state): 65 def interact_with_canopener(self, item):
66 empty = EmptyCan('empty_can') 66 empty = EmptyCan('empty_can')
67 state.add_item(empty) 67 self.state.add_item(empty)
68 state.replace_inventory_item(self.name, empty.name) 68 self.state.replace_inventory_item(self.name, empty.name)
69 return Result("You open both ends of the can, discarding the hideous contents.") 69 return Result("You open both ends of the can, discarding the hideous contents.")
70 70
71 71
72 class EmptyCan(BaseCan): 72 class EmptyCan(BaseCan):
73 "After emptying the full can." 73 "After emptying the full can."
74 74
75 INVENTORY_IMAGE = "empty_can.png" 75 INVENTORY_IMAGE = "empty_can.png"
76 CURSOR = CursorSprite('empty_can_cursor.png') 76 CURSOR = CursorSprite('empty_can_cursor.png')
77 77
78 def interact_with_titanium_leg(self, item, state): 78 def interact_with_titanium_leg(self, item):
79 return Result("Flattening the can doesn't look like a useful thing to do.") 79 return Result("Flattening the can doesn't look like a useful thing to do.")
80 80
81 def interact_with_canopener(self, item, state): 81 def interact_with_canopener(self, item):
82 return Result("There's nothing left to open on this can") 82 return Result("There's nothing left to open on this can")
83 83
84 84
85 class FullCan(BaseCan): 85 class FullCan(BaseCan):
86 "Found on the shelf." 86 "Found on the shelf."
87 87
88 INVENTORY_IMAGE = "full_can.png" 88 INVENTORY_IMAGE = "full_can.png"
89 CURSOR = CursorSprite('full_can_cursor.png') 89 CURSOR = CursorSprite('full_can_cursor.png')
90 90
91 def interact_with_titanium_leg(self, item, state): 91 def interact_with_titanium_leg(self, item):
92 dented = DentedCan("dented_can") 92 dented = DentedCan("dented_can")
93 state.add_item(dented) 93 self.state.add_item(dented)
94 state.replace_inventory_item(self.name, dented.name) 94 self.state.replace_inventory_item(self.name, dented.name)
95 return Result("You club the can with the femur. The can gets dented, but doesn't open.", soundfile="can_hit.ogg") 95 return Result("You club the can with the femur. The can gets dented, but doesn't open.", soundfile="can_hit.ogg")
96 96
97 97
98 class DentedCan(BaseCan): 98 class DentedCan(BaseCan):
99 "A can banged on with the femur" 99 "A can banged on with the femur"
100 100
101 INVENTORY_IMAGE = "dented_can.png" 101 INVENTORY_IMAGE = "dented_can.png"
102 CURSOR = CursorSprite('dented_can_cursor.png') 102 CURSOR = CursorSprite('dented_can_cursor.png')
103 103
104 def interact_with_titanium_leg(self, item, state): 104 def interact_with_titanium_leg(self, item):
105 return Result("You club the can with the femur. The dents shift around, but it still doesn't open.", soundfile="can_hit.ogg") 105 return Result("You club the can with the femur. The dents shift around, but it still doesn't open.", soundfile="can_hit.ogg")
106 106
107 107
108 class CansOnShelf(Thing): 108 class CansOnShelf(Thing):
109 109