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

后端 未结 4 509
傲寒
傲寒 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条回答
  •  旧时难觅i
    2020-12-07 06:24

    An enumeration (https://docs.python.org/3.5/library/enum.html) would be appropriate. For rich comparisons (and ordering) you should also consider implementing some or all of the __eq__, __ne__, __lt__, __le__, __gt__, __ge__ methods (from https://docs.python.org/3/reference/datamodel.html) on the Card class.

提交回复
热议问题