Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Momomotus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pouchet Pierre
Momomotus
Commits
257052ad
Commit
257052ad
authored
1 month ago
by
Massies Alexandre
Browse files
Options
Downloads
Patches
Plain Diff
derniers détails
parent
a05a4669
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Motus/Main.qml
+26
-9
26 additions, 9 deletions
Motus/Main.qml
with
26 additions
and
9 deletions
Motus/Main.qml
+
26
−
9
View file @
257052ad
...
@@ -18,6 +18,7 @@ Window {
...
@@ -18,6 +18,7 @@ Window {
property
var
case_focus
:
null
property
var
case_focus
:
null
property
int
current_essai
:
0
property
int
current_essai
:
0
property
int
indice_case
:
0
property
int
indice_case
:
0
property
bool
statsUpdated
:
false
property
string
mot
:
""
property
string
mot
:
""
property
var
mot_split
:
[]
property
var
mot_split
:
[]
...
@@ -44,7 +45,11 @@ Window {
...
@@ -44,7 +45,11 @@ Window {
function
refreshStatsDisplay
()
{
function
refreshStatsDisplay
()
{
var
globalStats
=
motusGame
.
getGlobalStats
(
"
Combined
"
);
var
globalStats
=
motusGame
.
getGlobalStats
(
"
Combined
"
);
partiesJouees
.
text
=
"
Parties jouées :
"
+
globalStats
.
totalGames
;
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
;
winStreakActuel
.
text
=
"
Win Streak Actuel :
"
+
globalStats
.
currentWinStreak
;
meilleurStreak
.
text
=
"
Meilleur Streak :
"
+
globalStats
.
bestWinStreak
;
meilleurStreak
.
text
=
"
Meilleur Streak :
"
+
globalStats
.
bestWinStreak
;
...
@@ -52,7 +57,11 @@ Window {
...
@@ -52,7 +57,11 @@ Window {
tempsMoyen
.
text
=
"
Temps moyen :
"
+
localStats
.
averageTime
+
"
sec
"
;
tempsMoyen
.
text
=
"
Temps moyen :
"
+
localStats
.
averageTime
+
"
sec
"
;
meilleurTemps
.
text
=
"
Meilleur temps :
"
+
localStats
.
bestTime
+
"
sec
"
;
meilleurTemps
.
text
=
"
Meilleur temps :
"
+
localStats
.
bestTime
+
"
sec
"
;
partiesJoueesLocal
.
text
=
"
Parties jouées :
"
+
localStats
.
gamesPlayed
;
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
;
winStreakActuelLocal
.
text
=
"
Win Streak Actuel :
"
+
localStats
.
currentWinStreak
;
meilleurStreakLocal
.
text
=
"
Meilleur Streak :
"
+
localStats
.
bestWinStreak
;
meilleurStreakLocal
.
text
=
"
Meilleur Streak :
"
+
localStats
.
bestWinStreak
;
// Mise à jour de l'histogramme via la nouvelle propriété "histData"
// Mise à jour de l'histogramme via la nouvelle propriété "histData"
...
@@ -61,6 +70,10 @@ Window {
...
@@ -61,6 +70,10 @@ Window {
// Fonction de mise à jour des statistiques à la fin d'une partie
// Fonction de mise à jour des statistiques à la fin d'une partie
function
updateGameStats
()
{
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
lang
=
(
motusGame
.
dictionnaryChoosed
.
indexOf
(
"
francais
"
)
>=
0
)
?
"
French
"
:
"
English
"
;
var
letterCount
=
nb_lettres
;
var
letterCount
=
nb_lettres
;
var
won
=
motusGame
.
win
;
var
won
=
motusGame
.
win
;
...
@@ -207,7 +220,6 @@ Window {
...
@@ -207,7 +220,6 @@ Window {
Rectangle
{
Rectangle
{
width
:
20
width
:
20
height
:
histogramRow
.
maxValue
>
0
?
Math
.
max
(
10
,
Math
.
round
((
histogramRow
.
histData
[
index
]
/
histogramRow
.
maxValue
)
*
200
))
:
10
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
"
color
:
"
#4a4a4a
"
border.width
:
1
border.width
:
1
border.color
:
"
white
"
border.color
:
"
white
"
...
@@ -358,6 +370,7 @@ Window {
...
@@ -358,6 +370,7 @@ Window {
cursorShape
:
Qt
.
PointingHandCursor
cursorShape
:
Qt
.
PointingHandCursor
enabled
:
motusGame
&&
(
motusGame
.
win
||
motusGame
.
loosetry
||
motusGame
.
looseabandon
||
motusGame
.
loosetime
||
!
motusGame
.
debut
)
enabled
:
motusGame
&&
(
motusGame
.
win
||
motusGame
.
loosetry
||
motusGame
.
looseabandon
||
motusGame
.
loosetime
||
!
motusGame
.
debut
)
onClicked
:
{
onClicked
:
{
statsUpdated
=
false
;
current_essai
=
0
;
current_essai
=
0
;
indice_case
=
0
;
indice_case
=
0
;
// Réinitialisation de la grille et des touches
// Réinitialisation de la grille et des touches
...
@@ -376,6 +389,12 @@ Window {
...
@@ -376,6 +389,12 @@ Window {
motusGame
.
setLoosetimebool
(
false
);
motusGame
.
setLoosetimebool
(
false
);
motusGame
.
setLooseabandonbool
(
false
);
motusGame
.
setLooseabandonbool
(
false
);
motusGame
.
setWinbool
(
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
();
motusGame
.
startTimer
();
mot_split
=
mot
.
split
(
""
);
mot_split
=
mot
.
split
(
""
);
}
}
...
@@ -426,8 +445,8 @@ Window {
...
@@ -426,8 +445,8 @@ Window {
choosebutton
.
_textText
=
"
Générer un mot
"
;
choosebutton
.
_textText
=
"
Générer un mot
"
;
text_langue
.
text
=
"
Langage
"
;
text_langue
.
text
=
"
Langage
"
;
text_choix_nb_lettres
.
text
=
"
Nombre de lettres
"
;
text_choix_nb_lettres
.
text
=
"
Nombre de lettres
"
;
text_stats
.
text
=
"
Statistiques
"
text_stats
.
text
=
"
Statistiques
"
;
text_abandon
.
text
=
"
Abandonner
"
text_abandon
.
text
=
"
Abandonner
"
;
numberLetterBtn
.
firstItemText
=
"
5
"
;
numberLetterBtn
.
firstItemText
=
"
5
"
;
}
}
}
}
...
@@ -449,8 +468,8 @@ Window {
...
@@ -449,8 +468,8 @@ Window {
choosebutton
.
_textText
=
"
Generate a word
"
;
choosebutton
.
_textText
=
"
Generate a word
"
;
text_langue
.
text
=
"
Language
"
;
text_langue
.
text
=
"
Language
"
;
text_choix_nb_lettres
.
text
=
"
Number of letters
"
;
text_choix_nb_lettres
.
text
=
"
Number of letters
"
;
text_stats
.
text
=
"
Statistics
"
text_stats
.
text
=
"
Statistics
"
;
text_abandon
.
text
=
"
Abandon
"
text_abandon
.
text
=
"
Abandon
"
;
numberLetterBtn
.
firstItemText
=
"
5
"
;
numberLetterBtn
.
firstItemText
=
"
5
"
;
}
}
}
}
...
@@ -548,7 +567,6 @@ Window {
...
@@ -548,7 +567,6 @@ Window {
onCurrentIndexChanged
:
{
onCurrentIndexChanged
:
{
nb_lettres
=
parseInt
(
model
[
currentIndex
]);
nb_lettres
=
parseInt
(
model
[
currentIndex
]);
//console.log("nb_lettres =", nb_lettres);
// Mettre à jour nb_essais en fonction de nb_lettres
// Mettre à jour nb_essais en fonction de nb_lettres
if
(
nb_lettres
==
4
)
if
(
nb_lettres
==
4
)
nb_essais
=
5
;
nb_essais
=
5
;
...
@@ -559,7 +577,6 @@ Window {
...
@@ -559,7 +577,6 @@ Window {
else
else
nb_essais
=
8
;
nb_essais
=
8
;
caseRepeater
.
model
=
nb_lettres
*
nb_essais
;
caseRepeater
.
model
=
nb_lettres
*
nb_essais
;
//console.log("Grille de", caseRepeater.model, "cases");
caseArray
=
[];
caseArray
=
[];
for
(
var
i
=
0
;
i
<
caseRepeater
.
count
;
i
++
)
{
for
(
var
i
=
0
;
i
<
caseRepeater
.
count
;
i
++
)
{
caseArray
.
push
(
caseRepeater
.
itemAt
(
i
));
caseArray
.
push
(
caseRepeater
.
itemAt
(
i
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment