Hello, I go by Pivot. Recently, I was trying to make a mini Pokemon damage calculator for a friend of mine that would have basic functions using loops and “if/elif/else” statements. The purpose was to make the process much faster and simpler by answering a couple of questions and using those answers to fill in blanks in the damage equation(s). I have tried multiple methods to fix the problem, but to no avail, so as a last resort, I decided to post here. I am only a few months new into using Python, and I currently have version 3.8. Below I will include the code. Any help would be greatly appreciated!
Damage Calcs
Stuff needed to import
import math
from fractions import FractionThe basic questions
print(“Welcome to the shortcut damage calculator made by Pivot. Check below to begin.”)
print(“What is the base power?”)
power = input()
print(“What is the base attack stat? (It does not matter whether it is physical or special)”)
attack = input()
print(“What is the base defense stat? (It does not matter whether it is physical or special)”)
defense = input()Bug-fixing.
power = int(power)
attack = int(attack)
defense = int(defense)The calcs and stuff
The default equation for damage calculation
dama = Fraction(Fraction(2 * 100/5) + 2 * power * attack/defense/50) + 2
dama * 1.0The damage calculation plus any additional modifiers, A-F.
A-F are replaced by further below code. However, not every letter is replaced, so each one is 1.
A = 1
B = 1
C = 1
D = 1
E = 1
F = 1
damaZ = dama * A * B * C * D * E * F
ABE = 2
ADC = 1More questions
If/else loop- if the user answers No, it will solve the equation and give the results.
If user answers Yes, it will continue to next loop.
Else statement is an error message meant to tell the user that their answer did not work, and will prompt them to retry.
f = input("Are there other factors? Enter 1 for Yes, 2 for No. ")
def factar():
if f == ADC:
print(“Okay, let me get your answer for you.”)
print(“Your damage is”, damaZ, “% out of the total.”)
quitif f == ABE: print("Okay. Available commands are STAB, weather, burn, stat change, critical hit.") else: print("You must have input a wrong command. Sorry, but you'll have to restart the calculator. :(") print("If you believe this is a bug, please let me know!")Questions regarding modifiers
Each modifier substituted with a number for convenience
Each if statement applies to each modifier, replacing A-F in the default equation and giving the solution, then stopping.
Ideal process would be input true example → if input == true example → add modifier to default equation.
Also ideal process would allow user to add multiple modifiers by going back to the first menu
and reselecting a different number.
bite = B
print(“Which factor do you wish to add? 1:STAB, 2:Weather, 3:Burn, 4:Stat change.”)
bite = input()def biet():
for input in bite:
if bite == 1:
print(“Okay, let me get your answer for you.”)
A = 1.5
print(“Your damage is”, damaZ, “% out of the total.”)
if bite == 2:
print(“Okay, does this weather harm or help your user’s attack damage? 1:Harm, 2:Help.”)
weather = input()
if weather == 1:
B = 0.5
print(“Your damage is”, damaZ, “% out of the total.”)
if weather == 2:
B = 1.5
print(“Your damage is”, damaZ, “% out of the total.”)
if bite == 3:
C = 0.5
print(“Your damage is”, damaZ, “% out of the total.”)
if bite == 4:
print(“Please enter the numerical value of the stat change, from 6 to -6, including 0 as the default.”)
stat = 10
int(stat)
stat = input()if stat == -6: D = 2/8 if stat == -5: D = 2/7 if stat == -4: D = 2/6 if stat == -3: D = 2/5 if stat == -2: D = 2/4 if stat == -1: D = 2/3 if stat == 0: D = 1 if stat == 1: D = 3/2 if stat == 2: D = 2 if stat == 3: D = 5/2 if stat == 4: D = 3 if stat == 5: D = 7/2 if stat == 6: D = 4