def test_pour_out_non_liquid_non_container_item_too_large(self):
        item = Thing(self.game, "bead")
        item.size = 100
        item.moveTo(self.old_container)
        self.old_container.removeThing(self.liquid)

        self.game.turnMain("pour bottle into bowl")
        self.assertIn("too large to fit inside", self.app.print_stack.pop())
Example #2
0
    def test_fill_container_from_container_containing_only_non_liquids(self):
        item = Thing(self.game, "bead")
        item.size = 2
        item.moveTo(self.old_container)
        self.old_container.removeThing(self.liquid)

        self.game.turnMain("fill bowl from bottle")
        self.assertIn("no liquid in", self.app.print_stack.pop())
Example #3
0
    def test_drop_item_not_in_inv(self):
        item = Thing(self.game, "shoe")
        item.invItem = True
        self.start_room.addThing(item)
        self.assertFalse(self.me.containsItem(item))

        self.game.turnMain(f"drop {item.verbose_name}")
        self.assertIn("You are not holding", self.app.print_stack.pop())
Example #4
0
    def test_pour_out_non_liquid_non_container_from_container(self):
        item = Thing(self.game, "bead")
        item.size = 2
        item.moveTo(self.old_container)
        self.old_container.removeThing(self.liquid)

        self.game.turnMain("pour bottle into bowl")
        self.assertIn("You dump the bottle", self.app.print_stack.pop())
Example #5
0
 def test_doff_player_not_wearing_gives_player_not_wearing_message(self):
     item = Thing(self.game, "item")
     item.moveTo(self.start_room)
     self.game.turnMain("doff item")
     self.assertIn(
         "aren't wearing",
         self.app.print_stack.pop(),
         "Did not receive expected 'not wearing' scope message",
     )
Example #6
0
 def test_player_cannot_light_non_light_source(self):
     item = Thing(self.game, "ball")
     item.moveTo(self.me)
     self.game.turnMain("look")
     self.assertNotIn(self.start_room.desc, self.app.print_stack)
     self.assertIn("dark", self.app.print_stack.pop())
     self.game.turnMain("light ball")
     self.assertIn("not a light source", self.app.print_stack.pop())
     self.game.turnMain("look")
     self.assertNotIn(self.start_room.desc, self.app.print_stack)
Example #7
0
    def test_set_on_floor_add_item_to_outer_room(self):
        item = Thing(self.game, "thing")
        item.invItem = True
        item.moveTo(self.game.me)

        self.assertIsNot(item.location, self.start_room)

        self.game.turnMain(f"set thing on floor")

        self.assertIs(item.location, self.start_room)
Example #8
0
    def test_fill_container_containing_non_liquid_item(self):
        item = Thing(self.game, "bead")
        item.moveTo(self.new_container)

        self.game.turnMain("fill bowl from bottle")
        self.assertIn("You fill the bowl", self.app.print_stack.pop())
        self.assertIn("You dump", self.app.print_stack.pop())

        self.assertIs(item.location, self.start_room)
        self.assertIs(self.liquid.location, self.new_container)
Example #9
0
    def test_set_in_gives_too_big_message_if_item_too_big(self):
        item = Thing(self.game, "giant")
        item.size = 100000
        self.me.addThing(item)
        place = Container(self.game, "place")
        self.start_room.addThing(place)

        self.game.turnMain(f"set giant in place")

        self.assertIn("too big", self.app.print_stack.pop())
        self.assertFalse(place.containsItem(item))
    def test_pour_liquid_into_container_containing_non_liquid_item(self):
        item = Thing(self.game, "bead")
        item.moveTo(self.new_container)

        self.game.turnMain("pour bottle into bowl")
        self.assertIn("You pour", self.app.print_stack.pop())
        self.assertIn("You dump the contents of the bowl",
                      self.app.print_stack.pop())

        self.assertIs(item.location, self.start_room)
        self.assertIs(self.liquid.location, self.new_container)
Example #11
0
    def test_pour_out_non_liquid_non_container_item_too_large(self):
        item = Thing(self.game, "bead")
        item.size = 100
        item.moveTo(self.old_container)
        self.old_container.removeThing(self.liquid)

        self.game.turnMain("pour bottle into bowl")
        self.assertIn(
            self.new_container.does_not_fit_msg.format(
                item=item, self=self.new_container),
            self.app.print_stack,
        )
