def murder(self, player, list_of_players): if len(list_of_players) == 1: print("SORRY there are no other players with influences to murder") return 0 player.coins = -3 choose_person = [] counter = 0 for person in (list_of_players): if person.status != "Playing": choose_person.append(person) print( "You can MURDER an INFLUENCE of {} by pressing {}".format( person, counter)) counter += 1 print( "Enter the number of the person's influence you want to murder: ") murder_person = Console.cast(0, counter) print("PASS the computer to {}".format( choose_person[murder_person].name)) input("PRESS ANY KEY to continue") Console.clear() choose_person[murder_person].resign_card() print("Player {} now has {} coins".format(player.name, player.coins))
def extortion(self, player, list_of_players): if len(list_of_players) == 1: print("SORRY there are no other players to extort") return 0 choose_person = [] counter = 0 for person in (list_of_players): if person.status != "Playing": choose_person.append(person) print("You can EXTORT {} by PRESSING {}".format( person, counter)) counter += 1 print("Enter the NUMBER of the PERSON you want to EXTORT: ") extort_person = Console.cast(0, counter) if choose_person[extort_person].coins >= 2: choose_person[extort_person].coins = -2 player.coins = 2 elif (choose_person[extort_person].coins == 1): choose_person[extort_person].coins = -1 player.coins = 1 else: print("SORRY, this person has no coins") print("Player {} now has {} coins".format(player.name, player.coins)) print("Player {} now has {} coins".format( choose_person[extort_person].name, choose_person[extort_person].coins))
def resign_card(self): print("{} you ought to resign a card".format(self.__name)) self.status = "Playing" self.see_cards() print("Press the NUMBER of the card you want to resign: ") card_resigned = Console.cast(0, len(self.cards)) self.cards[card_resigned - 1].out_of_game = True self.status = None Console.clear()
def change(self, player, deck): number_of_cards = 0 for card_player in player.cards: if card_player.out_of_game == False: number_of_cards += 1 temporary_cards = [] for counter in range(2): deck[counter - 1].hidden = False temporary_cards.append(deck[counter - 1]) for card in player.cards: if card.out_of_game == False: card.hidden = False temporary_cards.append(card) print( "You get to keep {} cards out of these: ".format(number_of_cards)) for num, element in enumerate(temporary_cards): print("- {} to keep {}".format(num, element)) new_cards_player = [] picked = [] for i in range(number_of_cards): print("Enter NUMBER of card you wish to keep: ") pick = Console.cast(0, number_of_cards + 1) if (pick == 0 or pick == 1): temporary_cards[pick].hidden = True new_cards_player.append(temporary_cards[pick]) deck.pop(pick - 1) else: temporary_cards[pick].hidden = True new_cards_player.append(temporary_cards[pick]) picked.append(pick) if number_of_cards == 2: if 3 not in picked: deck.append(player.cards[1]) player.cards.pop(1) if 2 not in picked: deck.append(player.cards[0]) player.cards.pop(0) for card in player.cards: if card not in new_cards_player and card.out_of_game == False: deck.append(card) player.cards.remove(card) for card_2 in new_cards_player: if card_2 not in player.cards: player.cards.append(card_2) for card_deck in deck: card_deck.hidden = True player.see_cards()
def see_cards_option(self): print("=======================") print("PRESS 1 if you wish to SEE YOUR CARDS AGAIN. 0 if you don't.") print("You get this choice ONCE before choosing your action!") print("=======================") number = Console.cast(0, 1) if number == 1: self.see_cards() input("To continue: press enter") Console.clear() else: return
def hit(self, player, list_of_players): if len(list_of_players) == 1: print("SORRY there are no other players to HIT") return 0 player.coins = -7 choose_person = [] counter = 0 for person in (list_of_players): if person.status != "Playing": choose_person.append(person) print("You can take a HIT on {} by pressing {}".format( person, counter)) counter += 1 print("Enter the NUMBER of the person you want to hit: ") hit_person = Console.cast(0, counter) print("PASS the computer to {}".format(choose_person[hit_person].name)) input("PRESS ANY KEY to continue") Console.clear() choose_person[hit_person].resign_card()
def __counterattack(cls, player, action): counterattacks = { "Foreign Help": ["Duke"], "Murder": ["Countess"], "Extortion": ["Captain", "Ambassador"] } print( "PLAYERS can COUNTERATTACK {}'s action if they have influence on: " .format(player)) for element in counterattacks[action]: print("-> {}".format(element)) challengers = [] for other_player in cls.__players: if other_player.status != "Playing": add = input( "{} PRESS 1 if you want to COUNTERATTACK, press enter otherwise " .format(other_player)) if add == "1": challengers.append(other_player) if len(challengers) == 0: print("\n NOBODY COUNTERATTACKED you") return 0 shuffle(challengers) challenger = challengers[0] print("{} you have been COUNTERATTACKED by {}".format( player, challenger)) if action == "Extortion": print( "{} SELECT 0 if you have influence on the CAPTAIN / SELECT 1 if you have influence over the AMBASSADOR: " .format(challenger)) num_influence = Console.cast(0, 1) influence = counterattacks[action][num_influence] else: influence = counterattacks[action][0] challenger.status = "Challenging" return [challenger, influence]
def __set_players(cls): print("Please enter NUMBER of players (3 or 4): \n") number_players = Console.cast(3, 4) for i in list(range(number_players)): name = input("Player {} enter your name: ".format(i + 1)) cls.__players.append(Player(name, i + 1))