added some animation sketches to 5/10

This commit is contained in:
Oystein Kristoffer Tveit 2020-09-28 18:27:57 +02:00
parent ea53ad397b
commit e88553337e

View File

@ -117,11 +117,51 @@ class CardHandler:
} }
return sum([values[card.num] for card in self.cards]) return sum([values[card.num] for card in self.cards])
def animator(self):
while True:
frame = 1
yield frame
#
# ┌─────────┐
# │? │
# │ │
# │ │
# │ ? │
# │ │
# │ │
# │ ?│
# └─────────┘
#
#
# ┌────────┐
# │? │
# │ │
# │ │
# │ ? │
# │ │
# │ │
# │ ?│
# └────────┘
#
#
# ┌───────┐
# │? │
# │ │
# │ │
# │ ? │
# │ │
# │ │
# │ ?│
# └───────┘
#
class Blackjack: class Blackjack:
def __init__(self): def __init__(self):
self.handler = CardHandler([]) self.handler = CardHandler([])
self.emptyHandler = CardHandler([emptyCard(), emptyCard()]) self.emptyHandler = CardHandler([emptyCard(), emptyCard()])
self.dealerHandler = CardHandler([])
self.reset() self.reset()
def generateNewCard(self): def generateNewCard(self):
@ -130,11 +170,17 @@ class Blackjack:
return Card(random.choice(cardTypes), random.choice(cardColors)) return Card(random.choice(cardTypes), random.choice(cardColors))
def generateNewCards(self): def generateNewCards(self):
self.dealerCards = [ self.generateNewCard() for _ in range(2) ] self.dealerHandler.cards = [ self.generateNewCard() for _ in range(2) ]
self.handler.cards = [ self.generateNewCard() for _ in range(2) ] self.handler.cards = [ self.generateNewCard() for _ in range(2) ]
def determineAceValue(self):
if self.dealerHandler.cardSum <= 9:
self.handler.aceValue = 13
def reset(self): def reset(self):
self.generateNewCards() self.generateNewCards()
self.determineAceValue()
def printCards(self): def printCards(self):
self.handler.safePrintCards() self.handler.safePrintCards()
@ -152,7 +198,6 @@ class Blackjack:
input('Continue?') input('Continue?')
self.handler.addCard(self.generateNewCard()) self.handler.addCard(self.generateNewCard())
def loop(self): def loop(self):
while True: while True:
self.update() self.update()