コード例 #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
コード例 #19
0
def expect(branch, results):
    m = Minimap()
    _, buf = m.unconnected_branch_as_buffer_with_indices("Dungeons of Doom", branch)
    assert buf == results
コード例 #20
0
def expect_dlvl_at_index(dlvl, index, branch):
    m = Minimap()
    indices, _ = m.unconnected_branch_as_buffer_with_indices("", branch)
    assert indices[dlvl] == index
コード例 #21
0
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
コード例 #23
0
def expect(level, results):
    m = Minimap()
    buf = m.level_text_as_buffer(level)
    assert buf == results
コード例 #24
0
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