X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=lightcards%2Fdeck.py;h=823946f0266c35e7f4c3c86e33271e4ec3823980;hb=b63db112dd72300f5948795077443280e43b08ba;hp=2136ecc589bdc0f843a2db68399b64385e1934b9;hpb=da5f204dfb0e33a99bba1fa00842b253bf9947e0;p=lightcards.git diff --git a/lightcards/deck.py b/lightcards/deck.py index 2136ecc..823946f 100644 --- a/lightcards/deck.py +++ b/lightcards/deck.py @@ -1,8 +1,28 @@ # Classes pertaining to the card deck # Armaan Bhojwani 2021 -class Card(list): - starred = False + +class Card: + """Class containing the card information.""" + + def __init__(self, inp): + self.starred = False + self.side = 0 + self.front = "" + self.back = "" + if len(inp) >= 1: + self.front = inp[0] + if len(inp) >= 2: + self.back = inp[1] + + def __str__(self): + return f"{self.front}, {self.back}" + + def unStar(self): + self.starred = False + + def star(self): + self.starred = True def toggleStar(self): if self.starred: @@ -10,36 +30,48 @@ class Card(list): else: self.starred = True - def getStar(self): + def printStar(self): if self.starred: return "★ Starred ★" else: return "Not starred" + def get(self): + if self.side == 0: + return (self.front, self.back) + else: + return (self.back, self.front) + + def flip(self): + if self.side == 0: + self.side = 1 + else: + self.side = 0 + + def get_reverse(self): + if self.side == 0: + return 1 + else: + return 0 + + +class Status: + """Keeps track of where in the deck the user is""" -class Status(): - index = 0 - side = 0 + def __init__(self): + self.index = 0 + self.side = 0 def forward(self, stack): - if not self.index == len(stack) - 1: + if self.index != len(stack): self.index += 1 def back(self): if not self.index < 1: self.index -= 1 - def flip(self): + def get_reverse(self): if self.side == 0: - self.side = 1 + return 1 else: - self.side = 0 - - def setSide(self, inp): - self.side = inp - - def getSide(self): - return self.side - - def getIdx(self): - return self.index + return 0