Skip to content
Snippets Groups Projects
Commit 257052ad authored by Massies Alexandre's avatar Massies Alexandre
Browse files

derniers détails

parent a05a4669
Branches
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ Window {
property var case_focus: null
property int current_essai: 0
property int indice_case: 0
property bool statsUpdated: false
property string mot: ""
property var mot_split: []
......@@ -44,7 +45,11 @@ Window {
function refreshStatsDisplay() {
var globalStats = motusGame.getGlobalStats("Combined");
partiesJouees.text = "Parties jouées : " + globalStats.totalGames;
victoires.text = "Victoires : " + globalStats.totalWins;
var globalWinPercentage = 0;
if (globalStats.totalGames > 0) {
globalWinPercentage = Math.round((globalStats.totalWins / globalStats.totalGames) * 100);
}
victoires.text = "Taux de réussite : " + globalWinPercentage + "%";
winStreakActuel.text = "Win Streak Actuel : " + globalStats.currentWinStreak;
meilleurStreak.text = "Meilleur Streak : " + globalStats.bestWinStreak;
......@@ -52,7 +57,11 @@ Window {
tempsMoyen.text = "Temps moyen : " + localStats.averageTime + " sec";
meilleurTemps.text = "Meilleur temps : " + localStats.bestTime + " sec";
partiesJoueesLocal.text = "Parties jouées : " + localStats.gamesPlayed;
partiesGagnees.text = "Parties gagnées : " + localStats.gamesWon;
var localWinPercentage = 0;
if (localStats.gamesPlayed > 0) {
localWinPercentage = Math.round((localStats.gamesWon / localStats.gamesPlayed) * 100);
}
partiesGagnees.text = "Taux de réussite : " + localWinPercentage + "%";
winStreakActuelLocal.text = "Win Streak Actuel : " + localStats.currentWinStreak;
meilleurStreakLocal.text = "Meilleur Streak : " + localStats.bestWinStreak;
// Mise à jour de l'histogramme via la nouvelle propriété "histData"
......@@ -61,6 +70,10 @@ Window {
// Fonction de mise à jour des statistiques à la fin d'une partie
function updateGameStats() {
if (statsUpdated)
return;
statsUpdated = true; // On indique qu'on a déjà mis à jour les stats.
var lang = (motusGame.dictionnaryChoosed.indexOf("francais") >= 0) ? "French" : "English";
var letterCount = nb_lettres;
var won = motusGame.win;
......@@ -207,7 +220,6 @@ Window {
Rectangle {
width: 20
height: histogramRow.maxValue > 0 ? Math.max(10, Math.round((histogramRow.histData[index] / histogramRow.maxValue) * 200)) : 10
// Vous pouvez personnaliser la couleur en fonction de l'index si besoin
color: "#4a4a4a"
border.width: 1
border.color: "white"
......@@ -358,6 +370,7 @@ Window {
cursorShape: Qt.PointingHandCursor
enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut)
onClicked: {
statsUpdated = false;
current_essai = 0;
indice_case = 0;
// Réinitialisation de la grille et des touches
......@@ -376,6 +389,12 @@ Window {
motusGame.setLoosetimebool(false);
motusGame.setLooseabandonbool(false);
motusGame.setWinbool(false);
// Système d'adaptation du chrono :
// Ici, on définit par exemple 10 secondes de temps par lettre.
var baseTimePerLetter = 10;
motusGame.duree_timer = nb_lettres * baseTimePerLetter;
motusGame.startTimer();
mot_split = mot.split("");
}
......@@ -426,8 +445,8 @@ Window {
choosebutton._textText = "Générer un mot";
text_langue.text = "Langage";
text_choix_nb_lettres.text = "Nombre de lettres";
text_stats.text = "Statistiques"
text_abandon.text = "Abandonner"
text_stats.text = "Statistiques";
text_abandon.text = "Abandonner";
numberLetterBtn.firstItemText = "5";
}
}
......@@ -449,8 +468,8 @@ Window {
choosebutton._textText = "Generate a word";
text_langue.text = "Language";
text_choix_nb_lettres.text = "Number of letters";
text_stats.text = "Statistics"
text_abandon.text = "Abandon"
text_stats.text = "Statistics";
text_abandon.text = "Abandon";
numberLetterBtn.firstItemText = "5";
}
}
......@@ -548,7 +567,6 @@ Window {
onCurrentIndexChanged: {
nb_lettres = parseInt(model[currentIndex]);
//console.log("nb_lettres =", nb_lettres);
// Mettre à jour nb_essais en fonction de nb_lettres
if (nb_lettres == 4)
nb_essais = 5;
......@@ -559,7 +577,6 @@ Window {
else
nb_essais = 8;
caseRepeater.model = nb_lettres * nb_essais;
//console.log("Grille de", caseRepeater.model, "cases");
caseArray = [];
for (var i = 0; i < caseRepeater.count; i++) {
caseArray.push(caseRepeater.itemAt(i));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment