Mar-27-2019, 02:28 AM
So I am making my first game in python. It is a text RPG. Obviously I can't post the entire code on here, but I think this will be enough to hopefully get this solved.
So right now I am creating achievements. For example, I have one where defeating 10 enemies gives you an achievement titled "soldier". My problem is with this. I set my enemies defeated to 9 and then went into combat and defeated one more to see if the achievement would work. I got this error:
So right now I am creating achievements. For example, I have one where defeating 10 enemies gives you an achievement titled "soldier". My problem is with this. I set my enemies defeated to 9 and then went into combat and defeated one more to see if the achievement would work. I got this error:
Error:File "C:/Users/DESKTOP/.PyCharmCE2018.3/config/scratches/Text RPG.py", line 672, in earn_achievement
if player.enemies_killed >= 10 and soldier_achievement == False:
UnboundLocalError: local variable 'soldier_achievement' referenced before assignmentThis is the code that it is referencing:soldier_achievement = False
hunter_achievement = False
slayer_achievement = False
executioner_achievement = False
john_achievement = False
shopper_achievement = False
merchant_achievement = False
cheater_achievement = False
dedication_achievement = False
frich_achievement = False
frrich_achievement = False
fstich_achievement = False
explorer_achievement = False
def earn_achievement():
if player.enemies_killed >= 10 and soldier_achievement == False:
print("#######################")
print("# Achievement Earned! #")
print("# 'Soldier' #")
print("#######################")
player.achievements.append('Soldier')
soldier_achievement = True
player.gold += 10
prompt()I've been looking at this for an hour and trying different things to get it to work, but nothing has changed. Anyone have any ideas? If you need more information I will gladly give some.
