2018-01-10 14:10:20 -05:00
|
|
|
from card.basic.card_attack import Attack
|
|
|
|
|
from card.basic.card_action import Action
|
2017-12-26 15:33:05 -06:00
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
|
2018-01-10 14:10:20 -05:00
|
|
|
class Militia(Action, Attack):
|
2017-12-26 15:33:05 -06:00
|
|
|
def effect(self):
|
|
|
|
|
for player in self._Card__owner.get_table().get_players():
|
2017-12-27 02:12:43 -06:00
|
|
|
if self._Card__owner != player and not player.get_hand().blocks_attack(self.get_name()):
|
2017-12-26 15:33:05 -06:00
|
|
|
player.print_hand()
|
2017-12-30 22:33:43 -06:00
|
|
|
print("Player " + str(player.get_player_index()) + ", you MUST discard down to 3 card.")
|
2017-12-26 15:33:05 -06:00
|
|
|
self.__force_discard(self._Card__owner.get_std_chances(), player)
|
|
|
|
|
|
|
|
|
|
def __force_discard(self, chances, player):
|
2017-12-26 16:57:31 -06:00
|
|
|
if player.get_hand().get_remaining() > 3 and chances > 0:
|
2018-01-05 03:42:13 -06:00
|
|
|
hand_index = player.militia_input("\nPlease provide an index to identify a card from hand you would like to"
|
2018-01-05 21:33:36 -06:00
|
|
|
" discard (0 to " + str(player.get_hand().get_remaining() - 1) + "): "
|
|
|
|
|
, int)
|
2017-12-30 22:33:43 -06:00
|
|
|
self.__check_discard(hand_index, player, chances)
|
|
|
|
|
elif self._Card__owner.get_hand().get_remaining() > 3 and chances <= 0:
|
2017-12-26 15:33:05 -06:00
|
|
|
print("You're out of chances to select a valid card to discard, randomly selecting for you.")
|
|
|
|
|
player.discard_from_hand(randint(0, self.__hand.get_remaining() - 1))
|
|
|
|
|
|
2017-12-30 22:33:43 -06:00
|
|
|
def __check_discard(self, index, player, chances):
|
|
|
|
|
if 0 > index or index >= self._Card__owner.get_hand().get_remaining():
|
|
|
|
|
print("Valid 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(index).get_name() + ".")
|
|
|
|
|
player.discard_from_hand(index)
|
|
|
|
|
player.print_hand()
|
|
|
|
|
self.__force_discard(self._Card__owner.get_std_chances(), player)
|