Back to Python again, lol!
So I'm getting a little used to Python now and decided to have some fun with it. I spent a couple of hours making a program for a text-based battle simulator for Pokémon fans. I found a few dead end points with some of the variables I'm going to use for the damage calculations, but I won't worry about those for now until all the relevant stuff is out of the way first.
Some of the numbers and calculations may be inaccurate, but I put my own spin on it (especially with the critical hit variable that can never seem to be as accurate as it is in the actual game). I based all the numbers off of the calculations in Generation 4 of Pokémon (the period of time between the release of Pokémon Pearl and Pokémon SoulSilver) to start with, then changed up a few things while editing and debugging my code.
Here's what I've made so far:
import time from time import sleep global Modifier global Targets global Weather global Critical global CritMod global CritPerce #Critical Hit Percentage (as you can tell, I got a little...confused [get it?] with how to make the Critical Hit Ratio work) global CritStage CritStage = 0 global RANdommage import random from random import randint global STAB global TypeEff #'TypeEff' = "Type Effect(iveness)" global Burn global OtherDamEf #'OtherDamEf' = "Other Damage Effects" #Not sure how I'm gonna use all these variables yet. global Damage global Type Type = ["Normal", "Grass", "Fire", "Water", "Rock", "Fight", "Psychic", "Bug", "Flying", "Ground", "Poison", "Ghost", "Dark", "Steel", "Ice", "Dragon", "Fairy"] #Type = random.Type() time.sleep(0.25) #Still beta, doesn't have much use as of now. RANdommage = random.uniform(0.85, 1) * 1.5 * 4 #Testing out an example from Bulbapedia to see if decimal numbers from 5.1-6 come up. Will remove the "1.5" and "4" multiplication factors after I'm done testing all of this. #RANdommage = random.randint(1, 2) * 0.85 * 1.5 * 4 [Will be used if random.uniform float cannot be used. An example of me putting my own spin on the numbers...sorta] print(RANdommage) #Testing...testing...1, 2, 3... time.sleep(1) print(Type) #Again, has no use right now, but I'm just testing to see if the list will still function normally. time.sleep(1.78) #A landslide of Critical Confusion. Tried making my calculations as precise as in the game, but got a bunch of errors and headaches, so I evaded that little error and put my own rapid spin of it. (Tried using a 'While Condition' like in my previous post, but it didn't work) if CritStage == 0: CritPercent = random.randint(4, 100) elif CritStage == 1: CritPercent = random.randint(12, 100) elif CritStage == 2: CritPercent = random.randint(49, 100) elif CritStage == 3: CritPercent = random.randint(71, 100) elif CritStage == 4: CritPercent = random.randint(76, 100) else: CritPercent = random.randint(80, 100) #Don't worry...just don't worry. It's unnecessary. if CritPercent > 75: CritMod = 1 elif CritPercent <= 75: CritMod = 0 Critical = CritMod * 2 * 4 #Testing... def modMeasure(): Targets = 1 Weather = 1 STAB = 2 TypeEff = 4 Burn = 1 OtherDamEf = 1 Modifier = Targets * Weather * Critical * RANdommage * STAB * Type * Burn * Other #I changed 'Other' here to "OtherDamEf" as @stetim94 requested, Which solved a potential syntax error, so shouts to him =). print(Modifier) time.sleep(1.333) modMeasure() print("Super...effective!") #Again, random. Ignore this. time.sleep(0.875)
I'm sorta stuck here for now. This is the error that came up:
Traceback (most recent call last):
File "python", line 68 (Line containing: "modMeasure()"), in
File "python", line 64, in modMeasure (Line containing: "Modifier = Targets * Weather * Critical * RANdommage * STAB * Type * Burn * Other")
TypeError: can't multiply sequence by non-int of type 'float'
What I want to know is, how do I get around this hurdle? I can't seem to find a solution for this one...
Please help me.
I will make updates to this post as more replies come in. On that note, I'm offline for now. I will change the post again when I'm back on though, so if you're waiting for a reply back, check the end of the post. See y'all later!