@@ -49,6 +49,7 @@ function testWinner(choice1, choice2) {
4949const boutonFeu = document . querySelector ( ".bouton-feu" ) ;
5050const boutonEau = document . querySelector ( ".bouton-eau" ) ;
5151const boutonTerre = document . querySelector ( ".bouton-terre" ) ;
52+ const boutonRejouer = document . querySelector ( ".bouton-rejouer" ) ;
5253
5354/* Recupere zone d'interractions */
5455
@@ -66,6 +67,10 @@ let partiesPerdues = 0;
6667
6768let computerChoice = powerPc ( ) ;
6869
70+ boutonRejouer . disabled = true ;
71+ interractions . textContent = "Choisissez un élément..." ;
72+
73+
6974function theWinnerIs ( userChoice ) {
7075 let str = `Ordinateur : ${ tabName [ computerChoice ] } \nVous : ${ tabName [ userChoice ] } \nResultat : ` ;
7176
@@ -83,7 +88,6 @@ function theWinnerIs(userChoice) {
8388 /* Update interraction section */
8489
8590 interractions . textContent = str ;
86- interractions . textContent += "\nEssayez encore..." ;
8791
8892 partiesJouer ++ ;
8993
@@ -92,7 +96,20 @@ function theWinnerIs(userChoice) {
9296 nombreGagnees . textContent = partiesGagnes . toString ( ) ;
9397 nombrePerdues . textContent = partiesPerdues . toString ( ) ;
9498
95- computerChoice = powerPc ( ) ;
99+ if ( ( partiesPerdues === 10 ) || ( partiesGagnes === 10 ) ) {
100+ boutonEau . disabled = true ;
101+ boutonFeu . disabled = true ;
102+ boutonTerre . disabled = true ;
103+ boutonRejouer . disabled = false ;
104+ if ( partiesGagnes === 10 )
105+ interractions . textContent += "\nVous aves gagné la manche."
106+ else
107+ interractions . textContent += "\nVous avez perdu la manche."
108+ }
109+ else {
110+ computerChoice = powerPc ( ) ;
111+ interractions . textContent += "\nEssayez encore..." ;
112+ }
96113}
97114
98115boutonFeu . addEventListener ( "click" , ( ) => {
@@ -108,4 +125,20 @@ boutonEau.addEventListener("click", () => {
108125boutonTerre . addEventListener ( "click" , ( ) => {
109126 // console.log("Terre clicked");
110127 theWinnerIs ( 2 ) ;
111- } ) ;
128+ } ) ;
129+
130+ boutonRejouer . addEventListener ( "click" , ( ) => {
131+ // console.log("Rejouer clicked");
132+ partiesJouer = 0 ;
133+ partiesGagnes = 0 ;
134+ partiesPerdues = 0 ;
135+
136+ computerChoice = powerPc ( ) ;
137+
138+ boutonEau . disabled = false ;
139+ boutonFeu . disabled = false ;
140+ boutonTerre . disabled = false ;
141+ boutonRejouer . disabled = true ;
142+
143+ interractions . textContent = "Choisissez un élément..." ;
144+ } )
0 commit comments