|
|
@ -4,25 +4,76 @@ |
|
|
|
<input type="text" id="name" required |
|
|
|
minlength="4" maxlength="8" size="10"> |
|
|
|
<button onclick="lancement()">lance le jeu</button> |
|
|
|
<p id="demo"></p> |
|
|
|
<script> |
|
|
|
var jeton_bac=1000; |
|
|
|
var jeton_joueur=99; |
|
|
|
let jeton_bac=1000; |
|
|
|
let jeton_joueur=99; |
|
|
|
|
|
|
|
function lancement() { |
|
|
|
var nb_jet = document.getElementById("name").value; |
|
|
|
if (jeton_joueur > nb_jet && jeton_bac > 500 && nb_jet < 100 && nb_jet> 0){document.write(11);nbAlea();} |
|
|
|
else{document.write("tu as mis trop de jetons");} |
|
|
|
let nb_jet = document.getElementById("name").value; |
|
|
|
if (jeton_joueur > nb_jet && jeton_bac > 500 && nb_jet < 100 && nb_jet> 0){ |
|
|
|
nbAlea(); |
|
|
|
} |
|
|
|
else{ |
|
|
|
document.getElementById("demo").innerHTML = "tu as mis trop de jetons"; |
|
|
|
return nb_jet |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function gain(x){ |
|
|
|
let nb_jet=lancement() |
|
|
|
let resultat=x |
|
|
|
let jeton_bac=jeton_bac |
|
|
|
let jeton_joueur=jeton_joueur |
|
|
|
if (resultat==1){ |
|
|
|
let jeton_joueur=jeton_joueur+jeton_joueur ; |
|
|
|
document.getElementById("demo").innerHTML = "vous avez",jeton_joueur,"jetons"; |
|
|
|
} |
|
|
|
</script> |
|
|
|
<script> |
|
|
|
else if (resultat==2){ |
|
|
|
let jeton_joueur=5*nb_jet ; |
|
|
|
document.getElementById("demo").innerHTML = "vous avez",jeton_joueur,"jetons"; |
|
|
|
let jeton_bac=jeton_bac-5*nb_jet; |
|
|
|
document.getElementById("demo").innerHTML = "vous avez",jeton_bac,"jetons"; |
|
|
|
return jeton_joueur; |
|
|
|
|
|
|
|
} |
|
|
|
else if (resultat==3){ |
|
|
|
let jeton_joueur=jeton_joueur-nb_jet ; |
|
|
|
document.getElementById("demo").innerHTML = "vous avez",jeton_joueur,"jetons"; |
|
|
|
let jeton_bac=jeton_bac+nb_jet; |
|
|
|
document.getElementById("demo").innerHTML = "il y a",jeton_bac,"jetons dans la machine"; |
|
|
|
return jeton_joueur; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function nbAlea(){ |
|
|
|
const cars = [Math.floor(Math.random() * 10) , |
|
|
|
Math.floor(Math.random() * 10) , |
|
|
|
Math.floor(Math.random() * 10) ]; |
|
|
|
return cars; |
|
|
|
} |
|
|
|
let cars = nbAlea(); |
|
|
|
window.alert(cars); |
|
|
|
if (cars[0] == 9 && cars[1] == 9 && cars[2] == 9){ |
|
|
|
document.getElementById("demo").innerHTML = "simon est gays"; |
|
|
|
gain(1); |
|
|
|
} |
|
|
|
else if (cars[0] == cars[1] && cars[0] == cars[2] ){ |
|
|
|
document.getElementById("demo").innerHTML = "bruno est gays"; |
|
|
|
gain(2); |
|
|
|
} |
|
|
|
else if (cars[1] == cars[0] && cars[1] == cars[2]){ |
|
|
|
document.getElementById("demo").innerHTML = "bruno est gays"; |
|
|
|
gain(2); |
|
|
|
} |
|
|
|
else if (cars[2] == cars[0] && cars[2] == cars[1]){ |
|
|
|
document.getElementById("demo").innerHTML = "bruno est gays"; |
|
|
|
gain(2); |
|
|
|
} |
|
|
|
else { |
|
|
|
document.getElementById("demo").innerHTML = "samuel est gays"; |
|
|
|
gain(3); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |
|
|
@ -30,4 +81,3 @@ window.alert(cars); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|