示例#1
0
def test_switching_a_branch_changes_the_current_level_to_a_new_branch():
    m = Map(level(1), 2, 2)

    second = flexmock(Level(2))
    second.should_receive("change_branch_to").with_args("mines").once
    m.levels.add(second)
    m.current = second
    m.change_branch_to("mines")
示例#2
0
def test_switching_a_branch_changes_the_current_level_to_a_new_branch():
    m = Map(level(1), 2, 2)

    second = flexmock(Level(2))
    second.should_receive("change_branch_to").with_args("mines").once
    m.levels.add(second)
    m.current = second
    m.change_branch_to("mines")
示例#3
0
def test_moving_up_stairs_to_an_unknown_level_creates_a_new_link_and_level():
    m = Map(level(1), 5, 5)

    fifth = flexmock(Level(5))
    fifth.should_receive("has_stairs_at").and_return(False).once
    fifth.should_receive("add_stairs").with_args(object, (5, 5))

    m.current = fifth

    m.travel_by_stairs(4, (4, 4))

    assert m.current.dlvl == 4
    assert len(m.levels) == 2
示例#4
0
def test_teleporting_to_an_undiscovered_level_doesnt_link():
    m = Map(level(1), 1, 1)

    first = flexmock(Level(1))
    m.current = first

    first.should_receive("add_stairs").never
    flexmock(Level).new_instances(flexmock(Level(5))).once

    m.travel_by_teleport(5, (5, 5))

    assert m.current.dlvl == 5
    assert len(m.levels) == 2 
示例#5
0
def test_teleporting_to_an_undiscovered_level_doesnt_link():
    m = Map(level(1), 1, 1)

    first = flexmock(Level(1))
    m.current = first

    first.should_receive("add_stairs").never
    flexmock(Level).new_instances(flexmock(Level(5))).once

    m.travel_by_teleport(5, (5, 5))

    assert m.current.dlvl == 5
    assert len(m.levels) == 2
示例#6
0
def test_moving_up_stairs_to_an_unknown_level_creates_a_new_link_and_level():
    m = Map(level(1), 5, 5)

    fifth = flexmock(Level(5))
    fifth.should_receive("has_stairs_at").and_return(False).once
    fifth.should_receive("add_stairs").with_args(object, (5, 5))

    m.current = fifth

    m.travel_by_stairs(4, (4, 4))

    assert m.current.dlvl == 4
    assert len(m.levels) == 2
示例#7
0
def test_traveling_down_when_a_link_doesnt_exist_creates_a_new_link_and_level():
    m = Map(level(1), 1, 1)

    first = flexmock(Level(1))
    first.should_receive("has_stairs_at").and_return(False).once
    first.should_receive("add_stairs").with_args(object, (1, 1))

    m.current = first

    flexmock(Level).new_instances(flexmock(Level(5))).once

    m.travel_by_stairs(2, (2, 2))

    assert len(m.levels) == 2
示例#8
0
def test_traveling_down_an_existing_link_doesnt_create_a_new_link_or_level():
    m = Map(level(1), 1, 1)

    second = Level(2)

    first = flexmock(Level(1))
    first.should_receive("has_stairs_at").and_return(True).once
    first.should_receive("stairs_at").and_return(second)
    first.should_receive("add_stairs").never

    m.current = first

    m.travel_by_stairs(2, (2, 2))
    
    assert m.current == second
示例#9
0
def test_moving_upstairs_from_to_a_known_level_that_isnt_yet_linked_with_the_current():
    m = Map(level(1), 2, 2)

    first = flexmock(Level(1))
    second = flexmock(Level(2))

    m.levels = set([first, second])
    m.current = second 

    first.should_receive("add_stairs").with_args(second, (1, 1)).once
    second.should_receive("add_stairs").with_args(first, (2, 2)).once

    m.travel_by_stairs(1, (1, 1))

    assert m.current.dlvl == 1
示例#10
0
def test_traveling_down_when_a_link_doesnt_exist_creates_a_new_link_and_level(
):
    m = Map(level(1), 1, 1)

    first = flexmock(Level(1))
    first.should_receive("has_stairs_at").and_return(False).once
    first.should_receive("add_stairs").with_args(object, (1, 1))

    m.current = first

    flexmock(Level).new_instances(flexmock(Level(5))).once

    m.travel_by_stairs(2, (2, 2))

    assert len(m.levels) == 2
示例#11
0
def test_traveling_down_an_existing_link_doesnt_create_a_new_link_or_level():
    m = Map(level(1), 1, 1)

    second = Level(2)

    first = flexmock(Level(1))
    first.should_receive("has_stairs_at").and_return(True).once
    first.should_receive("stairs_at").and_return(second)
    first.should_receive("add_stairs").never

    m.current = first

    m.travel_by_stairs(2, (2, 2))

    assert m.current == second
示例#12
0
def test_moving_upstairs_from_to_a_known_level_that_isnt_yet_linked_with_the_current(
):
    m = Map(level(1), 2, 2)

    first = flexmock(Level(1))
    second = flexmock(Level(2))

    m.levels = set([first, second])
    m.current = second

    first.should_receive("add_stairs").with_args(second, (1, 1)).once
    second.should_receive("add_stairs").with_args(first, (2, 2)).once

    m.travel_by_stairs(1, (1, 1))

    assert m.current.dlvl == 1