示例#1
0
    def test_should_add_obj_to_correct_layer_if_not_given(self):
        p = interfaces.Position(1, 1)
        for (o, layer) in (
            (tiles.Wall(p), tiles.Tile),
            (tiles.EvidencePanel(p), tiles.Tile),
            (monsters.Dalek(p), monsters.Monster),
            (monsters.StaticCamera(p), monsters.Monster),
            (items.HandTeleport(p, 1.0), items.Item),
            (items.RemoteControl(p, 1.0), items.Item),
        ):
            assert_is(self.map.add(o), None)

            assert_is(self.map.find_at_pos(p, layer), o)
            assert_is(o.map, self.map)

            assert_is(self.map.remove(o), None)
            assert_is(self.map.find_at_pos(p, layer), None)
示例#2
0
    def test_should_remove_obj_from_given_layer(self):
        # almost exactly the same
        p = interfaces.Position(1, 1)
        for (o, layer) in (
            (tiles.Wall(p), tiles.Tile),
            (tiles.EvidencePanel(p), tiles.Tile),
            (monsters.Dalek(p), monsters.Monster),
            (monsters.StaticCamera(p), monsters.Monster),
            (items.HandTeleport(p, 1.0), items.Item),
            (items.RemoteControl(p, 1.0), items.Item),
        ):

            assert_is(self.map.add(o, layer), None)
            assert_is(o.map, self.map)
            assert_is(self.map.find_at_pos(p, layer), o)

            assert_is(self.map.remove(o, layer), None)

            assert_is(o.pos, None)
            assert_is(self.map.find_at_pos(p, layer), None)
示例#3
0
    def test_should_use_layer_parameter_if_given(self):
        p = interfaces.Position(1, 1)
        p1 = p + (1, 1)
        for (o, layer) in (
            (tiles.Wall(p), tiles.Tile),
            (tiles.EvidencePanel(p), tiles.Tile),
            (monsters.Dalek(p), monsters.Monster),
            (monsters.StaticCamera(p), monsters.Monster),
            (items.HandTeleport(p, 1.0), items.Item),
            (items.RemoteControl(p, 1.0), items.Item),
        ):
            assert_is(self.map.add(o, layer), None)

            assert_equal(self.map.move(o, p1, layer), 0.0)

            assert_is(o.map, self.map)
            assert_is(self.map.find_at_pos(p, layer), None)
            assert_is(self.map.find_at_pos(p1, layer), o)
            assert_equal(o.pos, p1)

            assert_is(self.map.remove(o, layer), None)
            assert_is(self.map.find_at_pos(p, layer), None)