示例#1
0
 def test_normalize_name(self):
     self.assertEqual(normalize_name('p2a: Galvantula'), 'galvantula')
     self.assertEqual(normalize_name('Thundurus-Therian'), 'thundurustherian')
     self.assertEqual(normalize_name('Bug Buzz'), 'bugbuzz')
     self.assertEqual(normalize_name("Farfetch'd"), 'farfetchd')
     self.assertEqual(normalize_name("Mr. Mime"), 'mrmime')
     self.assertEqual(normalize_name('ability: Slow Start'), 'slowstart')
     self.assertEqual(normalize_name('move: Taunt'), 'taunt')
     self.assertEqual(normalize_name('[from] item: Life Orb'), 'lifeorb')
     self.assertEqual(normalize_name('[from] Protean'), 'protean')
示例#2
0
文件: miner.py 项目: sobolews/BillsPC
    def sample(self, pokemon, mega=False, level=False, primal=False):
        """
        Add the data from this pokemon to self.counter.
        `pokemon` is one of the 6 JSON dict members of Scripts.randomTeam()

        Megas are counted twice: once towards the statistics of the base forme, and once towards a
        separate entry for the mega forme.

        The pokemon are also indexed by level, such that stats for slurpuffL77 are separate from
        stats for slurpuffL79. The stats for "slurpuff" are the union of these.
        """
        name = pokedex[pokemon['species']].name
        if level:
            name = "%sL%d" % (name, pokemon['level'])
        item = pokemon['item']

        if (((item.endswith('ite') and item != 'Eviolite')
             or item.endswith('ite X') or item.endswith('ite Y'))
            and not mega and not level
        ):
            forme = 0 if not item.endswith('Y') else 1
            megapokemon = deepcopy(pokemon)
            megapokemon['species'] = megapokemon['name'] = str(
                pokedex[pokemon['name']].mega_formes[forme])
            self.sample(megapokemon, mega=True)

        if item in ('Red Orb', 'Blue Orb') and not primal and not level:
            primalpokemon = deepcopy(pokemon)
            primalpokemon['species'] = primalpokemon['name'] = pokemon['species'] + '-Primal'
            self.sample(primalpokemon, primal=True)

        if name not in self.counter:
            self.counter[name] = self.new_entry()

        pokemon['moves'] = [normalize_name(str(move)) for move in pokemon['moves']]
        pokemon['ability'] = normalize_name(str(pokemon['ability']))
        pokemon['item'] = normalize_name(str(pokemon['item']))

        self.counter[name]['number'] += 1
        for move in pokemon['moves']:
            self.counter[name]['moves'][move] += 1
        self.counter[name]['ability'][pokemon['ability']] += 1
        self.counter[name]['item'][pokemon['item']] += 1
        self.counter[name]['level'][pokemon['level']] += 1
        self.counter[name]['sets'][tuple(sorted(pokemon['moves']) +
                                                    [pokemon['ability'],
                                                     pokemon['item']])] += 1

        if not level:
            self.sample(pokemon, level=True)
示例#3
0
 def test_all_items_in_randbatsstatistics_are_implemented(self):
     unimplemented_items = [item for item in rbstats.item_index if normalize_name(item) not in itemdex]
     self.assertListEqual(unimplemented_items, [])