Beispiel #1
0
    def test_gets_only_move_for_both_sides(self):
        self.battle.user.active.moves = [Move('thunderbolt')]
        self.battle.opponent.active.moves = [Move('thunderbolt')]

        expected_options = ['thunderbolt'], ['thunderbolt']

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #2
0
    def test_double_fainted_active_pokemon(self):
        self.battle.user.active.hp = 0
        self.battle.opponent.active.hp = 0
        self.battle.user.active.moves = [
            Move('tackle'),
            Move('charm'),
        ]
        self.battle.opponent.active.moves = [
            Move('tackle'),
            Move('thunderbolt'),
        ]

        self.battle.user.reserve = [
            Pokemon('caterpie', 100),
            Pokemon('spinarak', 100)
        ]
        self.battle.opponent.reserve = [
            Pokemon('caterpie', 100),
            Pokemon('houndour', 100)
        ]

        expected_options = (['switch caterpie', 'switch spinarak'],
                            ['switch caterpie', 'switch houndour'])

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #3
0
    def test_opponent_has_no_moves_when_uturn_happens_after_switch(self):
        self.battle.user.active.moves = [
            Move('tackle'),
            Move('charm'),
            Move('uturn'),
        ]
        self.battle.opponent.active.moves = [
            Move('tackle'),
            Move('charm'),
        ]

        self.battle.user.reserve = [
            Pokemon('caterpie', 100),
            Pokemon('spinarak', 100)
        ]
        self.battle.opponent.reserve = [Pokemon('caterpie', 100)]

        # using uturn on the previous turn would cause force_switch to be True
        self.battle.force_switch = True

        self.battle.turn = 5

        self.battle.user.last_used_move = LastUsedMove(
            move='uturn',
            pokemon_name='pikachu',
            turn=5,
        )

        self.battle.opponent.last_used_move = LastUsedMove(
            move='switch pikachu', pokemon_name=None, turn=5)

        expected_options = (['switch caterpie', 'switch spinarak'], ['splash'])

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #4
0
    def test_gets_multiple_switches_and_multiple_moves(self):
        self.battle.user.active.moves = [
            Move('tackle'),
            Move('charm'),
        ]
        self.battle.opponent.active.moves = [
            Move('tackle'),
            Move('thunderbolt'),
        ]

        self.battle.user.reserve = [Pokemon('caterpie', 100), Pokemon('spinarak', 100)]
        self.battle.opponent.reserve = [Pokemon('caterpie', 100), Pokemon('houndour', 100)]

        expected_options = (
            [
                'tackle',
                'charm',
                'switch caterpie',
                'switch spinarak'
            ],
            [
                'tackle',
                'thunderbolt',
                'switch caterpie',
                'switch houndour'
            ]
        )

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #5
0
    def test_gives_no_options_for_user_and_only_switches_for_opponent_when_opponent_active_is_dead(self):
        self.battle.opponent.active.hp = 0
        self.battle.user.active.moves = [
            Move('tackle'),
            Move('charm'),
        ]
        self.battle.opponent.active.moves = [
            Move('tackle'),
            Move('thunderbolt'),
        ]

        self.battle.user.reserve = [Pokemon('caterpie', 100), Pokemon('spinarak', 100)]
        self.battle.opponent.reserve = [Pokemon('caterpie', 100), Pokemon('houndour', 100)]

        expected_options = (
            [
                'splash'
            ],
            [
                'switch caterpie',
                'switch houndour'
            ]
        )

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #6
0
    def test_ignores_moves_and_gives_opponent_no_option_when_force_switch_is_true(self):
        self.battle.force_switch = True
        self.battle.user.active.moves = [
            Move('tackle'),
            Move('charm'),
        ]
        self.battle.opponent.active.moves = [
            Move('tackle'),
            Move('thunderbolt'),
        ]

        self.battle.user.reserve = [Pokemon('caterpie', 100), Pokemon('spinarak', 100)]
        self.battle.opponent.reserve = [Pokemon('caterpie', 100), Pokemon('houndour', 100)]

        expected_options = (
            [
                'switch caterpie',
                'switch spinarak'
            ],
            [
                'splash'
            ]
        )

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #7
0
    def test_opponent_has_no_moves_results_in_splash_or_switches(self):
        self.battle.user.active.moves = [
            Move('tackle'),
            Move('charm'),
        ]
        self.battle.opponent.active.moves = [
        ]

        self.battle.user.reserve = [Pokemon('caterpie', 100), Pokemon('spinarak', 100)]
        self.battle.opponent.reserve = [Pokemon('caterpie', 100)]

        expected_options = (
            [
                'tackle',
                'charm',
                'switch caterpie',
                'switch spinarak'
            ],
            [
                'splash',
                'switch caterpie',
            ]
        )

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #8
0
    def test_decrements_seen_move_pp_if_seen_again(self):
        split_msg = ['', 'move', 'p2a: Caterpie', 'String Shot']
        m = Move("String Shot")
        m.current_pp = 5
        self.battle.opponent.active.moves.append(m)
        move(self.battle, split_msg)

        self.assertEqual(4, m.current_pp)
