def test_fill_container_of_liquid_with_different_liquid_mixwith_implemented( self): syrup = Liquid(self.game, "syrup", "syrup") syrup.moveTo(self.new_container) sweetened_wine = Liquid(self.game, "wine", "sweetened wine") def mixWith(g, base_liquid, mix_liquid): mix = set([base_liquid.liquid_type, mix_liquid.liquid_type]) container = base_liquid.location if mix == {"wine", "syrup"}: container.removeThing(base_liquid) container.addThing(sweetened_wine) g.addText("The syrup dissolves in the wine.") return True else: return False syrup.mixWith = mixWith self.liquid.mixWith = mixWith self.game.turnMain("fill bowl from bottle") self.assertIn("dissolves", self.app.print_stack.pop()) self.assertFalse(self.new_container.containsItem(self.liquid)) self.assertFalse(self.new_container.containsItem(syrup)) self.assertTrue(self.new_container.containsItem(sweetened_wine))
def test_pour_liquid_onto_different_liquid_mixwith_implemented(self): syrup = Liquid(self.game, "syrup", "syrup") syrup.moveTo(self.new_container) sweetened_wine = Liquid(self.game, "wine", "sweetened wine") def mixWith(g, base_liquid, mix_liquid, event="turn"): mix = set([base_liquid.liquid_type, mix_liquid.liquid_type]) container = base_liquid.location if mix == {"wine", "syrup"}: container.removeThing(base_liquid) container.addThing(sweetened_wine) g.addTextToEvent(event, "The syrup dissolves in the wine.") return True else: return False syrup.mix_with_liquid_type_allowed = ["wine"] self.liquid.mix_with_liquid_type_allowed = ["syrup"] syrup.mixWith = mixWith self.liquid.mixWith = mixWith self.game.turnMain("pour wine into bowl") self.assertIn("dissolves", self.app.print_stack.pop()) self.assertIn("You dump", self.app.print_stack.pop()) self.assertFalse(self.new_container.containsItem(self.liquid)) self.assertFalse(self.new_container.containsItem(syrup)) self.assertTrue(self.new_container.containsItem(sweetened_wine))