Add files via upload

added __str__ overrides, abstained from overriding __repr__ methods because I like memory addresses.
This commit is contained in:
Brad Stein 2017-12-31 17:02:27 -06:00 committed by GitHub
parent 5a397cfe85
commit 8a12ece1f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 7 deletions

View File

@ -70,3 +70,6 @@ class Card:
for c in card: for c in card:
print(str(counter) + ": " + c.identify()) print(str(counter) + ": " + c.identify())
counter += 1 counter += 1
def __str__(self):
return "A " + self.__name + " card."

View File

@ -35,7 +35,7 @@ def setup_new_game(game_list, parameter, card_info):
card_info[index][3], card_info[index][4], card_info[index][5], card_info[index][3], card_info[index][4], card_info[index][5],
card_info[index][6], card_info[index][7], None) card_info[index][6], card_info[index][7], None)
if i == 0: if i == 0:
t.add_pile(card, 1) t.add_pile(card)
else: else:
t.get_pile(t.get_pile_index_of_card(card_info[index][0])).add_card(card) t.get_pile(t.get_pile_index_of_card(card_info[index][0])).add_card(card)
index += 1 index += 1
@ -106,11 +106,14 @@ def get_card_info():
def get_starting_deck(): def get_starting_deck():
return [["Copper", 7], ["Estate", 3]] # return [["Copper", 7], ["Estate", 3]]
# return [["Market", 2], ["Merchant", 2], ["Smithy", 2], ["Village", 2], ["Moat", 2]] # return [["Market", 2], ["Merchant", 2], ["Smithy", 2], ["Village", 2], ["Moat", 2]]
# return [["Militia", 4], ["Cellar", 3], ["Moat", 3]] # return [["Militia", 4], ["Cellar", 3], ["Moat", 3]]
# return [["Silver", 7], ["Merchant", 3]] # return [["Silver", 7], ["Merchant", 3]]
# return [["Copper", 4], ["Mine", 2], ["Remodel", 2], ["Workshop", 2]] # return [["Copper", 4], ["Mine", 2], ["Remodel", 2], ["Workshop", 2]]
return [["Copper", 1], ["Silver", 1], ["Gold", 1], ["Estate", 1], ["Dutchy", 1], ["Province", 1], ["Cellar", 1],
["Market", 1], ["Merchant", 1], ["Militia", 1], ["Mine", 1], ["Moat", 1], ["Remodel", 1], ["Smithy", 1],
["Village", 1], ["Workshop", 1]]
main() main()

View File

@ -46,7 +46,6 @@ class Player:
def draw_card(self): def draw_card(self):
self.__deck.transfer_top_card(self.__hand) self.__deck.transfer_top_card(self.__hand)
self.__hand.get_top_card().passive()
def draw_cards(self, how_many): def draw_cards(self, how_many):
spillover = how_many - self.__deck.get_remaining() spillover = how_many - self.__deck.get_remaining()
@ -195,9 +194,12 @@ class Player:
print("Coin: " + str(self.__purchase_power)) print("Coin: " + str(self.__purchase_power))
self.print_hand() self.print_hand()
self.__print_discard() self.__print_discard()
self.__print_deck() # self.__print_deck()
def __turn_setup(self): def __turn_setup(self):
self.__actions.int = 1 self.__actions.int = 1
self.__buys = 1 self.__buys = 1
self.__purchase_power = 0 self.__purchase_power = 0
def __str__(self):
return "Player " + self.get_player_index() + "."

View File

@ -53,3 +53,6 @@ class Supply:
for c in self.__card: for c in self.__card:
print(str(index) + ": " + c.identify()) print(str(index) + ": " + c.identify())
index += 1 index += 1
def __str__(self):
return "A " + type(self).__name__ + " with " + str(len(self.__card)) + " cards."

View File

@ -22,9 +22,10 @@ class Table:
def get_trash(self): def get_trash(self):
return self.__trash return self.__trash
def add_pile(self, card, n): def add_pile(self, card):
p = Pile() p = Pile()
p.add_cards(card, n) p.add_card(card)
card.setup()
self.__pile.append(p) self.__pile.append(p)
def get_piles(self): def get_piles(self):
@ -77,3 +78,6 @@ class Table:
for s in self.__trash.get_supply(): for s in self.__trash.get_supply():
print(str(index) + ": " + s.identify()) print(str(index) + ": " + s.identify())
index += 1 index += 1
def __str__(self):
return "A table with " + str(len(self.__pile)) + " card piles and " + str(len(self.__player)) + " players."