I am creating a text based RPG where the player starts with 600 skill points to allocate between 6 skills.
So I start by assigning the value 600 to the skill_points
variable.
skill_points = 600
then I assign a default value for each skills variable.
skill_1 = 0
skill_2 = 0
skill_3 = 0
Now I ask the player for input for the first skill.
skill1_input = int(input("Skill 1:"))
And I update the value of the variables.
skill_1 = skill_1 + skill1_input
skill_points = skill_points - skill1_input
Then I use a if statement to check if the number submitted is above the leftover skill points available, If not It prompts you to input the next skill.
if skill1_input > skill_points:
print("Not Valid")
else:
skill_2input = int(input("Skill 2:"))
Nested IF/ELSE statements repeat throughout all 6 skills until you allocate all your points. It is in a while loop so that if you don't use all of your skill points, it starts over at the first skill.
However, it is very finicky. At first I put 100 points into each skill and it worked fine. When I put 100 points into the first skill then 200 into the next skill, it prints not valid, even though there 500 points left and 200 is not is not more then 500.
There are multiple similar scenarios where the math should work properly yet the program still prints not valid
What is the current way to do this? Should I have not designed it using if statements?