2
I’m having the following problem, I have a letter class and use the magic methods eq, ne, le, it’s, ge, gt to be able to compare the value of two cards and also to be able to use the Sort function, and for that it works the way I expected but when I need to use the remove method from a list to remove a card simply either remove the wrong card or remove none. Follows a part of the class code:
class Card(object):
def __init__(self, game, value, suit, args={}):
super(Card, self).__init__()
self.front = pygame.image.load("images/cards/card_{}_{}.png".format(
suit, value)).convert()
self.back = back.convert()
self.image = self.front
self.rect = self.front.get_rect(**args)
self.sound = sounds["card_place_1"]
self.game = game
self.value = value
self.suit = suit
self.moved = False
self.visible = True
def __eq__(self, other):
return self.manilha == other.manilha
def __ne__(self, other):
return self.manilha != other.manilha
def __lt__(self, other):
return self.manilha < other.manilha
def __le__(self, other):
return self.manilha <= other.manilha
def __gt__(self, other):
return self.manilha > other.manilha
def __ge__(self, other):
return self.manilha >= other.manilha
@property
def manilha(self):
if self.image == self.back:
return -1
elif "4567qjka23".find(self.value) == "34567qjka2".find(
self.game.vira.value):
return {"diamonds": 10, "spades": 11, "hearts": 12, "clubs": 13}[
self.suit]
else:
return "4567qjka23".find(self.value)
And where in the code is the
remove
that’s giving trouble?– Pedro von Hertwig Batista