Пример #1
0
def test_drawing_the_graph_draws_the_current_level_in_a_different_color():
    window = newpad() 
    window.should_receive("chgat").times(3)

    m = Minimap()
    dungeon = fixed_graph()
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #2
0
def test_drawing_the_graph_draws_the_current_level_in_a_different_color():
    window = newpad()
    window.should_receive("chgat").times(3)

    m = Minimap()
    dungeon = fixed_graph()
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #3
0
def test_color_doesnt_color_the_ellipsis():
    window = newpad()
    window.should_receive("chgat").times(3)

    m = Minimap()
    dungeon = fixed_graph()
    dungeon.current = [l for l in dungeon.levels if l.dlvl == 5][0]
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #4
0
def test_color_doesnt_color_the_ellipsis():
    window = newpad()
    window.should_receive("chgat").times(3)

    m = Minimap()
    dungeon = fixed_graph()
    dungeon.current = [l for l in dungeon.levels if l.dlvl == 5][0]
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #5
0
def test_color_only_the_text_not_the_border():
    window = newpad()
    window.should_receive("chgat").with_args(3, 1, 25, curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(4, 1, 25, curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(5, 1, 25, curses.A_BOLD | 0).times(1)

    m = Minimap()
    dungeon = fixed_graph()
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #6
0
def test_color_only_the_text_not_the_border():
    window = newpad()
    window.should_receive("chgat").with_args(3, 1, 25,
                                             curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(4, 1, 25,
                                             curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(5, 1, 25,
                                             curses.A_BOLD | 0).times(1)

    m = Minimap()
    dungeon = fixed_graph()
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #7
0
def test_drawing_a_graph_with_multiple_branches_colors_a_current_level_on_the_main_branch():
    levels = level_chain(3, "main")
    levels[1].change_branch_to("mines")

    window = newpad() 
    window.should_receive("chgat").with_args(3, 1, 25, curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(4, 1, 25, curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(5, 1, 25, curses.A_BOLD | 0).times(1)

    m = Minimap()
    dungeon = fixed_graph(levels)
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #8
0
def test_drawing_a_graph_with_multiple_branches_colors_a_current_level_on_the_main_branch(
):
    levels = level_chain(3, "main")
    levels[1].change_branch_to("mines")

    window = newpad()
    window.should_receive("chgat").with_args(3, 1, 25,
                                             curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(4, 1, 25,
                                             curses.A_BOLD | 0).times(1)
    window.should_receive("chgat").with_args(5, 1, 25,
                                             curses.A_BOLD | 0).times(1)

    m = Minimap()
    dungeon = fixed_graph(levels)
    m.draw_dungeon(dungeon, window, 0, 0, get_color)
Пример #9
0
def test_a_current_level_in_a_single_branch_is_properly_bounded():
    levels = level_chain(3, "main")
    window = newpad() 
    m = Minimap()
    dungeon = fixed_graph(levels)
    x, y = m.draw_dungeon(dungeon, window, 0, 0, get_color)[-2:]

    assert x == 0
    assert y == 3
Пример #10
0
def test_a_current_level_in_a_single_branch_is_properly_bounded():
    levels = level_chain(3, "main")
    window = newpad()
    m = Minimap()
    dungeon = fixed_graph(levels)
    x, y = m.draw_dungeon(dungeon, window, 0, 0, get_color)[-2:]

    assert x == 0
    assert y == 3
Пример #11
0
def test_drawing_a_dungeon_with_one_branch_offset_properly_computes_bounds():
    levels = level_chain(3, "main")
    window = newpad() 
    m = Minimap()
    dungeon = fixed_graph(levels)
    left, right, top, bottom = m.draw_dungeon(dungeon, window, 10, 10, get_color)[:-2]

    assert left == 10
    assert right == 37
    assert top == 10
    assert bottom == 23
Пример #12
0
def test_a_current_level_on_a_second_branch_is_properly_bounded():
    levels = level_chain(3, "main")
    levels[1].change_branch_to("mines")

    window = newpad() 
    m = Minimap()
    dungeon = fixed_graph(levels)
    dungeon.current = levels[1]
    x, y = m.draw_dungeon(dungeon, window, 0, 0, get_color)[-2:]

    assert x == 30
    assert y == 5
Пример #13
0
def test_a_current_level_on_a_second_branch_is_properly_bounded():
    levels = level_chain(3, "main")
    levels[1].change_branch_to("mines")

    window = newpad()
    m = Minimap()
    dungeon = fixed_graph(levels)
    dungeon.current = levels[1]
    x, y = m.draw_dungeon(dungeon, window, 0, 0, get_color)[-2:]

    assert x == 30
    assert y == 5
Пример #14
0
def test_drawing_a_dungeon_with_one_branch_properly_computes_bounds():
    levels = level_chain(3, "main")
    window = newpad()
    m = Minimap()
    dungeon = fixed_graph(levels)
    left, right, top, bottom = m.draw_dungeon(dungeon, window, 0, 0,
                                              get_color)[:-2]

    assert left == 0
    assert right == 27
    assert top == 0
    assert bottom == 13
Пример #15
0
def test_drawing_a_dungeon_with_multiple_branches_properly_computes_bounds():
    levels = level_chain(3, "main")
    levels[1].change_branch_to("mines")

    window = newpad() 
    m = Minimap()
    dungeon = fixed_graph(levels)
    left, right, top, bottom = m.draw_dungeon(dungeon, window, 0, 0, get_color)[:-2]

    assert left == 0
    assert right == 57
    assert top == 0
    assert bottom == 12
Пример #16
0
def test_drawing_a_dungeon_with_multiple_sub_branches_properly_computes_bounds():
    levels = level_chain(4, "main")
    levels[1].change_branch_to("mines")
    levels[2].change_branch_to("other")
    more_main = level_chain(3, "main", 2)
    more_main[0].add_stairs(levels[0], (5, 5))
    levels[0].add_stairs(more_main[0], (5, 5))

    window = newpad() 
    m = Minimap()
    dungeon = fixed_graph(levels + more_main)
    left, right, top, bottom = m.draw_dungeon(dungeon, window, 0, 0, get_color)[:-2]

    assert left == 0
    assert right == 87
    assert top == 0
    assert bottom == 16
Пример #17
0
def test_drawing_a_dungeon_with_multiple_sub_branches_properly_computes_bounds(
):
    levels = level_chain(4, "main")
    levels[1].change_branch_to("mines")
    levels[2].change_branch_to("other")
    more_main = level_chain(3, "main", 2)
    more_main[0].add_stairs(levels[0], (5, 5))
    levels[0].add_stairs(more_main[0], (5, 5))

    window = newpad()
    m = Minimap()
    dungeon = fixed_graph(levels + more_main)
    left, right, top, bottom = m.draw_dungeon(dungeon, window, 0, 0,
                                              get_color)[:-2]

    assert left == 0
    assert right == 87
    assert top == 0
    assert bottom == 16
def expect(dungeon, results, x_offset=0, y_offset=0):
    m = Minimap()
    pad = flexmock(MemoryPad())
    pad.should_receive("chgat")
    m.draw_dungeon(dungeon, pad, x_offset, y_offset, get_color)
    assert results == pad.buf
def expect(dungeon, results, x_offset=0, y_offset=0):
    m = Minimap()
    pad = flexmock(MemoryPad())
    pad.should_receive("chgat")
    m.draw_dungeon(dungeon, pad, x_offset, y_offset, get_color)
    assert results == pad.buf