def test_line(): """ tests normal use, lazy evaluation, and error propagation """ # test normal results test_result = [] def line_test(*test_xy): test_result.append(test_xy) return 1 assert libtcodpy.line(*LINE_ARGS, py_callback=line_test) == 1 assert test_result == INCLUSIVE_RESULTS # test lazy evaluation test_result = [] def return_false(*test_xy): test_result.append(test_xy) return False assert libtcodpy.line(*LINE_ARGS, py_callback=return_false) == 0 assert test_result == INCLUSIVE_RESULTS[:1]
def check_line_of_sight(x, y, x2, y2, map): return tcod.line(x, y, x2, y2, lambda xp, yp: not map.get_tile(xp, yp).block_sight)