Add files via upload

This commit is contained in:
Brad Stein 2017-12-26 16:57:31 -06:00 committed by GitHub
parent 159839dbc4
commit 1102ad7de1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 16 deletions

12
game.py
View File

@ -19,10 +19,14 @@ def setup_new_game(game_list, parameter, card_info):
index = 0
for p in parameter[2:]:
if p:
card = card_info[index][8](card_info[index][0], card_info[index][1], card_info[index][2],
card_info[index][3], card_info[index][4], card_info[index][5],
card_info[index][6], card_info[index][7], None)
t.add_pile(card, card_info[index][9])
for i in range(card_info[index][9]):
card = card_info[index][8](card_info[index][0], card_info[index][1], card_info[index][2],
card_info[index][3], card_info[index][4], card_info[index][5],
card_info[index][6], card_info[index][7], None)
if i ==0:
t.add_pile(card, 1)
else:
t.get_pile(t.get_pile_index_of_card(card_info[index][0])).add_card(card)
index += 1
for i in range(humans):

View File

@ -4,29 +4,29 @@ from random import randint
class Militia(Card):
def effect(self):
print("Who am I: " + str(self._Card__owner.get_table().get_players().index(self._Card__owner)) + " " + str(self._Card__owner))
for player in self._Card__owner.get_table().get_players():
print("player before if: " + str(self._Card__owner.get_table().get_players().index(player)) + " " + str(player))
if self._Card__owner != player:
print(str(self._Card__owner) + " " + str(player))
print("self._Card__owner: " + str(self._Card__owner.get_table().get_players().index(self._Card__owner)))
print("Player: " + str(self._Card__owner.get_table().get_players().index(player)))
player.print_hand()
print("Player " + str(self._Card__owner.get_table().get_players().index(player)) + ", you MUST discard "
"down to 3 cards.")
self.__force_discard(self._Card__owner.get_std_chances(), player)
def __force_discard(self, chances, player):
if self._Card__owner.get_hand().get_remaining() > 3 and chances > 0:
if player.get_hand().get_remaining() > 3 and chances > 0:
hand_index = int(input("\nPlease identify a card from hand you would like to discard by providing "
"its index: "))
"its index 0 to " + str(player.get_hand().get_remaining() - 1) + ": "))
if 0 > hand_index >= self.__hand.get_remaining() and chances > 0:
print("Acceptable inputs range from 0 to " + str(self.__hand.get_remaining() - 1) + ". 1 chance lost.")
self.__force_discard(chances - 1)
if chances <= 0:
print("Somehow chances ran out, you'll randomly discard a card now.")
self.__force_discard(chances, player)
elif 0 > hand_index or hand_index >= self._Card__owner.get_hand().get_remaining():
print("Acceptable inputs range from 0 to " + str(player.get_hand().get_remaining() - 1) +
". 1 chance lost.")
self.__force_discard(chances - 1, player)
else:
print("Discarding " + player.get_hand().get_card(hand_index).get_name() + ".")
player.discard_from_hand(hand_index)
player.print_hand()
self.__force_discard(chances, player)
elif self._Card__owner.get_hand().get_remaining() > 3 and chances < 0:
print("You're out of chances to select a valid card to discard, randomly selecting for you.")

View File

@ -71,7 +71,6 @@ class Player:
for i in range(ds[1]):
table.get_pile(index).transfer_top_card(self.__deck)
self.__claim_top_card(self.__deck)
print("Top card: " + str(self.__deck.get_top_card().get_owner()) + " " + str(self.__deck.get_top_card().get_name()))
self.__deck.shuffle()
def draw_hand(self):
@ -144,7 +143,8 @@ class Player:
print("You do not have enough coin. Try again.")
chances -= 1
else:
print("Buying card " + self.__table.get_pile(pile_index).get_card_group().get_name())
print("Player " + str(self.get_table().get_players().index(self)) + " buying card " +
self.__table.get_pile(pile_index).get_card_group().get_name())
self.__table.get_pile(pile_index).transfer_top_card(self.__discard)
self.__claim_top_card(self.__discard)
self.__buys -= 1