How can I compare the values of two playing cards when they have a value and a suit? Python3

后端 未结 4 508
傲寒
傲寒 2020-12-07 05:42

I am trying to make a text based object oriented card game. Two players draw a card each from a deck of cards, and the player with the strongest card wins. I have four class

4条回答
  •  无人及你
    2020-12-07 06:37

    You could implement operators for your Card class __gt__(), __lt__(), etc ...

    than you can use a number of standard library functions like max() to determine the higher value card or deck and could even use sort() to simply sort a 'hand' for example a list [Card, Card, ...].

提交回复
热议问题