Beispiel #9
0
 def setUp(self):
     self.battler = Battler()
     self.battler.active = Pokemon('pikachu', 100)
     self.battler.active.moves = [
         Move('thunderbolt'),
         Move('volttackle'),
         Move('agility'),
         Move('doubleteam'),
     ]
Beispiel #10
0
    def test_taunt_with_multiple_moves(self):
        self.battler.active.moves.append(Move('watergun'))
        self.battler.active.moves.append(Move('tackle'))
        self.battler.active.moves.append(Move('calmmind'))
        self.battler.active.volatile_statuses.append("taunt")

        self.battler.lock_moves()

        self.assertFalse(self.battler.active.get_move('watergun').disabled)
        self.assertFalse(self.battler.active.get_move('tackle').disabled)
        self.assertTrue(self.battler.active.get_move('calmmind').disabled)
Beispiel #11
0
    def test_trick_with_scarf_makes_sense(self):
        nature = 'jolly'
        spread = '0,0,0,252,4,252'
        item = 'choicescarf'
        ability = 'intimidate'
        moves = [
            Move('trick'),
            Move('darkpulse'),
            Move('thunderbolt'),
        ]

        self.assertTrue(set_makes_sense(nature, spread, item, ability, moves))
Beispiel #12
0
    def test_multiple_move_nastyplot_with_choicespecs_does_not_make_sense(self):
        nature = 'jolly'
        spread = '0,0,0,252,4,252'
        item = 'choicespecs'
        ability = 'intimidate'
        moves = [
            Move('nastyplot'),
            Move('darkpulse'),
            Move('thunderbolt'),
        ]

        self.assertFalse(set_makes_sense(nature, spread, item, ability, moves))
Beispiel #13
0
    def test_phantomforce_volatilestatus_makes_the_move_forced_for_user(self):
        self.battle.user.active.moves = [
            Move('thunderbolt'),
            Move('tackle'),
            Move('charm'),
            Move('phantomforce'),
        ]
        self.battle.opponent.active.moves = [Move('thunderbolt')]

        self.battle.user.active.volatile_statuses = ["phantomforce"]

        expected_options = ['phantomforce'], ['thunderbolt']

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #14
0
 def test_gets_all_moves_when_an_unknown_set_is_there(self):
     self.get_sets_mock.return_value = {
         constants.SETS: {
             "grassknot|hiddenpowerice60|voltswitch|volttackle": 16,
             "grassknot|hiddenpowerice60|irontail|poisonjab": 33
         },
         constants.MOVES: {
             "grassknot": 1,
             "hiddenpowerice60": 1,
             "voltswitch": 1,
             "volttackle": 1,
             "irontail": 1,
             "poisonjab": 1,
         }
     }
     expected_moves = [
         Move("tackle"),
         Move("grassknot"),
         Move("hiddenpowerice60"),
         Move("voltswitch"),
         Move("volttackle"),
         Move("irontail"),
         Move("poisonjab")
     ]
     p = Pokemon('pikachu', 100)
     p.moves = [Move("tackle")]
     p.update_moves_for_random_battles()
     self.assertEqual(expected_moves, p.moves)
Beispiel #15
0
    def test_gets_multiple_moves_for_both_sides(self):
        self.battle.user.active.moves = [
            Move('thunderbolt'),
            Move('agility'),
            Move('tackle'),
            Move('charm'),
        ]
        self.battle.opponent.active.moves = [
            Move('thunderbolt'),
            Move('swift'),
            Move('dragondance'),
            Move('stealthrock'),
        ]

        expected_options = (
            [
                'thunderbolt',
                'agility',
                'tackle',
                'charm'
            ],
            [
                'thunderbolt',
                'swift',
                'dragondance',
                'stealthrock'
            ]
        )

        self.assertEqual(expected_options, self.battle.get_all_options())
Beispiel #16
0
    def test_expected_plus_known_does_not_exceed_four_with_chance_moves(self):
        p = Pokemon('pikachu', 100)

        p.moves = [
            Move('tackle'),
            Move('splash'),
            Move('stringshot'),
        ]
        moves = [('move1', 95), ('move2', 80), ('move3', 40), ('move4', 40)]

        moves = p.get_possible_moves(moves)

        expected_result = (['move1'], [])

        self.assertEqual(expected_result, moves)
Beispiel #17
0
    def test_taunt_does_not_lock_special_move(self):
        self.battler.active.moves.append(Move('watergun'))
        self.battler.active.volatile_statuses.append("taunt")

        self.battler.lock_moves()

        self.assertFalse(self.battler.active.get_move('watergun').disabled)
Beispiel #18
0
    def test_adds_move_to_opponent(self):
        split_msg = ['', 'move', 'p2a: Caterpie', 'String Shot']

        move(self.battle, split_msg)
        m = Move("String Shot")

        self.assertIn(m, self.battle.opponent.active.moves)
