separate game logic from bot interface,
introduce exceptions instead of boolean returns, remove repetitive code, begin unit tests, improve docstrings, update to python-telegram-bot==4.1.1, add ponyorm settings classes (unused)
This commit is contained in:
10
card.py
10
card.py
@ -180,9 +180,7 @@ STICKERS_GREY = {
|
||||
|
||||
|
||||
class Card(object):
|
||||
"""
|
||||
This class represents a card.
|
||||
"""
|
||||
"""This class represents an UNO card"""
|
||||
|
||||
def __init__(self, color, value, special=None):
|
||||
self.color = color
|
||||
@ -205,16 +203,16 @@ class Card(object):
|
||||
return '%s%s' % (COLOR_ICONS[self.color], self.value.capitalize())
|
||||
|
||||
def __eq__(self, other):
|
||||
""" Needed for sorting the cards """
|
||||
"""Needed for sorting the cards"""
|
||||
return str(self) == str(other)
|
||||
|
||||
def __lt__(self, other):
|
||||
""" Needed for sorting the cards """
|
||||
"""Needed for sorting the cards"""
|
||||
return str(self) < str(other)
|
||||
|
||||
|
||||
def from_str(string):
|
||||
""" Decode a Card object from a string """
|
||||
"""Decodes a Card object from a string"""
|
||||
if string not in SPECIALS:
|
||||
color, value = string.split('_')
|
||||
return Card(color, value)
|
||||
|
Reference in New Issue
Block a user