import type { PokemonData } from '../types/pokemon';
export const calculateMatchupRating = (counter: PokemonData, target: PokemonData): number => {
let rating = 50;
if (counter.types.some((type: string) => target.typeEffectiveness?.weakTo?.includes(type))) {
rating += 25;
}
if (target.types.every((type: string) => counter.typeEffectiveness?.resistantTo?.includes(type))) {
rating += 15;
}
if (target.types.some((type: string) => counter.typeEffectiveness?.immuneTo?.includes(type))) {
rating += 20;
}
if (counter.stats.speed > target.stats.speed) {
rating += 10;
}
const tierValues: Record<string, number> = { 'OU': 4, 'UU': 3, 'RU': 2, 'NU': 1, 'LC': 0 };
const counterTier = tierValues[counter.competitiveTier || ''] || 1;
const targetTier = tierValues[target.competitiveTier || ''] || 1;
if (counterTier > targetTier) {
rating += 5;
}
return Math.min(Math.max(rating, 20), 98);
};
export const generateReasoning = (counter: PokemonData, target: PokemonData): string => {
const reasons = [];
if (counter.types.some((type: string) => target.typeEffectiveness?.weakTo?.includes(type))) {
const effectiveTypes = counter.types.filter((type: string) => target.typeEffectiveness?.weakTo?.includes(type));
reasons.push(`${effectiveTypes.join('/')} moves are super effective against ${target.name}`);
}
if (target.types.some((type: string) => counter.typeEffectiveness?.immuneTo?.includes(type))) {
reasons.push(`Immune to ${target.name}'s ${target.types.join('/')} attacks`);
}
if (counter.stats.speed > target.stats.speed) {
reasons.push(`Outspeeds ${target.name} (${counter.stats.speed} vs ${target.stats.speed})`);
}
if (counter.stats.total > target.stats.total) {
reasons.push(`Higher overall stats (${counter.stats.total} vs ${target.stats.total})`);
}
return reasons.length > 0 ? reasons.join('. ') + '.' : `Good matchup against ${target.name} based on type effectiveness and stats.`;
};
export const getTypeColor = (type: string): string => {
const colors: Record<string, string> = {
Fire: 'bg-red-500', Water: 'bg-blue-500', Electric: 'bg-yellow-500',
Grass: 'bg-green-500', Rock: 'bg-gray-600', Flying: 'bg-indigo-400',
Ice: 'bg-cyan-400', Normal: 'bg-gray-400', Fighting: 'bg-red-700',
Poison: 'bg-purple-500', Ground: 'bg-yellow-700', Psychic: 'bg-pink-500',
Bug: 'bg-green-600', Ghost: 'bg-purple-700', Dragon: 'bg-indigo-700',
Dark: 'bg-gray-800', Steel: 'bg-gray-500', Fairy: 'bg-pink-300'
};
return colors[type] || 'bg-gray-400';
};
export const getRatingColor = (rating: number): string => {
if (rating >= 85) return 'text-green-600 bg-green-100';
if (rating >= 70) return 'text-yellow-600 bg-yellow-100';
return 'text-red-600 bg-red-100';
};