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])
def animator(self):
while True:
frame = 1
yield frame
#
# ┌─────────┐
# │? │
# │ │
# │ │
# │ ? │
# │ │
# │ │
# │ ?│
# └─────────┘
#
#
# ┌────────┐
# │? │
# │ │
# │ │
# │ ? │
# │ │
# │ │
# │ ?│
# └────────┘
#
#
# ┌───────┐
# │? │
# │ │
# │ │
# │ ? │
# │ │
# │ │
# │ ?│
# └───────┘
#
class Blackjack:
def __init__(self):
self.handler = CardHandler([])
self.emptyHandler = CardHandler([emptyCard(), emptyCard()])
self.dealerHandler = CardHandler([])
self.reset()
def generateNewCard(self):
@ -130,11 +170,17 @@ class Blackjack:
return Card(random.choice(cardTypes), random.choice(cardColors))
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) ]
def determineAceValue(self):
if self.dealerHandler.cardSum <= 9:
self.handler.aceValue = 13
def reset(self):
self.generateNewCards()
self.determineAceValue()
def printCards(self):
self.handler.safePrintCards()
@ -152,7 +198,6 @@ class Blackjack:
input('Continue?')
self.handler.addCard(self.generateNewCard())
def loop(self):
while True:
self.update()