def player_meets_enemy(board, player, enemies, npc):
    # util.clear_screen
    # pl.put_player_on_board(board, player)
    # ui.display_board(board)
    printing(player, enemies, npc)
    if player["inventory"]["bucks"] > enemies[npc]["price"]:
        if player["chunk"] >= enemies[npc]["supplies"][npcs.CURRENT_SUPPLIES]:
            when_chunk_bigger_than_supplies(player, enemies, npc)
        # if player["chunk"] < npc["supplies"]
        else:
            when_chunk_smaller_than_supplies(player, enemies, npc)
        check_player_attributes_values(player)

        if has_won(player, enemies, npc):
            printing(player, enemies, npc)
            after_defeating_enemy(board, player, enemies, npc)
        elif has_died(player):
            printing(player, enemies, npc)
            ui.print_message("You have died... Your belly: ", player["belly"])
            util.press_any_key()
            raise SystemExit

        elif not has_won(player, enemies, npc):
            decide_next_move(player, enemies, npc)
    #if player["bucks"] < npc["price"]
    else:
        ui.print_message("You have not money enough. The price is",
                         enemies[npc]["price"])
        util.press_any_key()
def player_meets(board, player, future_x, future_y, enemies_coords,
                 friends_coords, enemies, friends):
    npc = indicate_npc(future_x, future_y, enemies_coords, friends_coords,
                       enemies, friends)
    if npc in friends:
        player_meets_friend(board, player, future_x, future_y, friends, npc)
        util.press_any_key()

    if npc in enemies:
        player_meets_enemy(board, player, enemies, npc)
def after_defeating_enemy(board, player, enemies, npc):
    print(f"{ui.PURPLE}You have won the fight!{ui.END} Your belly: ",
          player["belly"])
    remove_enemy_from_board(board, npc, enemies,
                            True)  # rozszerzone dla beasta
    enemies[npc]["position"] = []
    blocked_coords = specify_blocked_coords_list(board)
    remove_coords_defeated_enemy(npc, blocked_coords, enemies,
                                 True)  # rozszerzone dla beasta
    util.press_any_key()
示例#4
0
def main():
    player = database_player.create_player()
    prepare_game_environment()
    util.clear_screen()
    ui.print_start_screen()
    util.press_any_key()
    # setting which board is the 1st to start the gameplay
    current_board = database_boards.board_list['1']

    util.clear_screen()
    is_running = True
    while is_running:
        start(current_board, player)
        current_board = player_action(current_board, player)
        game_action(current_board, database_npc.food_challenges, player)

        util.clear_screen()
def when_chunk_bigger_than_supplies(player, enemies, npc):
    ratio = enemies[npc]["supplies"][npcs.CURRENT_SUPPLIES] / player["chunk"]
    if player["inventory"]["bucks"] >= enemies[npc]["price"] * ratio:
        player["inventory"]["bucks"] -= round(enemies[npc]["price"] * ratio, 2)
        enemies[npc]["supplies"][npcs.CURRENT_SUPPLIES] -= player["chunk"]
        player["belly"] += round(enemies[npc]["belly"] * ratio, 2)
        # printing(player,enemies,npc)
        # stop_attacking = True
    #if player["inventory"]["bucks"] < enemies[npc]["price"] * ratio
    else:
        player["belly"] += round(0.2 * player["chunk"],
                                 2)  # stres ścisnął żołądek
        # print("")
        # printing(player,enemies,npc)
        ui.print_message("Go away. You have not money enough. The price is",
                         enemies[npc]["price"])
        util.press_any_key()
def when_chunk_smaller_than_supplies(player, enemies, npc):
    if player["inventory"]["bucks"] >= enemies[npc]["price"]:
        player["inventory"]["bucks"] -= round(enemies[npc]["price"], 2)
        enemies[npc]["supplies"][npcs.CURRENT_SUPPLIES] -= player["chunk"]
        if enemies[npc]["type"] == "beast" and (
                15 < enemies[npc]["supplies"][npcs.CURRENT_SUPPLIES] < 31):
            ui.print_message(
                "Enemy has got angry. It has served you a spoilt ingridient. Your belly feels a chunk havier by",
                npcs.ENEMY_FACTOR)
            player["belly"] += round(enemies[npc]["belly"] * npcs.ENEMY_FACTOR,
                                     2)  # * player[factor obniżajacy]
        else:
            player["belly"] += round(enemies[npc]["belly"],
                                     2)  # * player[factor obniżajacy]
            return False
    else:
        ui.print_message("Go away. You have not money enough. The price is",
                         enemies[npc]["price"])
        util.press_any_key()
        # stop_attacking = True
        return True
def enemy_begins_fight(board, player, enemies, enemy):
    # pl.put_player_on_board(board, player)
    if player["inventory"]["bucks"] >= enemies[enemy]["price"]:
        player["inventory"]["bucks"] -= round(enemies[enemy]["price"], 2)
    else:
        player["inventory"]["bucks"] = 0
    print(
        f"\nYou have already paid for entrace to '{enemies[enemy]['name']}'.")
    print(f"Now you have only: {player['inventory']['bucks']} bucks.")

    printing(player, enemies, enemy)
    # user_choice = input("Do you wat to order something? y/n\n")
    user_choice = ""
    while user_choice not in ["y", "n"]:
        user_choice = input("Would you like to order something? y/n\n")
        if user_choice.lower().strip() == "y":
            print(
                f"To make an order,try to get position of {enemies[enemy]['name']}"
            )
            util.press_any_key()
            return
        elif user_choice.lower().strip() == "n":
            # enemies[enemy]['phase'] = ""
            return
