Skip to content

Commit

Permalink
Try to code the function sayAComment (only the "est en tête") + added…
Browse files Browse the repository at this point in the history
… the "hidden" class to the results winner -> it will depend on the result (of course)
  • Loading branch information
stellapln committed Dec 31, 2017
1 parent f972221 commit e370102
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ <h3 id="game-commentary">La course va bientôt commencer...</h3>
<!--<span id="result-player1-name">Player1</span>
<span id="result-player1-score">bois 1000</span>-->
<!--to active with the value of the winner-->
<h4 class="winner" id"spade"> Le Poulain qui a gagné est le <span class="horseWinner">Pique</span> ! </h4>
<h4 class="winner" id="diamond"> Le Poulain qui a gagné est le <span class="horseWinner">Carreau</span> ! </h4>
<h4 class="winner" id="heart"> Le Poulain qui a gagné est le <span class="horseWinner">Coeur</span> ! </h4>
<h4 class="winner" id="clover"> Le Poulain qui a gagné est le <span class="horseWinner">Trèfle</span> ! </h4>
<h4 class="winner hidden" id"spade"> Le Poulain qui a gagné est le <span class="horseWinner">Pique</span> ! </h4>
<h4 class="winner hidden" id="diamond"> Le Poulain qui a gagné est le <span class="horseWinner">Carreau</span> ! </h4>
<h4 class="winner hidden" id="heart"> Le Poulain qui a gagné est le <span class="horseWinner">Coeur</span> ! </h4>
<h4 class="winner hidden" id="clover"> Le Poulain qui a gagné est le <span class="horseWinner">Trèfle</span> ! </h4>

<!--the display will depend on the number of players-->

Expand Down
31 changes: 26 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var raceInfos = {
var prevRaceInfos = {};
Object.assign(prevRaceInfos,raceInfos); //copy
//infos du tour précedent,
//pour comparer et faire des comentaires
//pour comparer et faire des commentaires

var gameCommentary = document.querySelector('#game-commentary');

Expand Down Expand Up @@ -425,7 +425,7 @@ function nextTurn () {

/*
- print comment
- check if someone won th race
- check if someone won the race
*/

}
Expand All @@ -440,11 +440,30 @@ function checkIfRaceIsOver () {

function SayAComment() {

var maxPosition;

for (i=4 ; i>=0 ; i--) {
for (j=0 ; j<4 ; j++) {
if (aces[j].position == i) {
gameCommentary.innerHTML = "Le poulain de la piste N° " + (raceInfos.firstId+1) + " est en tête !";
maxPosition = aces[j].position;
console.log('maxposition:' + maxPosition);
}
// for (k=0 ; k<4 ; k++) { // j'ai bugué LOL ça marche po
// if (k!=j) {
// if (aces[k].position == maxPosition) {
// console.log("k:" + k);
// gameCommentary.innerHTML += " Le poulain de la piste N° " + (k+1) + " rattrape le premier !";
// }
// }
// }
}
}
}


function moveAceBkw() {
//checks wich Ace needs to move bkw & moves it
//checks which Ace needs to move bkw & moves it
for (i=0; i<4; i++) {
if (sideTrackDeck[raceInfos.nextSideCard].suit == aces[i].suit) {

Expand Down Expand Up @@ -558,7 +577,7 @@ function coolDownNextTurn() {

function endRace() {
console.log ("WIIIIIIIIN");
gameCommentary.innerHTML = "Et c'est le cheval de la piste N° " + (raceInfos.firstId+1) + " qui remporte la victoire !";
gameCommentary.innerHTML = "Et c'est le poulain de la piste N° " + (raceInfos.firstId+1) + " qui remporte la victoire !";
}

function seeResults() {
Expand All @@ -574,7 +593,9 @@ function seeResults() {
resultsScreenSelector.classList.remove("hidden");
}, 200);
resultsScreenSelector.classList.add("enter-screen-right");
console.log("porrrrr");

var winner = raceInfos.firstId
//console.log("porrrrr");

}

Expand Down

0 comments on commit e370102

Please sign in to comment.