Question in the description | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Question in the description

I am making a simple text only turn based rpg game by using python3 and I have used random choice() function to make the computer radomly attack on the player through a list of opponent attack I have used if else statement to reduce the health of player and oponent according to the attack choosen by player and computer but after the first attacks of both computer and player that is after the first turns of both , when the player will again attack (there is a list to choose for attacks for player too) how will i make the opponents health to reduce from the health left from the last attack for example if the first attack got 30 percent damage to opponent then on the second attack how would i make the health reduce from 70 percent rather than 100 same to do for players health

24th Jan 2021, 1:43 PM
Tanishq Kamble
Tanishq Kamble - avatar
2 Answers
+ 1
How do you store the status of the player and the computer during the game? It sounds to me like you are using loop for the main game. You could make health variables before the loop and change them based on attack outcome
24th Jan 2021, 1:50 PM
Lisa
Lisa - avatar
+ 1
I linked an example code for the thing with the health points. I don't know if this is how you want to set up your game. Maybe you can post your own code if you need further help... https://code.sololearn.com/c7lGw4CMiZVq/?ref=app
25th Jan 2021, 7:41 AM
Lisa
Lisa - avatar