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
 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