comparison gamelib/scenes/mess.py @ 223:10d3265f0bfa

Decreasing cans on shelf
author Stefano Rivera <stefano@rivera.za.net>
date Thu, 26 Aug 2010 22:10:01 +0200
parents bcb7b2093118
children 8d8aef45db4e
comparison
equal deleted inserted replaced
222:b03debaec72d 223:10d3265f0bfa
91 class CansOnShelf(Thing): 91 class CansOnShelf(Thing):
92 92
93 NAME = "mess.cans" 93 NAME = "mess.cans"
94 94
95 INTERACTS = { 95 INTERACTS = {
96 "cans": InteractImage(165, 209, "cans_on_shelf.png"), 96 '3cans': InteractImage(165, 209, 'shelf_3_cans.png'),
97 "nocans": InteractNoImage(165, 209, 50, 50), 97 '2cans': InteractImage(165, 209, 'shelf_2_cans.png'),
98 '1cans': InteractImage(165, 209, 'shelf_1_can.png'),
99 '0cans': InteractNoImage(165, 209, 50, 50),
98 } 100 }
99 101
100 INITIAL = "cans" 102 INITIAL = '3cans'
101 103
102 INITIAL_DATA = { 104 INITIAL_DATA = {
103 'cans_vended': 0, 105 'cans_available': 3,
104 } 106 }
105 107
106 def interact_without(self): 108 def interact_without(self):
107 starting_cans = self.get_data('cans_vended') 109 starting_cans = self.get_data('cans_available')
108 if starting_cans < 3: 110 if starting_cans > 0:
109 can = FullCan("full_can") 111 can = FullCan("full_can")
110 self.state.add_item(can) 112 self.state.add_item(can)
111 self.state.add_inventory_item(can.name) 113 self.state.add_inventory_item(can.name)
112 self.set_data('cans_vended', starting_cans + 1) 114 self.set_data('cans_available', starting_cans - 1)
115 self.set_interact('%icans' % (starting_cans - 1))
113 return Result({ 116 return Result({
114 0: "Best before along time in the past. Better not eat these.", 117 3: "Best before along time in the past. Better not eat these.",
115 1: "Mmmm. Nutritious Bacteria Stew.", 118 2: "Mmmm. Nutritious Bacteria Stew.",
116 2: "Candied silkworms. Who stocked this place!?", 119 1: "Candied silkworms. Who stocked this place!?",
117 }[starting_cans]) 120 }[starting_cans])
118 else: 121 else:
119 return Result("The rest of the cans are rusted beyond usefulness.") 122 return Result("The rest of the cans are rusted beyond usefulness.")
120 123
121 def get_description(self): 124 def get_description(self):