Ejemplo n.º 1
0
    def _draw_game_labels(self, current_player: Player):
        label: Font = Font(MAIN_FONT, MEDIUM_TEXT)
        label_surface: Surface = label.render(
            'Turn: ',
            True,
            BLACK
        )
        label_rect: Rect = label_surface.get_rect()
        label_rect.center = ((label_rect.width / 2) + 50, self._height - 50)
        self._screen.blit(label_surface, label_rect)

        player_label: Font = Font(TITLE_FONT, MEDIUM_TEXT)
        player_label_surface: Surface = player_label.render(
            current_player.name(),
            True,
            RED_TILE if current_player.color() == Color.RED else BLUE_TILE
        )
        plauer_label_rect: Rect = player_label_surface.get_rect()
        plauer_label_rect.center = (
            (plauer_label_rect.width / 2) + 50 + label_rect.width,
            self._height - 50
        )

        self._screen.blit(player_label_surface, plauer_label_rect)
Ejemplo n.º 2
0
import random
from src.models.board import Board
from src.models.player import Player
from src.models.challenges import challenges
from src.services import utilities

game = Board()
turn_count = 1
P1 = Player()
P2 = Player()
P1.name = input('What is Player 1\'s name? ')
P2.name = input('What is Player 2\'s name? ')
players = [P1, P2]
starting_player = random.choice(players)

while turn_count < 10:
    print(f'The current turn is {turn_count}')
    current_player = utilities.determine_player(turn_count, starting_player,
                                                players)
    print(f'The current player is {current_player.name}.')

    print(f'{P1.name} has {P1.cards}')
    print(f'{P2.name} has {P2.cards}')

    selected_card = input('Choose a card from your hand ... ')
    while not utilities.has_card_in_hand(current_player, selected_card):
        selected_card = input('That card is not in your hand. Try again ... ')

    played_card = [
        item for item in current_player.hand if item['name'] == selected_card
    ][0]