Beispiel #1
0
    def start_turn(self):
        game = self._game
        game.new_turn()

        # TURN-FACEDOWN
        game.turn.drop_char(Card(game.characters.take_random()).facedown)

        # TURN-FACEUP
        if self._config.turn_unused_faceup_chars:
            faceup_cards = self._config.turn_unused_faceup_chars
        else:
            faceup_cards = {2: 2, 3: 2, 4: 2, 5: 1, 6: 0, 7: 0}[len(self._game.players)]
        for _ in range(faceup_cards):
            card = game.characters.take_random()

            # TURN-FACEUP-KING
            if card == Character.King:
                card = game.characters.take_random()
                game.characters.put_on_bottom(Character.King)

            game.turn.drop_char(card)

        self.fire_event('turn_started')

        # TURN-PICK-FIRST, TURN-PICK
        for player in game.players.order_by_char_selection():
            controller = self.player_controller(player)
            selected_char = controller.pick_char(game.characters, ShadowPlayer(player, me=True), ShadowGame(player, game))
            game.characters.take(selected_char)
            player.char = selected_char

        # TURN-PICK-FACEDOWN
        while game.characters:
            game.turn.drop_char(Card(game.characters.take_from_top()).facedown)
Beispiel #2
0
def test_card_should_wrap_containee():
    # arrange
    payload = Payload(42)

    # act
    card = Card(payload)

    # assert
    assert card.data == 42

    card.data = 43
    assert card.data == 43
Beispiel #3
0
def test_card_should_wrap_primitive_type():
    # arrange
    s = 'str'

    # act
    card = Card(s).facedown

    # assert
    assert not card
Beispiel #4
0
def test_card_should_nullify_containee_when_facedown():
    # arrange
    payload = Payload(42)

    # act
    card = Card(payload).facedown

    # assert
    assert card.data is None
Beispiel #5
0
def test_card_should_still_raise_on_unknown_attr_when_facedown():
    # arrange
    payload = Payload(42)

    # act
    card = Card(payload).facedown

    # assert
    with pytest.raises(AttributeError):
        card.something
Beispiel #6
0
 def __init__(self, player: Player, me=False):
     self.player_id = player.player_id
     self.gold = player.gold
     self.name = player.name
     self.hand = [
         district if me else Card(district).facedown
         for district in player.hand
     ]
     self.char = player.char
     self.city = player.city
Beispiel #7
0
def test_card_facedown_equality():
    assert Card(42).facedown != Card(42)
    assert Card(42).facedown == Card(43).facedown
Beispiel #8
0
def test_card_faceup_equality():
    assert Card(42) == Card(42)
    assert Card(42) != Card(43)