Exemplo n.º 1
0
def handles_second_level():
    """Handle game's second level game."""

    os.system("clear")
    x_current_position = 1  #starting position of player
    y_current_position = 1
    board = create_board("level_1.csv")
    last_hero_position = board[y_current_position][x_current_position]

    barriers = ['X','⌂','🚪']
    added_items = []

    key_direction = getch()  #control

    while key_direction != "q":
        x_direction = 0
        y_direction = 0

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position

        if check_next_step(y_current_position + y_direction, x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = makes_good_step(y_current_position, x_current_position, y_direction, x_direction)

        add_item_to_inventory(board, inventory, y_current_position, x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)
        print_board(board)
        print_table(inventory)
Exemplo n.º 2
0
def handle_second_level():

    os.system("clear")
    time_start = time.time()

    x_current_position = 1
    y_current_position = 1

    board = create_board('level_2.csv')
    print_board(board)
    print_table(inventory)
    last_hero_position = board[y_current_position][x_current_position]
    barriers = [
        'X', '⌂', '🚪', '🚛', '🚒', '🚙', '�', '🚲', '🚶',
        '🚸'
    ]

    key_direction = getch()  #control

    while key_direction != "q":

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position

        if check_next_step(y_current_position + y_direction,
                           x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = take_next_step(
                y_current_position, x_current_position, y_direction,
                x_direction)

        if inventory['dollars'] == 250:
            board[1][49] = "∃"

        if inventory['stamina'] <= 0:
            game_over()
            sys.exit()

        if board[y_current_position][x_current_position] == '∃':
            if inventory['revolver'] == 1:
                ask_riddles(question_3, delay_print, handle_first_level,
                            handle_third_level)
        if board[y_current_position][x_current_position] == '∃':
            if inventory['revolver'] == 0:
                delay_print('You need a gun to go to the next level!')

        elif key_direction == "q":
            sys.exit()

        open_doors(board, inventory, '🚪', y_current_position, y_direction,
                   x_current_position, x_direction)
        add_item_to_inventory(board, inventory, y_current_position,
                              x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)

        print_board(board)
        print_table(inventory)
Exemplo n.º 3
0
def handle_zero_level():

    time.sleep(3)
    os.system("clear")
    time_start = time.time()

    x_current_position = 1
    y_current_position = 1

    board = create_board('level_0.csv')
    print_board(board)
    print_table(inventory)
    last_hero_position = board[y_current_position][x_current_position]
    barriers = ['X', '⌂', '🚪']

    key_direction = getch()  #control

    while key_direction != "q":

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position

        if check_next_step(y_current_position + y_direction,
                           x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = take_next_step(
                y_current_position, x_current_position, y_direction,
                x_direction)

        if inventory['dollars'] == 50:
            board[11][49] = "∃"

        if inventory['stamina'] <= 0:
            game_over()
            sys.exit()

        if board[y_current_position][x_current_position] == '∃':
            ask_riddles(question_1, delay_print, handle_first_level,
                        handle_first_level)

        elif key_direction == "q":
            sys.exit()

        open_doors(board, inventory, '🚪', y_current_position, y_direction,
                   x_current_position, x_direction)
        add_item_to_inventory(board, inventory, y_current_position,
                              x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)

        print_board(board)
        print_table(inventory)
Exemplo n.º 4
0
def handle_zero_level():
    # time.sleep(3)
    os.system("clear")
    time_start = time.time()

    x_current_position = 1
    y_current_position = 1

    board = create_board('level_0.csv')
    last_hero_position = board[y_current_position][x_current_position]
    barriers = ['X','⌂','🚪']

    key_direction = getch()  #control

    while key_direction != "q":

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position

        if check_next_step(y_current_position + y_direction, x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = makes_good_step(y_current_position, x_current_position, y_direction, x_direction)

        if inventory['dollars'] == 30:
            board[11][49] = "∃"

        if inventory['stamina'] <= 0:                #Gdy stamina spadnie ponizej 0 wyskakuje game over i highscores.
            game_over()
            sys.exit()

        if inventory['dollars'] > 150:                #W przypadku wygranej zapisuje wynik do pliku
            time_end = time.time() - time_start
            roundtime = round(time_end)
            win_game(roundtime)
            sys.exit()

        if board[y_current_position][x_current_position] == '∃':
            ask_riddles(question_1, delay_print, handles_first_level, handles_second_level)
            handles_first_level()

        elif key_direction == "q":
            sys.exit()


        open_doors(board, inventory, '🚪', y_current_position, y_direction, x_current_position, x_direction)
        add_item_to_inventory(board, inventory, y_current_position, x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)

        print_board(board)
        print_table(inventory)
Exemplo n.º 5
0
def handles_second_level():
    """Handle game's second level game."""

    os.system("clear")
    x_current_position = 1  #starting position of player
    y_current_position = 1
    board = create_board("level_1.csv")
    last_hero_position = board[y_current_position][x_current_position]

    barriers = ['X', '⌂', '🚪']
    added_items = []
    # twanas_list = ["௸", "௺", "இ", "௫", "௵", "ඖ", "ඣ", "ඐ", "ණ"]
    # twanas = "twanas"

    key_direction = getch()  #control

    while key_direction != "q":
        x_direction = 0
        y_direction = 0

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position

        if check_next_step(y_current_position + y_direction,
                           x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = makes_good_step(
                y_current_position, x_current_position, y_direction,
                x_direction)

        # if is_touching_blood(board[y_current_position + y_direction][x_current_position + x_direction], blood):
        #     dutifulness = subtract_dutifulness(dutifulness)

        # if is_touching_twanas(board[y_current_position + y_direction][x_current_position + x_direction], twanas_list):
        #     twanas_list.remove(board[y_current_position + y_direction][x_current_position + x_direction])
        #     board[y_current_position + y_direction][x_current_position + x_direction] = " "
        #     added_items.append(twanas)
        #     add_to_inventory(inventory, added_items)

        add_item_to_inventory(board, inventory, y_current_position,
                              x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)
        print_board(board)
Exemplo n.º 6
0
def handles_first_level():
    
    os.system("clear")
    x_current_position = 1  
    y_current_position = 1
    
    board = create_board('level_1.csv')
    last_hero_position = board[y_current_position][x_current_position]
    barriers = ['X','⌂','🚪']

    key_direction = getch()  #control

    while key_direction != "q":

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position

        if check_next_step(y_current_position + y_direction, x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = makes_good_step(y_current_position, x_current_position, y_direction, x_direction)
        
        if inventory['dollars'] == 40:
            board[8][60] = "∃"            
        
        if board[y_current_position][x_current_position] == '∃':
            ask_riddles(question_1, delay_print, handles_first_level, handles_second_level)
            # handles_second_level()   

         

        elif key_direction == "q":
            sys.exit()
        
        open_door(board, inventory, '🚪', y_current_position, y_direction, x_current_position, x_direction)
        add_item_to_inventory(board, inventory, y_current_position, x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)        
                 
        print_board(board)
        print_table(inventory)
Exemplo n.º 7
0
def handles_first_level():

    os.system("clear")
    # read_welcome_screen_file()
    x_current_position = 1
    y_current_position = 1
    # dutifulness = 100
    # lives = 3
    board = create_board('level_1.csv')
    last_hero_position = board[y_current_position][x_current_position]
    barriers = ['X', '⌂', '🚪']
    # table_elements = ["_", "|"]
    # door = "/"
    # blood = "~"
    # inventory = {'stamina' : 50, 'dollars' : 0, 'keys' : 0, 'revolver' : 0, 'bullets': 0}
    # added_items = []
    # horse = "♞"

    # note = "note"
    # key = "key"

    key_direction = getch()  #control

    while key_direction != "q":
        # x_direction = 0
        # y_direction = 0

        key_direction = getch()
        x_direction, y_direction = set_direction(key_direction)
        board[y_current_position][x_current_position] = last_hero_position
        print(y_current_position, x_current_position)
        # print(last_hero_position)

        if check_next_step(y_current_position + y_direction,
                           x_current_position + x_direction, barriers, board):
            y_current_position, x_current_position = makes_good_step(
                y_current_position, x_current_position, y_direction,
                x_direction)

        # if is_touching_horse(board[y_current_position + y_direction][x_current_position + x_direction], horse) and not is_key_in_inventory(key, added_items):
        # added_items.append(key)
        # add_to_inventory(inventory, added_items)

        # if is_touching_table(board[y_current_position + y_direction][x_current_position + x_direction], table_elements) and not is_note_in_inventory(note, added_items) and is_key_in_inventory(key, added_items):
        # added_items.append(note)
        # add_to_inventory(inventory, added_items)

        # if is_touching_blood(board[y_current_position + y_direction][x_current_position + x_direction], blood):
        # dutifulness = subtract_dutifulness(dutifulness)

        # if is_touching_door(board[y_current_position + y_direction][x_current_position + x_direction], door) and is_door_closed(obstacles, door) and is_key_in_inventory(key, added_items):
        # obstacles.remove(door)
        # return dutifulness, lives, inventory

        if inventory['dollars'] == 40:
            board[8][60] = "∃"

        if board[y_current_position][x_current_position] == '∃':
            handles_second_level()

        elif key_direction == "q":
            sys.exit()

        add_item_to_inventory(board, inventory, y_current_position,
                              x_current_position)
        last_hero_position = board[y_current_position][x_current_position]
        insert_player(board, y_current_position, x_current_position)
        print_board(board)
        # inv = add_to_inventory(inventory, added_items)
        print_table(inventory)