def flying_press_matchups(move): """Figure out Flying Press's type matchups.""" matchups = empty_matchup_dict() fighting = move.type flying = db.DBSession.query(db.Type).filter_by(identifier='flying').one() zipped_matchups = zip(fighting.attacking_matchups, flying.attacking_matchups) for matchup_pair in zipped_matchups: # Go through both matchups for each defending type result_n = 0 for matchup in matchup_pair: result = matchup.result.identifier if result == 'super-effective': result_n += 1 elif result == 'not-very-effective': result_n -= 1 elif result == 'ineffective': matchups['ineffective'].append(matchup.defending_type) break # No type is weak or resistant to both Flying and Fighting, so we don't # have to worry about that, thankfully. if result_n == 1: matchups['super-effective'].append(matchup.defending_type) elif result_n == -1: matchups['not-very-effective'].append(matchup.defending_type) return matchups
def type_matchups(move): """Figure out a move's type matchups.""" # Figure out special cases if move.damage_class.identifier == 'non-damaging': return None elif move.identifier == 'flying-press': return flying_press_matchups(move) elif any(cat.identifier == 'exact-damage' for cat in move.categories): return specific_damage_matchups(move) # Go through and group the matchups matchups = empty_matchup_dict() for matchup in move.type.attacking_matchups: result = matchup.result.identifier type_ = matchup.defending_type if move.identifier == 'freeze-dry' and type_.identifier == 'water': # Deal with Freeze-Dry matchups['super-effective'].append(type_) elif result != 'neutral': # Ignore neutral matchups matchups[result].append(type_) return matchups