Esempio n. 1
0
 def  setUp(self):
     """ Build the Pkmn and Precondition Checker for the test """
     self.user = BuildPokemonBattleWrapper()
     self.target = BuildPokemonBattleWrapper()
     self.environment = BattleEnvironment()
     
     self.attack = AttackFactory.getAttackAsNew("DIG")
     self.preconditionChecker = PreconditionChecker(self.user, self.target, self.environment, self.attack)
     
     attack2 = AttackFactory.getAttackAsNew("TACKLE")
     self.preconditionChecker2 = PreconditionChecker(self.user, self.target, self.environment, attack2)
Esempio n. 2
0
 def setUp(self):
     """ Build the Attack Action """
     attack = AttackFactory.getAttackAsNew("TACKLE")
     self.priority = attack.speedDelegate.priority
     attack.use = self.use
     self.action = AttackAction(attack, None, None, None)
     self.usedAttack = False
 def  setUp(self):
     """ Build the Attack Action """
     attack = AttackFactory.getAttackAsNew("TACKLE")
     self.priority = attack.speedDelegate.priority
     attack.use = self.use
     self.action = AttackAction(attack, None, None, None)
     self.usedAttack = False
 def  setUp(self):
     """ Build the Trainer and Pokemon lists for use in tests """
     self.trainer = ComputerTrainer()
     self.battlePkmn = BuildPokemonBattleWrapper(trainer = self.trainer)
     self.targetPkmn  = BuildPokemonBattleWrapper()
     
     self.attack = AttackFactory.getAttackAsNew("TACKLE")
     self.battlePkmn.pkmn.battleDelegate.attacks = [self.attack]
Esempio n. 5
0
 def  setUp(self):
     """ Build the Pkmn and Delegate for the test """
     self.user = BuildPokemonBattleWrapper()
     self.target = BuildPokemonBattleWrapper()
     attack = AttackFactory.getAttackAsNew("TACKLE")
     
     self.hp = 100
     self.target.setCurrHP(self.hp)
     
     self.delegate = OneHitDelegate(attack, 1)
Esempio n. 6
0
 def levelUp(self):
     """ Level up the Pokemon """
     self.level += 1
     events = ["{0} leveled up to level {1}.".format(self.name, self.level)]
     
     self.stats.levelUp()
     if self.level in self.species.attacksForLevel:
         for attackName in self.species.attacksForLevel[self.level]:
             attack = AttackFactory.getAttackAsNew(attackName)
             event = LearnAttackEvent(self, attack)
             if event.canLearnAttack():
                 events += event.perform()
             else:
                 events.append(event)
     return events
    def loadFromXML(parent, tree):
        """  Build a Pokemon's Battle Information """
        delegate = PokemonBattleDelegate()
        
        # Set parent
        delegate.parent = parent
    
        # Get current HP
        delegate.parent.stats.currentHP = int(tree.find(Tags.currHPTag).text)
    
        # Read attacks
        delegate.attacks = []
        attacksTree = tree.find(Tags.attacksTag)
        for attack in attacksTree.getiterator(Tags.attackTag):
             delegate.attacks.append(AttackFactory.loadFromPkmnXML(attack))
        
        # Status
        delegate.status = Status()

        return delegate
 def  setUp(self):
     """ Build the Attack, Delegates and Pkmn for the test """
     self.attack = AttackFactory.getAttackAsNew("MEGA DRAIN")
     self.target = BuildPokemonBattleWrapper()
     self.damage = 20
 def setUp(self):
     """ Build the Attack, Delegates and Pkmn for the test """
     self.attack = AttackFactory.getAttackAsNew("MEGA DRAIN")
     self.target = BuildPokemonBattleWrapper()
     self.damage = 20
Esempio n. 10
0
tree = xml.etree.ElementTree.ElementTree(file=file)

print xml.etree.ElementTree.tostring(tree.getroot())
print "\n"
for pokemon in tree.getiterator("pokemon"):
    pokemon = xml.etree.ElementTree.ElementTree(pokemon)
    print pokemon.find("species").text

    print "Types"
    types = pokemon.find("types")
    for type in types.getiterator("type"):
        print type.text,
    print ""

    baseStats = pokemon.find("baseStats")
    for stat in statKeys:
        print stat, baseStats.find(stat).text

    print ""

file.close()

file = open("resources/temp", 'r')

attack = AttackFactory.loadFromXML(file)

print attack.name
print attack.type
print attack.hitDelegate.chanceToHit
print attack.damageDelegate
print attack.effectDelegates[0]
Esempio n. 11
0
def BuildAttack(attack="TACKLE"):
    """ Builds an Attack """
    return AttackFactory.getAttackAsNew(attack)
Esempio n. 12
0
 def setUp(self):
     """ Build action for the test"""
     attack = AttackFactory.getAttackAsNew("TACKLE")
     self.action = AttackAction(attack, None, None, None)
     self.turns = 2
     self.actionLock = ActionLock(self, self.action, self.turns)
Esempio n. 13
0
from Pokemon.pokemon_battle_delegate_factory import PokemonBattleDelegateFactory
from Pokemon.pokemon_battle_delegate import PokemonBattleDelegate
from Pokemon.pokemon import Pokemon

from Battle.Attack.attackfactory import AttackFactory
from Battle.Attack.DamageDelegates.damage_delegatefactory import DamageDelegateFactory

parent = Pokemon()
parent.level = 1

delegate = PokemonBattleDelegate()
delegate.parent = parent

PokemonBattleDelegateFactory.loadPokedexBattleInfoDB(delegate, "BULBASAUR")

print delegate.types
print delegate.stats

print "\n"

attack = AttackFactory.loadFromDB("SPLASH")
print attack.name, attack.type
print attack.damageDelegate
#print attack.damageDelegate.power, attack.damageDelegate.isPhysical, attack.damageDelegate.parent
print attack.hitDelegate
#print attack.hitDelegate.chanceToHit, attack.hitDelegate.parent
print attack.speedDelegate.priority
print attack.critDelegate.base
print attack.effectDelegates
Esempio n. 14
0
tree =  xml.etree.ElementTree.ElementTree(file=file)

print  xml.etree.ElementTree.tostring(tree.getroot())
print "\n"
for pokemon in tree.getiterator("pokemon"):
  pokemon = xml.etree.ElementTree.ElementTree(pokemon)
  print pokemon.find("species").text
  
  print "Types"
  types = pokemon.find("types")
  for type in types.getiterator("type"):
    print type.text,
  print ""
  
  baseStats = pokemon.find("baseStats")
  for stat in statKeys:
    print stat, baseStats.find(stat).text
  
  print ""
  
file.close()

file = open("resources/temp", 'r')

attack = AttackFactory.loadFromXML(file)

print attack.name
print attack.type
print attack.hitDelegate.chanceToHit
print attack.damageDelegate
print attack.effectDelegates[0]
Esempio n. 15
0
def BuildAttack(attack = "TACKLE"):
    """ Builds an Attack """
    return AttackFactory.getAttackAsNew(attack)
Esempio n. 16
0
 def setUp(self):
     """ Build action for the test"""
     attack = AttackFactory.getAttackAsNew("TACKLE")
     self.action = AttackAction(attack, None, None, None)
     self.turns = 2
     self.actionLock = ActionLock(self, self.action, self.turns)