Пример #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_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
Пример #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_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
Пример #8
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
Пример #9
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)
Пример #10
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
Пример #11
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
Пример #12
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)
Пример #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_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
Пример #15
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)
Пример #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
Пример #18
0
def expect(level, results):
    m = Minimap()
    buf = m.level_text_as_buffer(level)
    assert buf == results
def expect(branch, results):
    m = Minimap()
    _, buf = m.unconnected_branch_as_buffer_with_indices("Dungeons of Doom", branch)
    assert buf == results
def expect_dlvl_at_index(dlvl, index, branch):
    m = Minimap()
    indices, _ = m.unconnected_branch_as_buffer_with_indices("", branch)
    assert indices[dlvl] == index
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
Пример #22
0
def expect_dlvl_at_index(dlvl, index, branch):
    m = Minimap()
    indices, _ = m.unconnected_branch_as_buffer_with_indices("", branch)
    assert indices[dlvl] == index
def expect(level, results):
    m = Minimap()
    buf = m.level_text_as_buffer(level)
    assert buf == results
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
Пример #25
0
def expect(branch, results):
    m = Minimap()
    _, buf = m.unconnected_branch_as_buffer_with_indices(
        "Dungeons of Doom", branch)
    assert buf == results