Ejemplo n.º 1
0
def test_change_card_goes_to_nearest_open_card_when_blocked():
    game = Game(Terminal(), Difficulty.NORMAL)
    key = Mock()

    key.name = 'KEY_UP'
    game.cur_card = (3, 4)
    game.matched = [(0, 4), (1, 4), (2, 4)]
    game.change_card(key)
    assert game.cur_card == (2, 3)

    key.name = 'KEY_LEFT'
    game.cur_card = (0, 4)
    game.matched = [(0, 0), (0, 1), (0, 2), (0, 3), (1, 4)]
    game.change_card(key)
    assert game.cur_card == (1, 3)

    key.name = 'KEY_DOWN'
    game.cur_card = (0, 0)
    game.matched = [(0, 1), (1, 0), (2, 0), (3, 0), (0, 2)]
    game.change_card(key)
    assert game.cur_card == (1, 1)

    key.name = 'KEY_RIGHT'
    game.cur_card = (0, 0)
    game.matched = [(0, 1), (1, 0), (0, 2), (0, 3), (0, 4)]
    game.change_card(key)
    assert game.cur_card == (1, 1)
Ejemplo n.º 2
0
def test_change_card_does_not_go_out_of_bounds_when_blocked():
    game = Game(Terminal(), Difficulty.NORMAL)
    key = Mock()

    key.name = 'KEY_RIGHT'
    game.cur_card = (2, 2)
    game.matched = [(2, 3), (2, 4), (3, 2), (3, 3), (1, 3), (1, 4), (0, 3),
                    (0, 4)]
    game.change_card(key)
    assert game.cur_card == (3, 4)

    key.name = 'KEY_RIGHT'
    game.cur_card = (0, 0)
    game.matched = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 1), (1, 2), (1, 3),
                    (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2),
                    (3, 3)]
    game.change_card(key)
    assert game.cur_card == (3, 4)
Ejemplo n.º 3
0
def test_change_card_works_properly():
    game = Game(Terminal(), Difficulty.NORMAL)
    game.cur_card = (2, 2)
    key = Mock()

    key.name = 'KEY_UP'
    game.change_card(key)
    assert game.cur_card == (1, 2)

    key.name = 'KEY_LEFT'
    game.change_card(key)
    assert game.cur_card == (1, 1)

    key.name = 'KEY_DOWN'
    game.change_card(key)
    assert game.cur_card == (2, 1)

    key.name = 'KEY_RIGHT'
    game.change_card(key)
    assert game.cur_card == (2, 2)
Ejemplo n.º 4
0
def test_change_card_skips_matched_cards():
    game = Game(Terminal(), Difficulty.NORMAL)
    game.cur_card = (2, 2)
    key = Mock()
    game.matched = [(1, 2), (0, 1), (1, 0), (2, 0), (3, 1), (3, 2)]

    key.name = 'KEY_UP'
    game.change_card(key)
    assert game.cur_card == (0, 2)

    key.name = 'KEY_LEFT'
    game.change_card(key)
    assert game.cur_card == (0, 0)

    key.name = 'KEY_DOWN'
    game.change_card(key)
    assert game.cur_card == (3, 0)

    key.name = 'KEY_RIGHT'
    game.change_card(key)
    assert game.cur_card == (3, 3)
Ejemplo n.º 5
0
def test_change_card_does_nothing_at_borders():
    game = Game(Terminal(), Difficulty.NORMAL)
    key = Mock()

    key.name = 'KEY_UP'
    game.cur_card = (0, 0)
    game.change_card(key)
    assert game.cur_card == (0, 0)

    key.name = 'KEY_LEFT'
    game.change_card(key)
    assert game.cur_card == (0, 0)

    key.name = 'KEY_DOWN'
    game.cur_card = (3, 4)
    game.change_card(key)
    assert game.cur_card == (3, 4)

    key.name = 'KEY_RIGHT'
    game.change_card(key)
    assert game.cur_card == (3, 4)