I am relatively new to Python. I use Python 2.7, and I am making a turn based battle game. I am struggling with a problem currently--if you are familiar with Pokemon you may be able to relate to this easily.
So I have a loop, that allows the user to attack, then subsequently, the enemy (computer-controlled) will attack the user. In my game, the attacks (governed by a class) each have their own accuracy level.. I want to create attacks that will change the accuracy for a certain number of iterations. In order to achieve this, I need to figure out how to change a variable for n number of turns. Here is some code that represents what I want to do, simplified:
accuracy = 0
while True:
attack = raw_input('What attack shall you choose?')
if attack == 'boost accuracy':
#accuracy = 100 for 3 iterations, then returns back to 0
#enemy does their attack
Note: I'm using a while True:loop because each monster has a health variable as well, and when that equals 0, or the monster is "dead", it breaks out of the loop.
I've tried using a turn = 0 (outside of loop), turn += 1 (inside of loop) type incrementation to fiddle around with this, but I can't seem to get it right. I feel as though this should be a rather simple solution and I am making it out to be much harder than it is. So, any ideas on how to change a variable for a certain number of iterations, then have it return to its original value?
turn += 1implementation? This seems like it would achieve what you're asking here.attackdidn't equal'boost accuracy', meaning I used a different attack, the accuracy would return to 0.