Example #12
0
    def test_verb_func_drops_item(self):
        item = Thing(self.game, self._get_unique_noun())
        item.invItem = True
        self.me.addThing(item)
        self.assertIn(item.ix, self.me.contains)
        self.assertEqual(len(self.me.contains[item.ix]), 1)
        self.assertIn(item, self.me.contains[item.ix])

        self.game.turnMain(f"drop {item.verbose_name}")

        self.assertItemNotIn(item, self.me.contains,
                             "Dropped item, but item still in inventory")
Example #13
0
    def test_cannot_set_under_non_underspace(self):
        item = Thing(self.game, self._get_unique_noun())
        item.invItem = True
        self.me.addThing(item)
        invalid_iobj = Thing(self.game, self._get_unique_noun())
        self.start_room.addThing(invalid_iobj)

        self.assertNotIn(item.ix, invalid_iobj.contains)

        self.game.turnMain(
            f"set {item.verbose_name} under {invalid_iobj.verbose_name}")

        self.assertNotIn(item.ix, invalid_iobj.contains)
Example #14
0
    def test_set_in_adds_item(self):
        item = Thing(self.game, self._get_unique_noun())
        item.invItem = True
        self.me.addThing(item)
        container = Container(self.game, self._get_unique_noun())
        self.start_room.addThing(container)

        self.assertNotIn(item.ix, container.contains)

        self.game.turnMain(
            f"set {item.verbose_name} in {container.verbose_name}")

        self.assertIn(item.ix, container.contains)
        self.assertIn(item, container.contains[item.ix])
Example #15
0
    def test_set_under_adds_item(self):
        item = Thing(self.game, self._get_unique_noun())
        item.invItem = True
        self.me.addThing(item)
        underspace = UnderSpace(self.game, self._get_unique_noun())
        self.start_room.addThing(underspace)

        self.assertNotIn(item.ix, underspace.contains)

        self.game.turnMain(
            f"set {item.verbose_name} under {underspace.verbose_name}")

        self.assertIn(item.ix, underspace.contains)
        self.assertIn(item, underspace.contains[item.ix])
Example #16
0
    def test_set_on_adds_item(self):
        item = Thing(self.game, self._get_unique_noun())
        item.invItem = True
        self.me.addThing(item)
        surface = Surface(self.game, self._get_unique_noun())
        self.start_room.addThing(surface)

        self.assertNotIn(item.ix, surface.contains)

        self.game.turnMain(
            f"set {item.verbose_name} on {surface.verbose_name}")

        self.assertIn(item.ix, surface.contains)
        self.assertIn(item, surface.contains[item.ix])
Example #17
0
    def test_pour_liquid_into_container_containing_non_liquid_item(self):
        # TODO: rethink the handling of priority.
        item = Thing(self.game, "bead")
        item.moveTo(self.new_container)

        self.game.turnMain("pour bottle into bowl")
        self.assertIn("You dump the bottle in the bowl",
                      self.app.print_stack.pop())
        self.assertIn("You dump out the bowl", self.app.print_stack.pop())
        self.assertIn("(First trying to dump out the bowl",
                      self.app.print_stack.pop())

        self.assertIs(item.location, self.start_room)
        self.assertIs(self.liquid.location, self.new_container)
    def test_pour_non_liquid_into_non_container(self):
        item = Thing(self.game, "bead")
        item.size = 2
        item.moveTo(self.old_container)
        self.old_container.removeThing(self.liquid)

        rock = Thing(self.game, "rock")
        rock.moveTo(self.start_room)

        self.game.turnMain("pour bottle into rock")
        self.assertIn("not a container", self.app.print_stack.pop())
Example #19
0
    def setUp(self):
        super().setUp()

        self.start_room.dark = True
        self.item = Thing(self.game, "item")
        self.start_room.addThing(self.item)

        self.light = LightSource(self.game, "light")
Example #20
0
 def test_drop_composite_child(self):
     machine = Thing(self.game, "machine")
     wheel = Thing(self.game, "wheel")
     machine.addComposite(wheel)
     machine.moveTo(self.me)
     self.game.turnMain("drop wheel")
     self.assertIn("wheel is attached to the machine",
                   self.app.print_stack.pop())
     self.assertTrue(self.me.containsItem(wheel))
Example #21
0
    def test_cannot_set_item_in_if_container_already_contains_liquid(self):
        item = Thing(self.game, "item")
        self.me.addThing(item)
        place = Container(self.game, "place")
        self.start_room.addThing(place)
        liquid = Liquid(self.game, "water", "water")
        liquid.moveTo(place)

        self.game.turnMain(f"set item in place")

        self.assertIn("already full of water", self.app.print_stack.pop())
        self.assertFalse(place.containsItem(item))
