// MFL overall rating: a player's overall at a given position. // Outfield positions: weighted sum of the six outfield stats, rounded to the nearest integer. // Goalkeepers: the goalkeeping stat. // Source of truth: mfl-player-progression (OverallCoeffsConfig, computeCurrentOverallFromStat). export type Position = | 'GK' | 'RB' | 'LB' | 'RWB' | 'LWB' | 'CB' | 'CDM' | 'CM' | 'RM' | 'LM' | 'CAM' | 'RW' | 'LW' | 'CF' | 'ST' export type OutfieldPosition = Exclude export interface PlayerStats { pace: number shooting: number passing: number dribbling: number defense: number physical: number goalkeeping: number } export type OutfieldStat = Exclude export const OVERALL_COEFFS: Record> = { RB: { passing: 0.19, shooting: 0, defense: 0.44, dribbling: 0.17, pace: 0.1, physical: 0.1 }, LB: { passing: 0.19, shooting: 0, defense: 0.44, dribbling: 0.17, pace: 0.1, physical: 0.1 }, RWB: { passing: 0.19, shooting: 0, defense: 0.44, dribbling: 0.17, pace: 0.1, physical: 0.1 }, LWB: { passing: 0.19, shooting: 0, defense: 0.44, dribbling: 0.17, pace: 0.1, physical: 0.1 }, CB: { passing: 0.05, shooting: 0, defense: 0.64, dribbling: 0.09, pace: 0.02, physical: 0.2 }, CDM: { passing: 0.28, shooting: 0, defense: 0.4, dribbling: 0.17, pace: 0, physical: 0.15 }, CM: { passing: 0.43, shooting: 0.12, defense: 0.1, dribbling: 0.29, pace: 0, physical: 0.06 }, RM: { passing: 0.43, shooting: 0.12, defense: 0.1, dribbling: 0.29, pace: 0, physical: 0.06 }, LM: { passing: 0.43, shooting: 0.12, defense: 0.1, dribbling: 0.29, pace: 0, physical: 0.06 }, CAM: { passing: 0.34, shooting: 0.21, defense: 0, dribbling: 0.38, pace: 0.07, physical: 0 }, RW: { passing: 0.24, shooting: 0.23, defense: 0, dribbling: 0.4, pace: 0.13, physical: 0 }, LW: { passing: 0.24, shooting: 0.23, defense: 0, dribbling: 0.4, pace: 0.13, physical: 0 }, CF: { passing: 0.24, shooting: 0.23, defense: 0, dribbling: 0.4, pace: 0.13, physical: 0 }, ST: { passing: 0.1, shooting: 0.46, defense: 0, dribbling: 0.29, pace: 0.1, physical: 0.05 }, } export function computeOverall(position: Position, stats: PlayerStats): number { if (position === 'GK') return stats.goalkeeping const c = OVERALL_COEFFS[position] return Math.round( stats.pace * c.pace + stats.defense * c.defense + stats.shooting * c.shooting + stats.passing * c.passing + stats.physical * c.physical + stats.dribbling * c.dribbling, ) }