Preliminaries Throughout this assignment you will be using the following Card an
ID: 3718206 • Letter: P
Question
Preliminaries Throughout this assignment you will be using the following Card and Player classes, which are available in the file war classes.py: class Card: def init_(self, rank, suit): self._rank- rank self._suit-suit class Player: CSE 101 - Spring 2018 Homework #5 Page 1 def _init-(self, player_num, score, cards): self._player_num-player_num self._score-score self-cards = cards We see that a Card object is defined by its rank and suit attributes, and a Player object is defined by its ID number, score and card list attributes.Explanation / Answer
def play_normal_round(p1,p2):
tie = 0
while(True):
if len(p1._cards) == 0 || len(p2._cards) == 0:
break
p1card = p1.draw_card()
p2card = p2.draw_card()
if p1card.rank == p2card.rank:
print("WAR!")
tie = tie + 1
if p1card.rank > p2card.rank:
p1._score = 2 + tie * 2
print("Player 1 won the round, scoring", p1._score, "points")
tupl = (1,p1._score)
return tup1
break
if p2card.rank > p1card.rank:
p2._score = 2 + tie * 2
print("Player 2 won the round, scoring", p2._score, "points")
tup2 = (2,p2._score)
return tup1
break
tup3 = (0,0)
return tup3