示例#1
0
    def test_switch(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'mew'
        }, {
            'species': 'mewtwo'
        }, {
            'species': 'magnezone'
        }])
        battle.join(1, [{'species': 'pidgey', 'moves': ['peck']}])

        battle.choose(0, dex.Decision('switch', 2))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        mew = battle.sides[0].pokemon[0]
        mewtwo = battle.sides[0].pokemon[1]
        magnezone = battle.sides[0].pokemon[2]

        pidgey = battle.sides[1].pokemon[0]

        self.assertEqual(battle.sides[0].active_pokemon[0].species,
                         'magnezone')
        self.assertEqual(mew.hp, mew.maxhp)
        self.assertEqual(magnezone.hp, magnezone.maxhp - 3)
示例#2
0
    def test_normal(self):
        b = Battle(doubles=True, debug=False, rng=False)
        b.join(0, [{
            'species': 'pidgey',
            'moves': ['thunderbolt', 'protect']
        }, {
            'species': 'charmander',
            'moves': ['tackle']
        }])
        b.join(1, [{
            'species': 'rattata',
            'moves': ['thunderbolt', 'protect']
        }, {
            'species': 'squirtle',
            'moves': ['tackle', 'watergun']
        }])

        b.choose(
            0,
            [dex.Decision('move', 0, 'foe1'),
             dex.Decision('move', 0, 'foe1')])
        b.choose(1, [dex.Decision('move', 0), dex.Decision('move', 0)])
        b.do_turn()

        pidgey = b.sides[0].pokemon[0]
        charmander = b.sides[0].pokemon[1]
        rattata = b.sides[1].pokemon[0]
        squirtle = b.sides[1].pokemon[1]

        #damage calcs were done by hand
        self.assertEqual(rattata.hp, rattata.maxhp)
        self.assertEqual(squirtle.hp, squirtle.maxhp - 70)
示例#3
0
    def test_heal(self):
        b = Battle(debug=False, rng=False)
        b.join(0, [{
            'species': 'pikachuhoenn',
            'item': 'pikashuniumz',
            'moves': ['thunderbolt', 'protect']
        }])
        b.join(1, [{
            'species': 'magnemite',
            'item': 'normaliumz',
            'moves': ['tackle', 'recover']
        }])

        b.choose(0, dex.Decision('move', 0, zmove=True))
        b.choose(1, dex.Decision('move', 0, zmove=True))
        b.do_turn()

        b.choose(0, dex.Decision('move', 1))
        b.choose(1, dex.Decision('move', 1))
        b.do_turn()

        pikachu = b.sides[0].pokemon[0]
        magnemite = b.sides[1].pokemon[0]

        #damage calcs were done by hand
        self.assertEqual(magnemite.hp, magnemite.maxhp - 11)
        self.assertEqual(pikachu.hp, pikachu.maxhp - 42)
示例#4
0
    def test_fakeout(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'charmander',
            'level': 5,
            'moves': ['fakeout']
        }])
        battle.join(1, [{
            'species': 'magnemite',
            'level': 5,
            'moves': ['tackle']
        }])

        battle.choose(0, dex.Decision('move', 0))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        battle.choose(0, dex.Decision('move', 0))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        magnemite = battle.sides[1].pokemon[0]
        charmander = battle.sides[0].pokemon[0]

        #damage calcs were done by hand
        self.assertEqual(charmander.hp, charmander.maxhp - 5)
        self.assertEqual(magnemite.hp, magnemite.maxhp - 2)
示例#5
0
    def test_residual_damage(self):
        battle = Battle(debug=False, rng=False)

        battle.join(0, [{'species': 'pidgey'}])
        battle.join(1, [{'species': 'rattata', 'moves': ['willowisp']}])

        battle.choose(0, dex.Decision('move', 0))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        pidgey = battle.sides[0].pokemon[0]
        self.assertEqual(pidgey.hp, pidgey.maxhp-math.floor(pidgey.maxhp*0.0625))
示例#6
0
    def test_crit_damage(self):
        b = Battle(debug=False, rng=False)

        b.join(0, [{'species': 'spheal', 'moves': ['frostbreath']}])
        b.join(1, [{'species': 'rattata', 'moves': ['tackle']}])

        b.choose(0, dex.Decision('move', 0))
        b.choose(1, dex.Decision('move', 0))
        b.do_turn()

        rattata = b.sides[1].pokemon[0]

        self.assertEqual(rattata.hp, rattata.maxhp - 85)
示例#7
0
    def test_acrobatics(self):
        b = Battle(debug=False, rng=False)
        b.join(0, [{'species': 'charmander', 'moves': ['tackle']}])
        b.join(1, [{'species': 'pidgey', 'moves': ['acrobatics']}])

        b.choose(0, dex.Decision('move', 0))
        b.choose(1, dex.Decision('move', 0))
        b.do_turn()

        charmander = b.sides[0].pokemon[0]
        pidgey = b.sides[1].pokemon[0]

        #damage calcs were done by hand
        self.assertEqual(charmander.hp, charmander.maxhp - 76)
示例#8
0
    def test_acid_armor(self):
        b = Battle(debug=False, rng=False)
        b.join(0, [{'species': 'charmander', 'moves': ['tackle']}])
        b.join(1, [{'species': 'bulbasaur', 'moves': ['acidarmor']}])

        b.choose(0, dex.Decision('move', 0))
        b.choose(1, dex.Decision('move', 0))
        b.do_turn()

        charmander = b.sides[0].pokemon[0]
        bulbasaur = b.sides[1].pokemon[0]

        #damage calcs were done by hand
        self.assertEqual(bulbasaur.boosts['def'], 2)
