Beispiel #1
0
def combat(player, monster):
    print(player)
    print("VS")
    print(monster)

    while player.life > 0 and monster.life > 0:
        print(player)
        print("VS")
        print(monster)
        print("Que voulez vous faire ?")
        print("1 : Attaquer")
        print("2 : Boire une potion")
        print("3 : Rien du tout")
        user_choice = int(input())
        if user_choice == 1:
            attack = choose_item(player.attack)
            if attack.hit():
                monster.damage(attack.damage)
        elif user_choice == 2:
            potion = choose_item(player.inventory)
            player.drink_potion(potion)

        attack = monster.choose_attack()
        if attack.hit():
            player.damage(attack.damage)

    print("Fin du combat !")
    print(player)
    print("VS")
    print(monster)
Beispiel #2
0
 def choose_main_actions(self) -> None:
     main_actions_names = (
         "Kontynuuj historię",
         "Idź do zamku",
         "Ekwipunek",
         "Zagraj w Blackjack'a",
     )
     main_actions = (self.continue_story, self.choose_castle,
                     self.player.equipment.choose_main_action,
                     Blackjack.main)
     question = "\nWybierz interakcje\n"
     while True:
         try:
             introduce_from_list(main_actions_names)
             chosen_action = choose_item(main_actions, question)
             if chosen_action is not None:
                 try:
                     chosen_action()
                 except TypeError:
                     chosen_action(self.player)
             else:
                 print("\nPodana wartość jest nieprawidłowa!\n")
         except GameHasFinished as reason:
             print(reason)
             return None
Beispiel #3
0
 def use_item_during_combat(self, player: 'Player') -> None:
     while True:
         potion_items = self.filter(ItemType.POTION)
         introduce_from_list(potion_items)
         question = "\nWybierz miskturę do użycia, lub naciśnij enter aby wyjść\n"
         chosen_item = choose_item(potion_items, question)
         if chosen_item is None:
             break
         self.remove_item(chosen_item)
         chosen_item.drink(player)
Beispiel #4
0
 def _improve_weapon(self, player) -> None:
     while True:
         players_backpack_items = player.equipment.backpack.items
         introduce_from_list(players_backpack_items, space=True)
         print("\nKoszt ulepszenia broni " + str(self.IMPROVE_PRICE) + "\n")
         question = "\nPodaj numer przedmiotu, który chcesz naostrzyć, lub naciśnij enter aby wyjść\n"
         chosen_item = choose_item(players_backpack_items, question)
         if chosen_item is not None:
             if self._can_improve(player, chosen_item):
                 player.equipment.gold.subtract(self.IMPROVE_PRICE)
                 chosen_item.improve()
             else:
                 print("\nNie można naostrzyć broni\n")
         else:
             break
Beispiel #5
0
 def _buy_items(self, player: 'Player') -> None:
     while True:
         self._introduce_items()
         print(player.equipment.gold)
         list_of_items = classes_to_items(get_classes_from_keys(self.ITEMS_PRICES))
         question = "\nPodaj numer przedmiotu, lub naciśnij enter aby wyjść\n"
         chosen_item = choose_item(list_of_items, question)
         if chosen_item is not None:
             if self._has_money(player, chosen_item):
                 price = self._get_price(chosen_item)
                 player.equipment.gold.subtract(price)
                 player.equipment.backpack.append(chosen_item)
             else:
                 print("\nNie masz hajsu na ten szajs\n")
         else:
             break
Beispiel #6
0
 def choose_interaction(self, player) -> None:
     actions = (
         self._buy_items,
         self._sell_items,
     )
     interactions_names = (
         "Kup przedmiot",
         "Sprzedaj przedmiot",
     )
     question = "\nWybierz interakcje, lub naciśnij enter, aby wyjść\n"
     while True:
         introduce_from_list(interactions_names)
         chosen_action = choose_item(actions, question)
         if chosen_action is not None:
             chosen_action(player)
         else:
             break
Beispiel #7
0
 def _sell_items(self, player: 'Player') -> None:
     while True:
         self._introduce_items(margin=self.MARGIN)
         players_backpack_items = player.equipment.backpack.items
         introduce_from_list(players_backpack_items, space=True)
         print(player.equipment.gold)
         question = "\nWybierz przedmiot który chcesz sprzedać, lub naciśnij enter aby wyjść\n"
         chosen_item = choose_item(players_backpack_items, question)
         if chosen_item is not None:
             if self._can_sell(chosen_item):
                 players_backpack_items.remove(chosen_item)
                 gold_from_item = floor(self.MARGIN * self._get_price(chosen_item))
                 player.equipment.gold.add(gold_from_item)
             else:
                 print("\nNie handluje tym szajsem\n")
         else:
             break
Beispiel #8
0
    def choose_interaction(self, player):
        actions = (
            self._buy_items,
            self._sell_items,
        )

        interactions_names = (
            "Kup przedmiot",
            "Sprzedaj przedmiot",
        )

        while True:
            introduce_from_list(interactions_names)
            chosen_action = choose_item(actions, "\nWybierz interakcje\n")
            if chosen_action is not None:
                chosen_action(player)
            else:
                break
Beispiel #9
0
    def choose_castle(self) -> None:
        question = "\nWybierz lokacje\n"
        main_actions_names = (
            "Idź do starego zamku",
            "Idź do nowego zamku",
        )
        main_actions = (self.locations[0].visit_merchant,
                        self.locations[1].visit_merchant)

        while True:
            try:
                introduce_from_list(main_actions_names)
                chosen_action = choose_item(main_actions, question)
                if chosen_action is not None:
                    chosen_action()
                else:
                    break
            except IndexError:
                print("\nPodana wartość jest nieprawidłowa!\n")
Beispiel #10
0
    def visit_merchant(self) -> None:
        merchants: list = [
            self.ARMOURER, self.BLACKSMITH, self.ENCHANTER, self.ALCHEMIST
        ]

        merchant_actions_names: list = [
            "Idź do płatnerz", "Idź do kowala", "Idź do zaklinacza",
            "Idź do alchemika"
        ]
        if self.can_enter():
            while True:
                introduce_from_list(merchant_actions_names)
                question = "\nWybierz, do kogo chcesz się wybrać, lub naciśnij enter, aby wyjść\n"
                chosen_merchant = choose_item(merchants, question)
                if chosen_merchant is not None:
                    chosen_merchant.choose_interaction(self.player)
                else:
                    return
        else:
            print(colored("\nMasz za niski poziom!\n", "red"))
Beispiel #11
0
    def choose_interaction(self, player) -> None:
        actions = (
            self._buy_items,
            self._sell_items,
            self._improve_weapon
        )

        interactions_names: tuple = (
            "Kup przedmiot",
            "Sprzedaj przedmiot",
            "Ulepsz przedmiot"
        )

        interaction_question = "\nWybierz interakcje, jeśli chcesz wyjść naciśnij enter\n"
        while True:
            introduce_from_list(interactions_names)
            chosen_action = choose_item(actions, interaction_question)
            if chosen_action is not None:
                chosen_action(player)
            else:
                break