Python RPG游戏恢复游戏循环失败

时间:2020-08-15 19:21:38

标签: python

这是我的简历功能

 > def resume_game(player_stats):
    global daycount
    global row
    global column
    
    read_save = open('save_file.txt', 'r')
    row = int(read_save.readline().strip('\n'))
    column = int(read_save.readline().strip('\n'))
    daycount = int(read_save.readline().strip('\n'))
    player_stats['HP'] = int(read_save.readline().strip('\n'))
    player_stats['Attack'] = int(read_save.readline().strip('\n'))
    player_stats['Defense'] = int(read_save.readline().strip('\n'))
    print(daycount)
    print('\n' + 'RESUMING GAME...')
    print_map(column, row, map_list)
    return player_stats

这是我的主程序

if choice == '1':
    while daycount > 0:
        if map_list[column][row] == 'H/T':
            town_actions()
            
        elif map_list[column][row] == 'H':
            rat_encounter(enemy_stats, rat, enemy_id)

        elif map_list[column][row] == 'H/K':
            RK_encounter(enemy_stats, rat_king, enemy_id)

if choice == '2':
    while player_stats['HP'] > 0:
        if map_list[column][row] == 'H/T':
            town_actions()
            
        elif map_list[column][row] == 'H':
            rat_encounter(enemy_stats, rat, enemy_id)

        elif map_list[column][row] == 'H/K':
            RK_encounter(enemy_stats, rat_king, enemy_id)

从代码中得到的结果是: enter image description here

我似乎无法使简历游戏正确循环。那么,我可以获取有关如何解决此问题的建议吗?

0 个答案:

没有答案