Example #22
0
    def setUp(self):
        super().setUp()
        self.parent = Thing(self.game, "cube")
        self.child = Container(self.game, "slot")
        self.container = Container(self.game, "box")
        self.nested_item = Thing(self.game, "bead")
        self.nested_item.moveTo(self.container)
        self.parent.addComposite(self.child)
        self.stacked1 = Thing(self.game, "tile")
        self.stacked2 = self.stacked1.copyThing()
        self.clothing = Clothing(self.game, "scarf")
        self.clothing1 = Clothing(self.game, "mitten")
        self.clothing2 = self.clothing1.copyThing()
        self.clothing3 = Clothing(self.game, "hat")

        self.me.addThing(self.parent)
        self.me.addThing(self.child)
        self.me.addThing(self.container)
        self.me.addThing(self.stacked1)
        self.me.addThing(self.stacked2)
        self.me.addThing(self.clothing)
        self.me.addThing(self.clothing1)
        self.me.addThing(self.clothing2)
        self.me.addThing(self.clothing3)

        self.game.turnMain("wear scarf")
        self.game.turnMain("wear hat")
        self.game.turnMain("wear mitten")
        self.game.turnMain("wear mitten")
Example #23
0
    def test_pour_item_implicitly_into_child_object(self):
        target = Thing(self.game, "thing")
        target.addComposite(self.new_container)
        target.moveTo(self.start_room)

        self.game.turnMain("pour wine in thing")
        self.assertIn("You dump", self.app.print_stack.pop())
        self.assertTrue(self.new_container.containsItem(self.liquid))
Example #24
0
    def test_set_composite_child_on_floor_gives_attached_message(self):
        parent = Thing(self.game, "thing")
        parent.moveTo(self.me)
        item = Thing(self.game, "handle")
        parent.addComposite(item)

        self.assertIsNot(item.location, self.start_room)

        self.game.turnMain(f"set handle on floor")

        self.assertIn("is attached to", self.app.print_stack.pop())
        self.assertIs(item.location, self.me)
Example #25
0
    def test_set_composite_child_under_gives_attached_message(self):
        parent = Thing(self.game, "thing")
        parent.moveTo(self.me)
        item = Thing(self.game, "handle")
        parent.addComposite(item)
        underspace = UnderSpace(self.game, "place")
        self.start_room.addThing(underspace)

        self.game.turnMain(f"set handle under place")

        self.assertIn("is attached to", self.app.print_stack.pop())
        self.assertIs(item.location, self.me)
Example #26
0
    def test_set_composite_child_in_gives_attached_message(self):
        parent = Thing(self.game, "thing")
        parent.moveTo(self.me)
        item = Thing(self.game, "handle")
        parent.addComposite(item)
        container = Container(self.game, "place")
        self.start_room.addThing(container)

        self.game.turnMain(f"set handle in place")

        self.assertIn("is attached to", self.app.print_stack.pop())
        self.assertIs(item.location, self.me)
Example #27
0
    def test_set_in_closed_container_implies_open_it_first(self):
        item = Thing(self.game, "item")
        self.me.addThing(item)
        place = Container(self.game, "place")
        place.giveLid()
        place.is_open = False
        self.start_room.addThing(place)

        self.game.turnMain(f"set item in place")

        self.assertIn("You set the item in the place",
                      self.app.print_stack.pop())
        self.assertIn("You open the place", self.app.print_stack.pop())
        self.assertIn("(First trying to open", self.app.print_stack.pop())
        self.assertTrue(place.is_open)
        self.assertTrue(place.containsItem(item))
Example #28
0
 def test_fill_container_non_container_non_liquid(self):
     item = Thing(self.game, "rock")
     item.moveTo(self.start_room)
     self.game.turnMain("fill bowl from rock")
     self.assertIn("no liquid in the rock", self.app.print_stack.pop())
Example #29
0
 def test_fill_non_container(self):
     item = Thing(self.game, "bead")
     item.moveTo(self.start_room)
     self.game.turnMain("fill bead from bottle")
     self.assertIn("can't fill that", self.app.print_stack.pop())
Example #30
0
 def test_pour_out_non_liquid_non_container(self):
     item = Thing(self.game, "bead")
     item.moveTo(self.start_room)
     self.game.turnMain("pour bead into bowl")
     self.assertIn("has nothing on", self.app.print_stack.pop())