The item() class holds the information of the item and also runs the item effect when it gets used. Constructor def __init__ ( self , command , name , cost , usage): self .effect = command self .name = name self .cost = cost self .usage = usage The effect holds the string name of the effect for the item, usage holds the value of the Effect . The rest are self-explanatory. EffectHandler() def effectHandler ( self , user: PlayableCharacter , equip= True ): #learned how to specify type of parameter. if equip: if self .effect == "Def" : user.defense = user.defense + self .usage elif self .effect == "AtkPhy" or self .effect == "AtkMag" : user.attack = user.attack + self .usage else : if self .effect == "hp" : user = self .healing(user) return user This handles the effects of the item when it is used. If equip is true then it will check for the equip...
This is probably the simplest of all the functions, but still one of the most important.
def intiativeRoll(self, Combatant):
# defualt for now
self.listing.update({Combatant.displayName : Combatant})
self.order.append([Combatant.displayName, random.random()])
Essentially all it does is add combatants to the order and listing. As I said in the main post it was the order that holds the initiative and the listing has combatant names as keys and character object as the content. I used random.random() to assign a number to the name as the initiative value.
This will be used a lot by foePrep(). So now that it’s out of the way, I’ll hope into foePrep() next!
Comments
Post a Comment