def execute(self): """Brew the beer""" has_water = False has_yeast = False has_fruit = False has_wood = False has_bottle = False player_character = (self.model.game_state. getObjectById("PlayerCharacter").container) for item in self.pot.children: if not item: continue if item.item_type == "Questionable water": if has_water: self.view.hud.addAction(unicode(\ "Please put only 1 water in the pot")) return has_water = True water_type = 1 water = item elif item.item_type == "Pure water": if has_water: self.view.hud.addAction(unicode(\ "Please put only 1 water in the pot")) return has_water = True water_type = 2 water = item elif item.item_type == "Grain": if has_fruit: self.view.hud.addAction(unicode(\ "Please put only 1 fruit in the pot")) return has_fruit = True fruit_type = 3 fruit = item elif item.item_type == "Wild potato": if has_fruit: self.view.hud.addAction(unicode(\ "Please put only 1 fruit in the pot")) return has_fruit = True fruit_type = 2 fruit = item elif item.item_type == "Rotten yam": if has_fruit: self.view.hud.addAction(unicode(\ "Please put only 1 fruit in the pot")) return has_fruit = True fruit_type = 1 fruit = item elif item.item_type == "Yeast": if has_yeast: self.view.hud.addAction(unicode(\ "Please put only 1 yeast in the pot")) return has_yeast = True yeast = item else: self.view.hud.addAction(unicode( "Item " + (item.entity.description.view_name) + " is not needed for brewing beer")) self.view.hud.addAction(unicode(\ "Please put only ingredients for the beer in the pot.\ Things like bottles and wood have to be in your inventory")) return wood = container.get_item(player_character, "Wood") if wood: has_wood = True bottle = container.get_item(player_character, "Empty beer bottle") if bottle: has_bottle = True if has_water and has_fruit and has_wood and has_bottle: container.remove_item(self.pot, water.slot) container.remove_item(self.pot, fruit.slot) if has_yeast: container.remove_item(self.pot, yeast.slot) container.remove_item(player_character, wood.slot) new_item = (self.model.createItemByType("Beer", "Beer", self.pot.entity.world) ) container.put_item(player_character, new_item.containable) self.view.hud.inventory.updateImages() beer_quality = 0 if water_type == 1: if fruit_type == 1: beer_quality = -1 elif fruit_type == 2: beer_quality = 2 elif fruit_type == 3: beer_quality = 3 if water_type == 2: if fruit_type == 1: beer_quality = 1 elif fruit_type == 2: beer_quality = 3 elif fruit_type == 3: beer_quality = 4 if beer_quality > 0 and has_yeast: beer_quality += 1 self.model.game_state.quest_engine.quests["beer"].\ setValue("beer_quality", beer_quality) else: self.view.hud.addAction(unicode( """For brewing beer you need at least: In the pot: Fruit (like grain, potato, yam) Water Optionally: Good quality yeast. Wild yeast will be used if none present. In the inventory: Wood Empty bottle""")) super(BrewBeerAction, self).execute()
def execute(self): super(DropItemFromContainerAction, self).execute() container.remove_item(self.item.container, self.item.slot) self.container_gui.updateImages()