sacha.serny 3 years ago
parent
commit
8f3476d58a
  1. 18
      app.js
  2. 3
      index.html

18
app.js

@ -19,18 +19,25 @@ function nbAlea() {
}
function gain(tirage) {
player_coins = player_coins - mise
machine_coins = machine_coins + mise
if (tirage == [9,9,9]) {
player_coins = player_coins + machine_coins
machine_coins = 0
} else if (tirage[0] == tirage[1] && tirage[1]== tirage[2]) {
console.log("E")
player_coins = player_coins + 6*mise
machine_coins = machine_coins - 6*mise
} else if (tirage[0] == tirage[1] || tirage[1] == tirage[2] || tirage[0] == tirage[2]) {
console.log("K")
player_coins = player_coins + 2*mise
machine_coins = machine_coins - 2*mise
} else {
console.log("Perdu")
}
}
function update_stats() {
document.getElementById('machine_coins').innerText = machine_coins
document.getElementById('player_coins').innerText = player_coins
}
/*
var button = document.createElement("BUTTON");
var button_1 = document.createTextNode("CLICK ME");
@ -44,10 +51,11 @@ var player_coins = 100
function jeu() {
if (player_coins > 0) {
userinput = document.getElementById("mise").value // a dev
console.log(userinput)
var mise = document.getElementById("mise").value // a dev
console.log(mise)
var tirage = [nbAlea(), nbAlea(), nbAlea()]
console.log(tirage)
gain(tirage)
update_stats()
}
}

3
index.html

@ -12,6 +12,9 @@
<input type="text" id="mise">
<input onclick="jeu()" type="button" value="Submit" id="valider">
</form>
<h5 id="machine_coins"></h5>
<h5 id="player_coins"></h5>
<script src="app.js"></script>
</body>
</html>
Loading…
Cancel
Save