Beispiel #19
0
    def test_tackle_is_not_disabled_when_user_has_assaultvest(self):
        self.battler.active.moves.append(Move('tackle'))
        self.battler.active.item = 'assaultvest'

        self.battler.lock_moves()

        self.assertFalse(self.battler.active.get_move('tackle').disabled)
Beispiel #20
0
    def test_calmmind_gets_locked_when_user_has_assaultvest(self):
        self.battler.active.moves.append(Move('calmmind'))
        self.battler.active.item = 'assaultvest'

        self.battler.lock_moves()

        self.assertTrue(self.battler.active.get_move('calmmind').disabled)
Beispiel #21
0
    def test_add_revealed_move_does_not_add_move_twice(self):
        split_msg = ['', 'move', 'p2a: Caterpie', 'String Shot']

        self.battle.opponent.active.moves.append(Move("String Shot"))
        move(self.battle, split_msg)

        self.assertEqual(1, len(self.battle.opponent.active.moves))
Beispiel #22
0
    def test_taunt_locks_status_move(self):
        self.battler.active.moves.append(Move('calmmind'))
        self.battler.active.volatile_statuses.append("taunt")

        self.battler.lock_moves()

        self.assertTrue(self.battler.active.get_move('calmmind').disabled)
Beispiel #23
0
    def test_taunt_does_not_lock_physical_move(self):
        self.battler.active.moves.append(Move('tackle'))
        self.battler.active.volatile_statuses.append("taunt")

        self.battler.lock_moves()

        self.assertFalse(self.battler.active.get_move('tackle').disabled)
Beispiel #24
0
    def test_does_not_get_already_revealed_move_and_guesses_expected_moves(
            self):
        p = Pokemon('pikachu', 100)

        p.moves = [
            Move('tackle'),
            Move('stringshot'),
        ]
        moves = [('tackle', 95), ('splash', 85), ('stringshot', 40),
                 ('move4', 40)]

        moves = p.get_possible_moves(moves)

        expected_result = (['splash'], ['move4'])

        self.assertEqual(expected_result, moves)
Beispiel #25
0
    def test_chance_moves_are_not_guessed_if_known_plus_expected_equals_four(
            self):
        p = Pokemon('pikachu', 100)

        p.moves = [
            Move('tackle'),
            Move('splash'),
            Move('stringshot'),
        ]
        moves = [('move1', 95), ('move2', 40), ('move3', 40), ('move4', 40)]

        moves = p.get_possible_moves(moves)

        expected_result = (['move1'], [])

        self.assertEqual(expected_result, moves)
Beispiel #26
0
 def test_gets_only_set_available(self):
     self.get_sets_mock.return_value = {
         constants.SETS: {
             "grassknot|hiddenpowerice60|voltswitch|volttackle": 16,
             "grassknot|hiddenpowerice60|irontail|volttackle": 33
         }
     }
     expected_moves = [
         Move("irontail"),
         Move("grassknot"),
         Move("hiddenpowerice60"),
         Move("volttackle"),
     ]
     p = Pokemon('pikachu', 100)
     p.moves = [Move('irontail')]
     p.update_moves_for_random_battles()
     self.assertEqual(expected_moves, p.moves)
Beispiel #27
0
    def test_swordsdance_with_choiceband_does_not_make_sense(self):
        nature = 'jolly'
        spread = '0,0,0,252,4,252'
        item = 'choiceband'
        ability = 'intimidate'
        moves = [Move('swordsdance')]

        self.assertFalse(set_makes_sense(nature, spread, item, ability, moves))
Beispiel #28
0
 def test_gets_all_possible_moves_when_none_have_yet_been_revealed(self):
     self.get_sets_mock.return_value = {
         constants.SETS: {
             "grassknot|hiddenpowerice60|voltswitch|volttackle": 16,
             "grassknot|hiddenpowerice60|irontail|volttackle": 33
         }
     }
     expected_moves = [
         Move("grassknot"),
         Move("hiddenpowerice60"),
         Move("voltswitch"),
         Move("volttackle"),
         Move("irontail")
     ]
     p = Pokemon('pikachu', 100)
     p.moves = list()
     p.update_moves_for_random_battles()
     self.assertEqual(expected_moves, p.moves)
Beispiel #29
0
    def test_fakeout_is_not_disabled_when_the_last_used_move_was_a_switch(
            self):
        self.battler.active.moves.append(Move('fakeout'))
        self.battler.last_used_move = LastUsedMove(pokemon_name='caterpie',
                                                   move='switch',
                                                   turn=0)

        self.battler.lock_moves()

        self.assertFalse(self.battler.active.get_move('fakeout').disabled)
Beispiel #30
0
    def test_chance_moves_are_not_affected_by_known_moves(self):
        p = Pokemon('pikachu', 100)
        p.moves = [Move('tackle')]

        moves = [('move1', 95), ('move2', 40), ('move3', 40), ('move4', 40)]

        moves = p.get_possible_moves(moves)

        expected_result = (['move1'], ['move2', 'move3', 'move4'])

        self.assertEqual(expected_result, moves)