def test_move_seismic_toss(self): m = self.genMove(name='Seismic Toss') p1 = self.genPkmn(moves=[m]) p2 = self.genPkmn() self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, (100, 100)) p2.level = 39 self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, (39, 39))
def test_ability_trace(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="trace", type1="normal") # Test #1: Wonder Guard wondermon = self.genPkmn(ability="wonder guard", moves=[self.genMove(type="normal"), self.genMove(type="fighting")]) attackdamages = calcSetup(p, wondermon, self.genEnv()).reds self.assertNotEffective(attackdamages[0]) self.assertSuperEffective(attackdamages[1]) # Test #2: Vital Spirit should prevent sleep vitalmon = self.genPkmn(ability="vital spirit", moves=[self.genMove(name="Spore")]) attackdamages = calcSetup(p, wondermon, self.genEnv()).reds self.assertNotEffective(attackdamages[0]) # Test #3: Technician technimon = self.genPkmn(ability="technician") p.moves = [self.genMove(power=50), self.genMove(power=60), self.genMove(power=70)] p.type1 = "fire" # avoid STAB pdamages = calcSetup(p, technimon, self.genEnv()).blues self.assertEqual(pdamages[0].damage, self.getDamage(50 * 1.5, 100, 100)) self.assertEqual(pdamages[1].damage, self.getDamage(60 * 1.5, 100, 100)) self.assertEqual(pdamages[2].damage, self.getDamage(70, 100, 100)) # Test #4: Tracing Trace doesn't cause an infinite loop of death tracimon = self.genPkmn(ability="technician") try: calcSetup(p, tracimon, self.genEnv()).blues except RuntimeError as e: # oops self.assertIsNone(e)
def test_ability_download(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="download", type1="dragon") p.moves = [ self.genMove(power=70, category=MoveCategory.physical), self.genMove(power=70, category=MoveCategory.special) ] # SPD lower: SPA raised to *1.5 pdamage = calcSetup(p, self.genPkmn(stats=self.genStats(DEF=100, SPD=80)), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100)) self.assertEqual(pdamage[1].damage, self.getDamage(70, 100 * 1.5, 80)) # DEF lower: ATK raised to *1.5 pdamage = calcSetup(p, self.genPkmn(stats=self.genStats(DEF=80, SPD=100)), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100 * 1.5, 80)) self.assertEqual(pdamage[1].damage, self.getDamage(70, 100, 100)) # DEF = SPD: SPA raised to *1.5 pdamage = calcSetup( p, self.genPkmn(stats=self.genStats(DEF=100, SPD=100)), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100)) self.assertEqual(pdamage[1].damage, self.getDamage(70, 100 * 1.5, 100))
def test_move_thunder(self): m = self.genMove(name='Thunder', accuracy=70) p = self.genPkmn(moves=[m]) self.assertEqual(calcSetup(p, self.genPkmn(), self.genEnv()).blues[0].accuracy, 70) self.assertEqual(calcSetup(p, self.genPkmn(), self.genEnv(weather='rain')).blues[0].accuracy, 100) self.assertEqual(calcSetup(p, self.genPkmn(), self.genEnv(weather='sun')).blues[0].accuracy, 50) self.assertEqual(calcSetup(p, self.genPkmn(), self.genEnv(weather='sandstorm')).blues[0].accuracy, 70)
def test_move_smelling_salts(self): m = self.genMove(name='Smelling Salts', power=60) p1 = self.genPkmn(stats=self.genStats(ATK=154), type1='dark', moves=[m]) p2 = self.genPkmn(stats=self.genStats(DEF=235)) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(60, 154, 235)) p2.status = 'par' self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(120, 154, 235))
def test_move_facade(self): m = self.genMove(name='Facade', power=70, type='normal') p1 = self.genPkmn(stats=self.genStats(ATK=121), type1='fire', moves=[m]) # no stab p2 = self.genPkmn(stats=self.genStats(DEF=212), type1='normal') self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(70, 121, 212)) p1.status = 'par' self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(140, 121, 212))
def test_weather(self): p = self.genPkmn(stats=self.genStats(ATK=102)) p2 = self.genPkmn(stats=self.genStats(DEF=112)) mf = self.genMove(type='fire', power=98) mw = self.genMove(type='water', power=96) # no STAB env = self.genEnv() p.moves = [mf, mw] s = calcSetup(p, p2, env) self.assertEqual(s.blues[0].damage, self.getDamage(98, 102, 112, 1)) # default self.assertEqual(s.blues[1].damage, self.getDamage(96, 102, 112, 1)) # default env.weather = 'sun' s = calcSetup(p, p2, env) self.assertEqual(s.blues[0].damage, self.getDamage(98, 102, 112, 1.5)) # boost self.assertEqual(s.blues[1].damage, self.getDamage(96, 102, 112, 0.5)) # nerf env.weather = 'rain' s = calcSetup(p, p2, env) self.assertEqual(s.blues[0].damage, self.getDamage(98, 102, 112, 0.5)) # nerf self.assertEqual(s.blues[1].damage, self.getDamage(96, 102, 112, 1.5)) # boost
def test_ability_solar_power(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="solar power", moves=[self.genMove(power=70, category=MoveCategory.special)], type1="dragon") p2 = self.genPkmn() pdamage = calcSetup(p, p2, self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100)) pdamage = calcSetup(p, p2, self.genEnv(weather="sun")).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100 * 1.5, 100)) # SpAttack * 1.5
def test_move_attract(self): p1 = self.genPkmn(gender=Gender.male, moves=[self.genMove(name='Attract')]) p2 = self.genPkmn(gender=Gender.male) self.assertNotEffective(calcSetup(p1, p2, self.genEnv()).blues[0]) p2.gender = Gender.female self.assertNormalEffective(calcSetup(p1, p2, self.genEnv()).blues[0]) p1.gender = Gender.none self.assertNotEffective(calcSetup(p1, p2, self.genEnv()).blues[0])
def test_ability_hydration(self): # In rain, status conditions go away p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="hydration") p2 = self.genPkmn(moves=[self.genMove(name="Thunder Wave")]) attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertNormalEffective(attackdamage[0]) attackdamage = calcSetup(p, p2, self.genEnv(weather="rain")).reds self.assertNotEffective(attackdamage[0])
def test_move_gyro_ball(self): m = self.genMove(name='Gyro Ball') p1 = self.genPkmn(stats=self.genStats(ATK=99, SPE=204), type1='ground', moves=[m]) p2 = self.genPkmn(stats=self.genStats(DEF=166, SPE=172)) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(25 * (172 / 204), 99, 166)) p1.SPE.stageAdd(2) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(25 * (172 / 408), 99, 166)) p2.SPE.stageAdd(3) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(25 * (430 / 408), 99, 166))
def test_move_seismic_toss(self): m = self.genMove(name='Seismic Toss') p1 = self.genPkmn(moves=[m]) p2 = self.genPkmn() self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, (100, 100)) p2.level = 39 self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, (39, 39))
def test_ability_snow_cloak(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="snow cloak") p2 = self.genPkmn(moves=[self.genMove(accuracy=100), self.genMove(accuracy=50)]) attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertEqual(attackdamage[0].accuracy, 100) self.assertEqual(attackdamage[1].accuracy, 50) attackdamage = calcSetup(p, p2, self.genEnv(weather="hail")).reds self.assertEqual(attackdamage[0].accuracy, int(100 * 1 / (1.2))) self.assertEqual(attackdamage[1].accuracy, int(50 * 1 / (1.2)))
def test_ability_leaf_guard(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="leaf guard") p2 = self.genPkmn(moves=[self.genMove(name="Thunder Wave"), self.genMove(name="Yawn"), self.genMove(name="Toxic")]) attackdamage = calcSetup(p, p2, self.genEnv()).reds for atk in attackdamage: self.assertNormalEffective(atk) attackdamage = calcSetup(p, p2, self.genEnv(weather="sun")).reds for atk in attackdamage: self.assertNotEffective(atk)
def test_ability_flower_gift(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="flower gift", moves=[self.genMove(power=70, category=MoveCategory.physical)], type1="dragon") p2 = self.genPkmn(moves=[self.genMove(power=70, category=MoveCategory.special)], type1="dragon") pdamage, attackdamage, env = calcSetup(p, p2, self.genEnv()) self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100)) self.assertEqual(attackdamage[0].damage, self.getDamage(70, 100, 100)) pdamage, attackdamage, env = calcSetup(p, p2, self.genEnv(weather="sun")) self.assertEqual(pdamage[0].damage, self.getDamage(70, 100 * 1.5, 100)) # Attack * 1.5 self.assertEqual(attackdamage[0].damage, self.getDamage(70, 100, 100 * 1.5)) # Spdef * 1.5
def test_ability_guts(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="guts", moves=[self.genMove(power=70)], type1="dragon") self.assertEqual(p.hasStatusCondition(), False) pdamage = calcSetup(p, self.genPkmn(), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100)) p.status = "brn" self.assertEqual(p.hasStatusCondition(), True) pdamage = calcSetup(p, self.genPkmn(), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100 * 1.5, 100)) # No attack drop from burn
def test_move_night_shade(self): m = self.genMove(name='Night Shade') p1 = self.genPkmn(moves=[m]) self.assertEqual( calcSetup(p1, self.genPkmn(), self.genEnv()).blues[0].damage, (100, 100)) p1.level = 57 self.assertEqual( calcSetup(p1, self.genPkmn(), self.genEnv()).blues[0].damage, (57, 57))
def test_ability_marvel_scale(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="marvel scale") p2 = self.genPkmn(moves=[self.genMove(name="Tackle", power=70)], type1="dragon") attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertEqual(attackdamage[0].damage, self.getDamage(70, 100, 100)) p.status = "psn" self.assertEqual(p.hasStatusCondition(), True) attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertEqual(attackdamage[0].damage, self.getDamage(70, 100, 100 * 1.5))
def test_move_solar_beam(self): p1 = self.genPkmn(type1="dragon",moves=[self.genMove(name="SolarBeam",power=70),self.genMove(name="Solar Beam",power=70)]) pdamages = calcSetup(p1,self.genPkmn(),self.genEnv()).blues for result in pdamages: self.assertEqual(result.damage, self.getDamage(70,100,100)) pdamages = calcSetup(p1,self.genPkmn(),self.genEnv(weather='rain')).blues for result in pdamages: self.assertEqual(result.damage, self.getDamage(70*0.5,100,100))
def test_ability_levitate(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="levitate") attackingmon = self.genPkmn(stats=self.genStats(ATK=100)) groundmove = self.genMove(type="ground", power=70) attackingmon.moves = [groundmove] pdamage, attackdamage, env = calcSetup(p, attackingmon, self.genEnv()) self.assertEqual(attackdamage[0].eff, Eff.NOT) # But can still be hit through Mold Breaker! moldbreakimon = self.genPkmn(stats=self.genStats(ATK=100), ability="mold breaker") moldbreakimon.moves = [groundmove] pdamage, attackdamage, env = calcSetup(p, moldbreakimon, self.genEnv()) self.assertEqual(attackdamage[0].eff, Eff.NORMAL)
def test_ability_normalize(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="normalize", moves=[self.genMove(power=70, type="fire")]) p2 = self.genPkmn(type1="ghost") pdamage = calcSetup(p, p2, self.genEnv()).blues # Fire should be able to hit ghost-types; with normalize it won't self.assertNotEffective(pdamage[0]) # Test for STAB; the move remains a fire-type move p3 = self.genPkmn(type1="fire") pdamage = calcSetup(p, p3, self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100, 1.5))
def test_ability_white_smoke(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="white smoke") p2 = self.genPkmn(stats=self.genStats(ATK=100)) p2.moves = [self.genMove(name="Swagger"), self.genMove(name="Growl")] d2 = calcSetup(p2, p, self.genEnv()).blues self.assertNormalEffective(d2[0]) self.assertNotEffective(d2[1]) p2.ability = "Mold Breaker" d2 = calcSetup(p2, p, self.genEnv()).blues self.assertNormalEffective(d2[0]) self.assertNormalEffective(d2[1])
def test_move_blizzard(self): self.assertEqual( calcSetup( self.genPkmn( moves=[self.genMove(name='Blizzard', accuracy=70)]), self.genPkmn(), self.genEnv()).blues[0].accuracy, 70) self.assertEqual( calcSetup( self.genPkmn( moves=[self.genMove(name='Blizzard', accuracy=70)]), self.genPkmn(), self.genEnv(weather='hail')).blues[0].accuracy, 100)
def test_move_smelling_salts(self): m = self.genMove(name='Smelling Salts', power=60) p1 = self.genPkmn(stats=self.genStats(ATK=154), type1='dark', moves=[m]) p2 = self.genPkmn(stats=self.genStats(DEF=235)) self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(60, 154, 235)) p2.status = 'par' self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(120, 154, 235))
def test_ability_solar_power(self): p = self.genPkmn( stats=self.genStats(ATK=100, DEF=100), ability="solar power", moves=[self.genMove(power=70, category=MoveCategory.special)], type1="dragon") p2 = self.genPkmn() pdamage = calcSetup(p, p2, self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100)) pdamage = calcSetup(p, p2, self.genEnv(weather="sun")).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100 * 1.5, 100)) # SpAttack * 1.5
def test_ability_snow_cloak(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="snow cloak") p2 = self.genPkmn( moves=[self.genMove(accuracy=100), self.genMove(accuracy=50)]) attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertEqual(attackdamage[0].accuracy, 100) self.assertEqual(attackdamage[1].accuracy, 50) attackdamage = calcSetup(p, p2, self.genEnv(weather="hail")).reds self.assertEqual(attackdamage[0].accuracy, int(100 * 1 / (1.2))) self.assertEqual(attackdamage[1].accuracy, int(50 * 1 / (1.2)))
def test_move_facade(self): m = self.genMove(name='Facade', power=70, type='normal') p1 = self.genPkmn(stats=self.genStats(ATK=121), type1='fire', moves=[m]) # no stab p2 = self.genPkmn(stats=self.genStats(DEF=212), type1='normal') self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(70, 121, 212)) p1.status = 'par' self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(140, 121, 212))
def test_move_thunder(self): m = self.genMove(name='Thunder', accuracy=70) p = self.genPkmn(moves=[m]) self.assertEqual( calcSetup(p, self.genPkmn(), self.genEnv()).blues[0].accuracy, 70) self.assertEqual( calcSetup(p, self.genPkmn(), self.genEnv(weather='rain')).blues[0].accuracy, 100) self.assertEqual( calcSetup(p, self.genPkmn(), self.genEnv(weather='sun')).blues[0].accuracy, 50) self.assertEqual( calcSetup(p, self.genPkmn(), self.genEnv(weather='sandstorm')).blues[0].accuracy, 70)
def test_move_grass_knot(self): m = self.genMove(name='Grass Knot') p1 = self.genPkmn(stats=self.genStats(ATK=99), type1='water', moves=[m]) p2 = self.genPkmn(stats=self.genStats(DEF=166)) p2.weight = 59 self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(80, 99, 166)) p2.weight = 0.6 self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(20, 99, 166)) p2.weight = 187 self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(100, 99, 166)) p2.weight = 347 self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(120, 99, 166)) p2.weight = 0.012 self.assertNotEffective(calcSetup(p1, p2, self.genEnv()).blues[0])
def test_move_punishment(self): m = self.genMove(name='Punishment') p1 = self.genPkmn(stats=self.genStats(ATK=85), type1='dark', moves=[m]) p2 = self.genPkmn(stats=self.genStats(DEF=165, ATK=123, SPD=245, SPE=201)) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(60, 85, 165)) p1.DEF.stageAdd(1) p2.ATK.stageAdd(1) p2.SPD.stageAdd(1) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(100, 85, 165)) p2.SPD.stageAdd(1) p2.SPE.stageAdd(-1) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(120, 85, 165)) p2.SPD.stageAdd(-2) p2.SPE.stageAdd(2) self.assertEqual(calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(100, 85, 165))
def test_ability_leaf_guard(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="leaf guard") p2 = self.genPkmn(moves=[ self.genMove(name="Thunder Wave"), self.genMove(name="Yawn"), self.genMove(name="Toxic") ]) attackdamage = calcSetup(p, p2, self.genEnv()).reds for atk in attackdamage: self.assertNormalEffective(atk) attackdamage = calcSetup(p, p2, self.genEnv(weather="sun")).reds for atk in attackdamage: self.assertNotEffective(atk)
def test_ability_solid_rock(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="solid rock", type1="grass", type2="bug") attackingmon = self.genPkmn(stats=self.genStats(ATK=100), type1="ghost") # prevent STAB nveffective = self.genMove(type="water", power=70) fourxeffective = self.genMove(type="fire", power=70) supereffective = self.genMove(type="poison", power=70) normaleffective = self.genMove(type="normal", power=70) attackingmon.moves = [ nveffective, supereffective, normaleffective, fourxeffective ] attackdamages = calcSetup(attackingmon, p, self.genEnv()).blues self.assertEqual(attackdamages[0].damage, self.getDamage(70, 100, 100, 0.5)) # not very: unaffected self.assertEqual(attackdamages[1].damage, self.getDamage(70, 100, 100, 1.5)) # super: 1.5x instead of 2 self.assertEqual(attackdamages[2].damage, self.getDamage(70, 100, 100, 1)) # normal: 1x self.assertEqual(attackdamages[3].damage, self.getDamage(70, 100, 100, 3)) # 4x effective: 3x instead of 4
def test_ability_suction_cups(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="suction cups") m = self.genMove(name="Whirlwind") m2 = self.genMove(name="Roar") d2 = calcSetup(p, self.genPkmn(moves=[m, m2]), self.genEnv()).reds self.assertEqual(d2[0].eff, Eff.NOT) self.assertEqual(d2[1].eff, Eff.NOT)
def test_ability_water_absorb(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="water absorb") p2 = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), moves=[self.genMove(type="water", power=70)]) self.assertNotEffective(calcSetup(p2, p, self.genEnv()).blues[0])
def test_ability_pure_power(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="pure power", moves=[self.genMove(power=70)], type1="fire") pdamage = calcSetup(p, self.genPkmn(), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 200, 100))
def test_ability_water_veil(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="water veil") p2 = self.genPkmn(stats=self.genStats(ATK=100, DEF=100)) m = self.genMove(name="Will-o-Wisp", category=MoveCategory.nonDamaging) p2.moves = [m] self.assertNotEffective(calcSetup(p2, p, self.genEnv()).blues[0])
def test_move_solar_beam(self): p1 = self.genPkmn(type1="dragon", moves=[ self.genMove(name="SolarBeam", power=70), self.genMove(name="Solar Beam", power=70) ]) pdamages = calcSetup(p1, self.genPkmn(), self.genEnv()).blues for result in pdamages: self.assertEqual(result.damage, self.getDamage(70, 100, 100)) pdamages = calcSetup(p1, self.genPkmn(), self.genEnv(weather='rain')).blues for result in pdamages: self.assertEqual(result.damage, self.getDamage(70 * 0.5, 100, 100))
def test_ability_damp(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="damp") p2 = self.genPkmn(stats=self.genStats(ATK=100)) p2.moves = [self.genMove(name="Selfdestruct"), self.genMove(name="Tackle")] d2 = calcSetup(p2, p, self.genEnv()).blues self.assertNotEffective(d2[0]) self.assertNormalEffective(d2[1])
def test_ability_heatproof(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="heatproof") attackingmon = self.genPkmn(stats=self.genStats(ATK=100)) p.moves = [self.genMove(type="fire", power=70)] d1, d2, env = calcSetup(p, attackingmon, self.genEnv()) self.assertEqual(d1[0].damage, self.getDamage(70, 100, 100, 0.5))
def test_ability_flash_fire(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="flash fire") attackingmon = self.genPkmn( stats=self.genStats(), moves=[self.genMove(type="fire", power=70)]) self.assertNotEffective( calcSetup(attackingmon, p, self.genEnv()).blues[0])
def test_move_ohko(self): self.assertEqual( calcSetup(self.genPkmn(moves=[self.genMove(name='Fissure')]), self.genPkmn(), self.genEnv()).blues[0].kind, Kind.ohko) self.assertEqual( calcSetup(self.genPkmn(moves=[self.genMove(name='Guillotine')]), self.genPkmn(), self.genEnv()).blues[0].kind, Kind.ohko) self.assertEqual( calcSetup(self.genPkmn(moves=[self.genMove(name='Sheer Cold')]), self.genPkmn(), self.genEnv()).blues[0].kind, Kind.ohko) self.assertEqual( calcSetup(self.genPkmn(moves=[self.genMove(name='Horn Drill')]), self.genPkmn(), self.genEnv()).blues[0].kind, Kind.ohko) self.assertNotEqual( calcSetup(self.genPkmn(moves=[self.genMove(name='Seismic Toss')]), self.genPkmn(), self.genEnv()).blues[0].kind, Kind.ohko)
def test_ability_volt_absorb(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="volt absorb") p2 = self.genPkmn(stats=self.genStats(ATK=100, DEF=100)) m = self.genMove(type="electric", power=70) p2.moves = [m] self.assertNotEffective(calcSetup(p2, p, self.genEnv()).blues[0])
def test_ability_reckless(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="reckless", type1="fire") p.moves = [self.genMove(name="Flare Blitz", power=70), self.genMove(name="Tackle", power=70)] self.assertEqual(p.moves[0].isRecoilMove(), True) pdamage = calcSetup(p, self.genPkmn(), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70 * 1.2, 100, 100)) self.assertEqual(pdamage[1].damage, self.getDamage(70, 100, 100))
def test_ability_hyper_cutter(self): # Attack cannot be reduced p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="hyper cutter") p2 = self.genPkmn(moves=[self.genMove(name="Growl"), self.genMove(name="Swagger")]) attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertNotEffective(attackdamage[0]) self.assertNormalEffective(attackdamage[1])
def test_ability_hustle(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="hustle", type1="dragon") p.moves = [self.genMove(power=70, category=MoveCategory.physical, accuracy=100), self.genMove(power=70, category=MoveCategory.special, accuracy=100)] pdamage = calcSetup(p, self.genPkmn(), self.genEnv()).blues self.assertEqual(pdamage[0].damage, self.getDamage(70, 100 * 1.5, 100)) self.assertEqual(pdamage[0].accuracy, 100 * 0.8) self.assertEqual(pdamage[1].damage, self.getDamage(70, 100, 100)) # spatk isnt boosted self.assertEqual(pdamage[1].accuracy, 100)
def test_ability_compound_eyes(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="compound eyes") p2 = self.genPkmn(stats=self.genStats(ATK=100, DEF=100)) m = self.genMove(accuracy=10) p.moves = [self.genMove(accuracy=10), self.genMove(accuracy=80)] pdamage = calcSetup(p, p2, self.genEnv()).blues self.assertEqual(pdamage[0].accuracy, 10 * 1.3) self.assertEqual(pdamage[1].accuracy, 100) # Upper cap of 100
def test_move_gyro_ball(self): m = self.genMove(name='Gyro Ball') p1 = self.genPkmn(stats=self.genStats(ATK=99, SPE=204), type1='ground', moves=[m]) p2 = self.genPkmn(stats=self.genStats(DEF=166, SPE=172)) self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(25 * (172 / 204), 99, 166)) p1.SPE.stageAdd(2) self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(25 * (172 / 408), 99, 166)) p2.SPE.stageAdd(3) self.assertEqual( calcSetup(p1, p2, self.genEnv()).blues[0].damage, self.getDamage(25 * (430 / 408), 99, 166))
def test_ability_vital_spirit(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="vital spirit") p2 = self.genPkmn(moves=[self.genMove(name="Spore")]) p.moves = [self.genMove(name="Rest")] pdamage, attackdamage, env = calcSetup(p, p2, self.genEnv()) self.assertNotEffective(pdamage[0]) # Rest won't work self.assertNotEffective(attackdamage[0]) # Spore won't put to sleep
def test_ability_rivalry(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="rivalry", gender=Gender.male) if not p.abilityVisuable: return # rivalry doesn't work as a design choice p2 = self.genPkmn(gender=Gender.male) m = self.genMove(power=70) p.moves = [m] pdamage, attackdamage, env = calcSetup(p, p2, self.genEnv()) self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100, 1.25)) p2.gender = Gender.female pdamage, attackdamage, env = calcSetup(p, p2, self.genEnv()) self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100, 0.75)) p2.gender = Gender.none pdamage, attackdamage, env = calcSetup(p, p2, self.genEnv()) self.assertEqual(pdamage[0].damage, self.getDamage(70, 100, 100, 1))
def test_ability_oblivious(self): p = self.genPkmn(stats=self.genStats(ATK=100, DEF=100), ability="oblivious", gender=Gender.male) p2 = self.genPkmn(moves=[self.genMove(name="attract")], gender=Gender.female) attackdamage = calcSetup(p, p2, self.genEnv()).reds self.assertNotEffective(attackdamage[0])