def setUp(self):
     """ Builds the delegate and pkmn for use in the tests """
     self.pkmn = BuildPokemonBattleWrapper()
     self.status = "PAR"
     attack = Attack()
     attack.type = ""
     self.delegate = ApplyStatusDelegate(attack, self.status, 1)
 def setUp(self):
     """ Builds the delegate and pkmn for use in the tests """
     self.pkmn = BuildPokemonBattleWrapper()
     self.status = "PAR"
     attack = Attack()
     attack.type = ""
     self.delegate = ApplyStatusDelegate(attack, self.status, 1)
Example #3
0
 def loadFromPokemonFile(file):
     """ Load an attack as saved within a Pokemon instance in a file """
     attack = Attack()
     attackdex = AttackFactory.getAttackdexTree()
   
     attack.name = file.readline().strip()
 
     temp = ""
     while (temp.find(attack.name) == -1):
         """ Read the file until you find the species we need """
         temp = attackdex.readline().strip()
 
     attack.type = attackdex.readline().strip()
     
     #Load delegates
     attack.hitDelegate = HitDelegateFactory.loadFromAttackDex(attackdex, attack)
     attack.damageDelegate = DamageDelegateFactory.loadFromAttackDex(attackdex, attack)
         
     attack.effectDelegate = EffectDelegateFactory.loadFromAttackDex(attackdex)
 
     # Get currPP and PP from file
     values = file.readline().strip().split(" ")
     attack.powerPoints = int(values[0])
     attack.currPowerPoints = int(values[1])
             
     attackdex.close()
 
     return attack
Example #4
0
 def buildAttackFromDB(cursor, name):
     """ Build an Attack from a Database connection """
     attack = Attack()
     
     cursor.execute("SELECT Type.name from Attack, Type where Attack.name = ? and Attack.type_id = Type.id", (name,))
     type = cursor.fetchone()[0]
     
     attack.name = name
     attack.type = type
     
     # Delegates
     for delegateCategory in AttackFactory.factories.keys():
         delegate = AttackFactory.getDelegateDB(cursor, delegateCategory, attack)
         attack.addDelegate(delegateCategory, delegate)
         
     attack.effectDelegates = EffectDelegateFactory.loadAllEffectsFromDB(cursor, attack)
             
     return attack
Example #5
0
 def buildAttackFromXML(tree):
     """ Build an Attack from XML tree """
     attack = Attack()
     
     attack.name = tree.find(Tags.nameTag).text
     attack.type = tree.find(Tags.typeTag).text
     attack.makes_contact = Tags.contactAttribute in tree.attrib
     
     # Delegates
     for delegateCategory in AttackFactory.factories.keys():
         delegate = AttackFactory.getDelegate(tree, delegateCategory, attack)
         attack.addDelegate(delegateCategory, delegate)
         
     effects = tree.find(Tags.effectDelegatesTag)
     
     if effects is not None:
         for effect in effects.getchildren():
             delegate = EffectDelegateFactory.loadFromXML(effect, attack)
             attack.addDelegate(Tags.effectDelegateTag, delegate)
             
     return attack
Example #6
0
 def getConfusionAttack():
     """  Builds and returns the DamageDelegate used for Confusion """
     attack = Attack()
     attack.type = ""
     return DamageDelegate(attack, 40, 1)
Example #7
0
 def setUp(self):
     """ Build the Attack and Damage Delegate """
     attack = Attack()
     attack.type ="FIRE"
     self.delegate = DamageDelegate(attack, 0, 1)
 def getConfusionAttack():
     """  Builds and returns the DamageDelegate used for Confusion """
     attack = Attack()
     attack.type = ""
     return DamageDelegate(attack, 40, 1)