Actualiser js/data.js
This commit is contained in:
+9
-27
@@ -65,7 +65,6 @@ const playersData = {
|
||||
surfaceStats: { clay: { winRate: 0.81 }, hard: { winRate: 0.64 }, grass: { winRate: 0.52 } },
|
||||
recentForm: ["W", "L", "W", "L", "W"]
|
||||
},
|
||||
|
||||
// ---- SIMPLE DAMES ----
|
||||
"swiatek": {
|
||||
id: "swiatek",
|
||||
@@ -195,54 +194,45 @@ const tournamentMatches = [
|
||||
}
|
||||
];
|
||||
|
||||
function getPlayerObj(idOrObj) {
|
||||
if (typeof idOrObj === 'object' && idOrObj !== null) return idOrObj;
|
||||
return playersData[idOrObj] || null;
|
||||
}
|
||||
|
||||
// Algorithme de calcul de probabilités sans faille (basé sur la terre battue)
|
||||
function calculateWinProbability(p1Id, p2Id) {
|
||||
const p1 = playersData[p1Id];
|
||||
const p2 = playersData[p2Id];
|
||||
const p1 = getPlayerObj(p1Id);
|
||||
const p2 = getPlayerObj(p2Id);
|
||||
if (!p1 || !p2) return { player1: 50, player2: 50 };
|
||||
|
||||
let score1 = 50;
|
||||
let score2 = 50;
|
||||
|
||||
// Différence de classement
|
||||
const rankingDiff = p2.ranking - p1.ranking;
|
||||
score1 += rankingDiff * 1.5;
|
||||
score2 -= rankingDiff * 1.5;
|
||||
|
||||
// Performance spécifique Terre Battue (Roland Garros)
|
||||
const surfaceDiff = (p1.surfaceStats.clay.winRate - p2.surfaceStats.clay.winRate) * 100;
|
||||
score1 += surfaceDiff * 0.4;
|
||||
score2 -= surfaceDiff * 0.4;
|
||||
|
||||
// Normalisation stricte entre 15% et 85% pour éviter les bugs d'affichage à 100%
|
||||
let finalP1 = Math.round(score1);
|
||||
finalP1 = Math.max(15, Math.min(85, finalP1));
|
||||
let finalP2 = 100 - finalP1;
|
||||
|
||||
return { player1: finalP1, player2: finalP2 };
|
||||
}
|
||||
|
||||
// Générateur dynamique d'avantages/défauts croisés en fonction de l'opposant
|
||||
function getMatchupAnalysis(p1Id, p2Id) {
|
||||
const p1 = playersData[p1Id];
|
||||
const p2 = playersData[p2Id];
|
||||
|
||||
const p1 = getPlayerObj(p1Id);
|
||||
const p2 = getPlayerObj(p2Id);
|
||||
const analysis = {
|
||||
player1Advantages: [],
|
||||
player1Disadvantages: [],
|
||||
player2Advantages: [],
|
||||
player2Disadvantages: []
|
||||
};
|
||||
|
||||
if (!p1 || !p2) return analysis;
|
||||
|
||||
// Règle 1 : Avantage de la main opposée (Gaucher vs Droitier)
|
||||
if (p1.handedness === "Gaucher" && p2.handedness === "Droitier") {
|
||||
analysis.player1Advantages.push("Effet de service sortant de gaucher gênant le revers adverse");
|
||||
analysis.player2Disadvantages.push("Doit s'ajuster aux trajectoires spécifiques d'un gaucher");
|
||||
}
|
||||
|
||||
// Règle 2 : Avantage de la taille sur le service
|
||||
const h1 = parseFloat(p1.height);
|
||||
const h2 = parseFloat(p2.height);
|
||||
if (h1 > h2 + 0.05) {
|
||||
@@ -250,27 +240,19 @@ function getMatchupAnalysis(p1Id, p2Id) {
|
||||
} else if (h2 > h1 + 0.05) {
|
||||
analysis.player2Advantages.push("Avantage hauteur au service pour trouver des zones plongeantes");
|
||||
}
|
||||
|
||||
// Règle 3 : Exploitation des faiblesses déclarées
|
||||
p1.strengths.forEach(str => {
|
||||
if (p2.weaknesses.some(wk => wk.toLowerCase().includes("fond de court") || wk.toLowerCase().includes("revers"))) {
|
||||
analysis.player1Advantages.push(`Peut pilonner avec son [${str}]`);
|
||||
}
|
||||
});
|
||||
|
||||
p2.strengths.forEach(str => {
|
||||
if (p1.weaknesses.some(wk => wk.toLowerCase().includes("fond de court") || wk.toLowerCase().includes("revers"))) {
|
||||
analysis.player2Advantages.push(`Peut pilonner avec son [${str}]`);
|
||||
}
|
||||
});
|
||||
|
||||
// Fallbacks par défaut si aucun avantage croisé n'est trouvé
|
||||
if (analysis.player1Advantages.length === 0) analysis.player1Advantages.push("Excellente couverture de terrain sur brique pilée");
|
||||
if (analysis.player2Advantages.length === 0) analysis.player2Advantages.push("Puissance de fond de court régulière");
|
||||
|
||||
// Remplissage automatique des défauts de manière symétrique
|
||||
analysis.player1Disadvantages = p1.weaknesses;
|
||||
analysis.player2Disadvantages = p2.weaknesses;
|
||||
|
||||
return analysis;
|
||||
}
|
||||
Reference in New Issue
Block a user