示例#8
0
def player_action(current_board, player):
    # change_board = False
    player_turn = True
    while player_turn:
        key = engine.get_key()
        if key == 'q':
            player_turn = False
            raise ExitException
        elif key == 'i':
            print(player['inventory'])
            engine.use_inventory(player)
            util.press_any_key()
            util.clear_screen()
            start(current_board, player)
            continue
        else:
            future_x, future_y = engine.get_move_coords(player, key)

        engine.remove_player_from_board(current_board, player)
        if engine.can_move_player_to(current_board, player, future_x,
                                     future_y):
            # moves the player to the next / previous board(s) / if has the district_pass
            if database_boards.is_cell_exit(current_board, future_x, future_y):
                if engine.player_has_item(player,
                                          database_items.district_pass):
                    current_board = engine.go_to_next_board(
                        current_board, player, future_x, future_y,
                        database_boards.board_list)
                    player_turn = False
                    # change_board = True

                else:
                    print('You need to find a district pass first... (#)')
                    util.press_any_key()
            else:
                enemies_coords = engine.get_coords(
                    current_board, database_npc.food_challenges)
                friends_coords = engine.get_coords(current_board,
                                                   database_npc.friends, True)
                if engine.is_meet(future_x, future_y, enemies_coords,
                                  friends_coords):
                    engine.player_meets(current_board, player, future_x,
                                        future_y, enemies_coords,
                                        friends_coords,
                                        database_npc.food_challenges,
                                        database_npc.friends)
                    if current_board[future_x][
                            future_y] == database_boards.BOARD_FIELD_SIGN:
                        engine.move_player_to(player, future_x, future_y)
                        player_turn = False
                    else:
                        player_turn = True

                else:
                    engine.move_player_to(player, future_x, future_y)
                    if current_board[future_x][
                            future_y] in database_items.item_database:
                        engine.put_item_into_the_inv(
                            player, database_items.item_database[
                                current_board[future_x][future_y]])
                        print(
                            f"You have added sth special to your backpack.\n")
                        util.press_any_key()

                    player_turn = False
    return current_board
示例#9
0
def main():
    util.clear_screen()

    player = database_player.create_player()

    board_list = database_boards.create_boards()
    current_board = board_list['1']
    npc_dictionary = {}

    is_running = True
    npc = None
    while is_running:

        x, y = player['position']
        future_x = x
        future_y = y

        print('Current Howling Forest Region: ',
              extras.board_level_info(board_list, current_board))
        extras.how_is_the_hp(player)
        extras.print_player_stats(player)
        if npc:
            extras.how_is_the_npc_hp(npc)
            if engine.fight_is_over:
                npc = None
        database_player.put_player_on_board(current_board, player)
        ui.display_board(current_board)

        key = util.key_pressed()

        if key == 'q':
            is_running = False
        elif key == 'w':
            future_x = x - 1
        elif key == 's':
            future_x = x + 1
        elif key == 'a':
            future_y = y - 1
        elif key == 'd':
            future_y = y + 1
        elif key == 'i':
            print(player['inventory'])
            util.press_any_key()
        elif key == 'h':
            extras.help()
            util.press_any_key()
        elif key == 'k':
            item = database_items.small_hp_potion
            engine.use_item_from_inventory(player, item)
        elif key == 'l':
            item = database_items.small_hp_potion
            engine.use_item_from_inventory(player, item)
        else:
            pass
        engine.remove_player_from_board(current_board, player)
        database_player
        # moves the player to the next/previous board(s) if has the teleportation orb // put items to inv
        if engine.can_move_player_to(current_board, player, future_x,
                                     future_y):
            engine.idle_hp_regeneration(player, future_x, future_y)
            if database_boards.is_cell_exit(current_board, future_x, future_y):
                if engine.player_has_item(player,
                                          database_items.teleportation_orb):
                    for key in board_list:
                        if current_board[future_x][future_y] == key:
                            current_board = board_list[key]
                            break
                    if future_y == 0:
                        player[
                            'position'] = future_x, future_y + database_boards.BOARD_WIDTH - 2
                    else:
                        player[
                            'position'] = future_x, future_y - database_boards.BOARD_WIDTH + 2
                    database_player.put_player_on_board(current_board, player)
                else:
                    print(
                        'You need to find the teleportation orb first... (#)')
                    util.press_any_key()
            else:
                engine.move_player_to(player, future_x, future_y)
                if current_board[future_x][
                        future_y] in database_items.item_database:
                    item = database_items.item_database[current_board[future_x]
                                                        [future_y]]
                    if item['type'] == 'sword':
                        engine.choose_weapon_to_use(player, item)
                    elif item['type'] == 'shield':
                        engine.choose_shield_to_use(player, item)
                    elif item['type'] == 'upgrade':
                        engine.add_upgrade_to_stats(player, item)
                    else:
                        engine.put_item_into_the_inv(player, item)

        elif engine.is_occupied_by_npc(current_board, future_x, future_y):
            npc_key = extras.encode_location(board_list, current_board,
                                             future_x, future_y)
            if npc_key in npc_dictionary:
                npc = npc_dictionary[npc_key]
            else:
                npc = database_npc.npc_database[current_board[future_x]
                                                [future_y]].copy()
                npc_dictionary[npc_key] = npc
            extras.how_is_the_npc_hp(npc)
            engine.player_vs_npc(player, npc, future_x, future_y)
            if player['hp'] == 0:
                is_running = False
        util.clear_screen()