Initial commit
This commit is contained in:
44
source/cardgame/card_application.py
Normal file
44
source/cardgame/card_application.py
Normal file
@ -0,0 +1,44 @@
|
||||
"""
|
||||
Fausse bataille avec les mauvaises règles.
|
||||
|
||||
Ce n'est absolument pas comme ça qu'on joue à la bataille en
|
||||
temps normal, mais je n'y avais pas joué depuis 30 ans.
|
||||
Ceci étant, avec des règles simples, on arrive à un truc...exécutable.
|
||||
"""
|
||||
from source.cardgame.cards import Deck, Card
|
||||
|
||||
|
||||
def main():
|
||||
full_deck: Deck = Deck(full=True, shuffled=True)
|
||||
player1_deck: Deck = Deck()
|
||||
player2_deck: Deck = Deck()
|
||||
player1_score: int = 0 # dégueulasse
|
||||
player2_score: int = 0
|
||||
# Choice was to distribute cards from one deck to player hands.
|
||||
# Could be any strategy (and could be better).
|
||||
while full_deck:
|
||||
full_deck.pop_to(player1_deck)
|
||||
full_deck.pop_to(player2_deck)
|
||||
|
||||
while player1_deck:
|
||||
# Show available cards to pick
|
||||
selected_index: int = player1_deck.pick_input()
|
||||
selected_card: Card = player1_deck.pop(selected_index)
|
||||
opponent_card: Card = player2_deck.pop(0)
|
||||
print(f"Player 1 plays {selected_card.full_name}")
|
||||
print(f"Player 2 plays {opponent_card.full_name}")
|
||||
if selected_card < opponent_card:
|
||||
player2_score += 1
|
||||
print("Computer wins this round.")
|
||||
elif selected_card > opponent_card:
|
||||
player1_score += 1
|
||||
print("You won this round.")
|
||||
|
||||
print(f"Player 1 final score: {player1_score}")
|
||||
print(f"Player 2 final score: {player2_score}")
|
||||
if player1_score == player2_score:
|
||||
print("Pathetic!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user