示例#9
0
    def test_protect_invulnerable(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'pidgeot',
            'moves': ['tackle', 'protect']
        }])
        battle.join(1, [{'species': 'mew', 'moves': ['tackle']}])

        battle.choose(0, dex.Decision('move', 1))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        pidgeot = battle.sides[0].pokemon[0]
        self.assertEqual(pidgeot.hp, pidgeot.maxhp)
        self.assertTrue('protect' in pidgeot.volatile_statuses)
示例#10
0
    def test_pidgeot(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'pidgeot',
            'item': 'pidgeotite',
            'moves': ['tackle', 'protect']
        }])
        battle.join(1, [{'species': 'mew', 'moves': ['tackle']}])

        battle.choose(0, dex.Decision('move', 0, mega=True))
        battle.choose(1, dex.Decision('move', 0, mega=True))
        battle.do_turn()

        pidgeot = battle.sides[0].pokemon[0]
        self.assertEqual(pidgeot.species, 'pidgeotmega')
        self.assertEqual(pidgeot.hp, pidgeot.maxhp - 23)
示例#11
0
    def test_protect_one_turn(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'pidgeot',
            'moves': ['tackle', 'protect']
        }])
        battle.join(1, [{'species': 'mew', 'moves': ['tackle', 'protect']}])

        battle.choose(0, dex.Decision('move', 1))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        battle.choose(0, dex.Decision('move', 0))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        pidgeot = battle.sides[0].pokemon[0]
        self.assertEqual(pidgeot.hp, pidgeot.maxhp - 24)
示例#12
0
    def test_drain_moves(self):
        b = Battle(debug=False, rng=False)
        b.join(0, [{'species': 'charmander', 'moves': ['tackle']}])
        b.join(1, [{'species': 'bulbasaur', 'moves': ['tackle', 'absorb']}])

        b.choose(0, dex.Decision('move', 0))
        b.choose(1, dex.Decision('move', 0))
        b.do_turn()

        b.choose(0, dex.Decision('move', 0))
        b.choose(1, dex.Decision('move', 1))
        b.do_turn()

        charmander = b.sides[0].pokemon[0]
        bulbasaur = b.sides[1].pokemon[0]

        #damage calcs were done by hand
        self.assertEqual(charmander.hp, charmander.maxhp-30)
        self.assertEqual(bulbasaur.hp, bulbasaur.maxhp-36)
示例#13
0
    def test_zmove_protect(self):
        battle = Battle(debug=False, rng=False)
        """tests tackle with STAB and no STAB"""
        battle.join(0, [{
            'species': 'pikachuhoenn',
            'item': 'pikashuniumz',
            'moves': ['thunderbolt']
        }])
        battle.join(1, [{'species': 'magnemite', 'moves': ['protect']}])

        battle.choose(0, dex.Decision('move', 0, zmove=True))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        pikachu = battle.sides[0].pokemon[0]
        magnemite = battle.sides[1].pokemon[0]

        #damage calcs were done by hand
        self.assertEqual(magnemite.hp, magnemite.maxhp - 15)
示例#14
0
    def test_mewtwo_x(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'mewtwo',
            'item': 'mewtwonitex',
            'moves': ['tackle', 'protect']
        }])
        battle.join(1, [{
            'species': 'charizard',
            'item': 'charizarditex',
            'moves': ['tackle']
        }])

        battle.choose(0, dex.Decision('move', 0, mega=True))
        battle.choose(1, dex.Decision('move', 0, mega=False))
        battle.do_turn()

        mewtwo = battle.sides[0].pokemon[0]
        charizard = battle.sides[1].pokemon[0]
        self.assertEqual(mewtwo.species, 'mewtwomegax')
        self.assertEqual(mewtwo.hp, mewtwo.maxhp - 17)
示例#15
0
    def test_level_difference(self):
        battle = Battle(debug=False, rng=False)
        battle.join(0, [{
            'species': 'abomasnow',
            'level': 50,
            'moves': ['headbutt']
        }])
        battle.join(1, [{
            'species': 'wailord',
            'level': 100,
            'moves': ['surf']
        }])

        battle.choose(0, dex.Decision('move', 0))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        nic = battle.sides[0]
        sam = battle.sides[1]

        #damage calcs were done by hand
        self.assertEqual(nic.pokemon[0].hp, nic.pokemon[0].maxhp - 117)
        self.assertEqual(sam.pokemon[0].hp, sam.pokemon[0].maxhp - 29)
示例#16
0
    def test_tackle(self):
        battle = Battle(debug=False, rng=False)
        """tests tackle with STAB and no STAB"""
        battle.join(0, [{
            'species': 'charmander',
            'level': 5,
            'moves': ['tackle']
        }])
        battle.join(1, [{
            'species': 'magnemite',
            'level': 5,
            'moves': ['tackle']
        }])

        battle.choose(0, dex.Decision('move', 0))
        battle.choose(1, dex.Decision('move', 0))
        battle.do_turn()

        nic = battle.sides[0]
        sam = battle.sides[1]

        #damage calcs were done by hand
        self.assertEqual(nic.pokemon[0].hp, nic.pokemon[0].maxhp - 5)
        self.assertEqual(sam.pokemon[0].hp, sam.pokemon[0].maxhp - 2)