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...
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 commands and add the stats to the user. Otherwise, it heals the user.
Healing()
def healing(self, user: PlayableCharacter):
user.currentHealth = user.currentHealth + self.usage
if user.currentHealth >= user.health:
user.currentHealth = user.health
return user
Handles the healing of the item, it same as the rest in the
main. The main difference being this one heals by a set value.
Comments
Post a Comment