generated from mwc/project_game
added demo game in chris_demo
You had some really clear planning in your commit message-- In the "chris_demo" folder I implemented a bunch of what you planned. I suggest playing the game I built (go into chris_demo and run python game.py), and then carefully reading all the source code. Then, if you like the patterns I used, copy or move whatever you want to use into your main project folder. Also, if there are parts of my code you don't understand, please let me know (in a commit message or in person next time I'm in class) and I'll be happy to explain it.
This commit is contained in:
20
chris_demo/deck.py
Normal file
20
chris_demo/deck.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from card import Card
|
||||
from random import shuffle
|
||||
|
||||
class Deck:
|
||||
def __init__(self, position, hidden=True, shuffled=True):
|
||||
self.position = position
|
||||
self.cards = [Card(position, i, hidden=hidden) for i in range(52)]
|
||||
if shuffled:
|
||||
shuffle(self.cards)
|
||||
|
||||
def draw(self):
|
||||
return self.cards.pop()
|
||||
|
||||
def get_agents(self):
|
||||
agents = []
|
||||
for card in self.cards:
|
||||
agents.append(card)
|
||||
agents += card.agents
|
||||
return agents
|
||||
|
||||
Reference in New Issue
Block a user