Exemplo n.º 1
0
def test_player_can_play_two_lands_in_different_turns():
    new_game = Game()
    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=data.black_land_deck)
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land_to_play = bernardo.position.hand[0]
    bernardo.play(land_to_play)

    new_game.move_to_next_step() #combat - declare_attackers
    new_game.move_to_next_step() #combat - declare_blockers
    new_game.move_to_next_step() #combat - damage
    new_game.move_to_next_step() #main - main
    new_game.move_to_next_step() #main - main (other player)

    new_game.move_to_next_step() #combat - declare_attackers
    new_game.move_to_next_step() #combat - declare_blockers
    new_game.move_to_next_step() #combat - damage
    new_game.move_to_next_step() #main - main
    new_game.move_to_next_step() #main - main (other player)

    land_to_play = bernardo.position.hand[0]
    bernardo.play(land_to_play)

    assert len(bernardo.position.hand) == 5
    assert len(bernardo.position.battlefield) == 2
    assert bernardo.position.battlefield[1] == land_to_play
Exemplo n.º 2
0
def test_playing_two_lands_in_the_same_turn_fails():
    new_game = Game()
    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=data.black_land_deck)
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land_to_play = bernardo.position.hand[0]
    bernardo.play(land_to_play)

    land_to_play = bernardo.position.hand[0]
    assert_raises(InvalidOperationError, bernardo.play, card=land_to_play, exc_pattern=r"The player can only play one land per turn.")
Exemplo n.º 3
0
def test_player_can_play_land():
    new_game = Game()
    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=data.black_land_deck)
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land_to_play = bernardo.position.hand[0]
    bernardo.play(land_to_play)

    assert len(bernardo.position.hand) == 6
    assert len(bernardo.position.battlefield) == 1
    assert bernardo.position.battlefield[0] == land_to_play
Exemplo n.º 4
0
def test_generating_mana_out_of_a_tapped_land_raises():
    new_game = Game()
    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=data.black_land_deck)
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land_to_play = bernardo.position.hand[0]
    bernardo.play(land_to_play)

    land_to_play.GenerateManaAndTap() #tap to generate mana

    assert_raises(InvalidOperationError, land_to_play.GenerateManaAndTap, exc_pattern=r"The player can't generate mana out of a tapped card.")
Exemplo n.º 5
0
def test_generate_mana_and_tap_ability_taps_card():
    new_game = Game()

    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=deepcopy(data.black_land_deck))
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land = bernardo.position.hand[0]
    bernardo.play(land)

    land.GenerateManaAndTap()

    assert land.is_tapped
Exemplo n.º 6
0
def test_generate_mana_and_tap_ability_raises_when_card_is_tapped():
    new_game = Game()

    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=deepcopy(data.black_land_deck))
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land = bernardo.position.hand[0]
    bernardo.play(land)

    land.GenerateManaAndTap()

    assert_raises(InvalidOperationError, land.GenerateManaAndTap, exc_pattern=r"The player can't generate mana out of a tapped card.")
Exemplo n.º 7
0
def test_player_can_tap_lands_to_get_mana():
    new_game = Game()
    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=data.black_land_deck)
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land_to_play = bernardo.position.hand[0]
    bernardo.play(land_to_play)

    land_to_play.GenerateManaAndTap() #tap to generate mana

    assert bernardo.position.mana["green"] == 1
    assert bernardo.position.mana["black"] == 0
    assert bernardo.position.mana["blue"] == 0
    assert bernardo.position.mana["red"] == 0
    assert bernardo.position.mana["white"] == 0
    assert bernardo.position.mana["colorless"] == 0

    assert land_to_play.is_tapped
Exemplo n.º 8
0
def test_generate_mana_and_tap_ability_publishes_mana_generated_event():
    new_game = Game()
    messages = []

    def handle_event(game, position, card):
        messages.append("Card %s tapped to generate 1 %s mana" % (card.name, card.color))

    new_game.bus.subscribe('mana_generated', handle_event)

    bernardo = Player(name="Bernardo", deck=deepcopy(data.green_land_deck))
    john = Player(name="John", deck=deepcopy(data.black_land_deck))
    new_game.add_player(bernardo)
    new_game.add_player(john)

    new_game.initialize()

    land = bernardo.position.hand[0]
    bernardo.play(land)

    land.GenerateManaAndTap()

    assert len(messages) == 1
    assert messages[0] == "Card Forest tapped to generate 1 green mana"