def get_item_renames_map(self): renames_map = {} for old_name, new_name in self.read_item_renames(): renames_map[slugify(old_name)] = slugify(new_name) return renames_map
def read_pbr_moveset(self, filename): with self.read_csv(filename) as reader: for index, row in enumerate(reader): if index == 0: continue ( gender, number, name, move_a, move_b, move_c, move_d, ability, item, hp, attack, defense, special_attack, special_defense, speed, ) = row if number in NUMBER_NAME_REWRITE_MAP: name = NUMBER_NAME_REWRITE_MAP[number] number = int(re.match(r'(\d+)', number).group(1)) hp = int(hp) attack = int(attack) defense = int(defense) special_attack = int(special_attack) special_defense = int(special_defense) speed = int(speed) moves = [] for move in [move_a, move_b, move_c, move_d]: if move: moves.append(slugify(move)) doc = { 'gender': gender, 'name': rewrite_name(name), 'slug': slugify(rewrite_name(name)), 'number': number, 'moves': moves, 'hp': hp, 'attack': attack, 'defense': defense, 'special_attack': special_attack, 'special_defense': special_defense, 'speed': speed, 'ability': slugify(ability), 'item': slugify(item), } yield doc
def get_accuracy_map(self): accuracy_map = {} for row in self.read_accuracy_changes(): move_slug = slugify(row[0]) accuracy = row[1] or row[2] if accuracy: accuracy_map[move_slug] = accuracy for row in self.read_accuracy_overrides(): move_slug = slugify(row[0]) accuracy_map[move_slug] = row[1] return accuracy_map
def get_power_map(self): power_map = {} for row in self.read_power_changes(): move_slug = slugify(row[0]) power = row[1] or row[2] if power: power_map[move_slug] = power return power_map
def get_accuracy_map(self): accuracy_map = {} for row in self.read_accuracy_changes(): move_slug = slugify(row[0]) accuracy = row[1] or row[2] if accuracy: accuracy_map[move_slug] = accuracy return accuracy_map
def read_pbr_moveset(self, filename): with self.read_csv(filename) as reader: for index, row in enumerate(reader): if index == 0: continue (name, number, item, ability, move_a, move_b, move_c, move_d, nature, iv, hp, attack, defense, special_attack, special_defense, speed, *dummy) = row if not name.strip(): continue name = rewrite_pokemon_name(name) number = int(number) iv = int(number) hp = int(hp) attack = int(attack) defense = int(defense) special_attack = int(special_attack) special_defense = int(special_defense) speed = int(speed) happiness = None if item == '--': item = '' moves = [] for move in [move_a, move_b, move_c, move_d]: if move and move != '--': happiness_match = re.search(r' \((\d+|max)\)', move) if happiness_match: happiness = happiness_match.group(1) if happiness == 'max': # Max as in max frustration pp, not happiness happiness = 0 else: happiness = int(happiness) moves.append(slugify(move)) doc = { 'name': name, 'slug': slugify(name), 'number': number, 'ability': slugify(ability), 'moves': moves, 'iv': iv, 'hp': hp, 'attack': attack, 'defense': defense, 'special_attack': special_attack, 'special_defense': special_defense, 'speed': speed, 'nature': slugify(nature), 'item': slugify(item), 'happiness': happiness, } move_type_override_match = re.search(r'HP (\w+)', move_a) if move_type_override_match: doc['move_type_override'] = slugify( move_type_override_match.group(1)) yield doc
def read_pbr_moveset(self, filename): with self.read_csv(filename) as reader: for index, row in enumerate(reader): if index == 0: continue ( name, number, item, ability, move_a, move_b, move_c, move_d, nature, iv, hp, attack, defense, special_attack, special_defense, speed, *dummy ) = row if not name.strip(): continue name = rewrite_pokemon_name(name) number = int(number) iv = int(number) hp = int(hp) attack = int(attack) defense = int(defense) special_attack = int(special_attack) special_defense = int(special_defense) speed = int(speed) happiness = None if item == '--': item = '' moves = [] for move in [move_a, move_b, move_c, move_d]: if move and move != '--': happiness_match = re.search(r' \((\d+|max)\)', move) if happiness_match: happiness = happiness_match.group(1) if happiness == 'max': # Max as in max frustration pp, not happiness happiness = 0 else: happiness = int(happiness) moves.append(slugify(move)) doc = { 'name': name, 'slug': slugify(name), 'number': number, 'ability': slugify(ability), 'moves': moves, 'iv': iv, 'hp': hp, 'attack': attack, 'defense': defense, 'special_attack': special_attack, 'special_defense': special_defense, 'speed': speed, 'nature': slugify(nature), 'item': slugify(item), 'happiness': happiness, } move_type_override_match = re.search(r'HP (\w+)', move_a) if move_type_override_match: doc['move_type_override'] = slugify(move_type_override_match.group(1)) yield doc