Skip to content

Commit

Permalink
Having pokemon.py load the type or types of pokemon into an array
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicrules1234 committed Oct 13, 2012
1 parent 9ab4047 commit a079fb8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pokemon.py
Expand Up @@ -38,6 +38,7 @@ def load_data(self, dom): #load data from a dom
d.description = g(t, "desc")
d.color = g(t, "color")
d.number = int(g(t, "num"))
d.type = g(dom, "type").split("|")
#load ability data
self.data.ability = Container()
self.data.ability.normal = []
Expand Down Expand Up @@ -140,6 +141,7 @@ def generate(self, level): #generate a new wild pokemon
self.stats = [self.calc_stat(x) for x in xrange(6)] #generate pokemon stats
self.stages = [0]*5 #move stages
self.hp = self.stats[0]
self.type = self.data.type
#generate abilities
self.ability = self.data.ability.normal[random.randrange(0, len(self.data.ability.normal))]
self.hidden_ability = self.data.ability.hidden[random.randrange(0, len(self.data.ability.hidden))]
Expand Down Expand Up @@ -200,6 +202,7 @@ def save(self): #save our data
s["habil"] = self.hidden_ability
s["g"] = self.gender
s["hp"] = self.hp
s["type"] = self.type
return s #return saved data
def load(self, s): #load saved data
global pokemon_data, nature_data
Expand All @@ -218,6 +221,7 @@ def load(self, s): #load saved data
self.gender = s["g"]
self.stages = [0]*5
self.hp = s["hp"]
self.type = s["type"]
#regenerate stats
self.stats = [self.calc_stat(x) for x in xrange(6)]

Expand Down

0 comments on commit a079fb8

Please sign in to comment.