bataille.py

Created by thibaut-lyon

Created on April 16, 2020

717 Bytes


# Bataille de de cartes
from cartes import JeuDeCartes
jeuA = JeuDeCartes() # instanciation du premier jeu
jeuB = JeuDeCartes() # instanciation du second jeu
jeuA.battre() # mélange de chacun
jeuB.battre()
pA, pB = 0, 0 # compteurs de points des joueurs A et B
# tirer 52 fois une carte de chaque jeu :
for n in range(52):
 cA, cB = jeuA.tirer(), jeuB.tirer()
 vA, vB = cA[0], cB[0] # valeurs de ces cartes
 if vA>vB:
  pA=1
 elif vB>vA:
  pB=1 # (rien ne se passe si vA = vB)
 # affichage des points successifs et des cartes tirées :
 print("{} * {} ==> {} * {}".format(jeuA.nom_carte(cA),
 jeuB.nom_carte(cB), pA, pB))
print("le joueur A obtient {} pts, le joueur B en obtient {}.".format(pA, pB))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.