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) { function gain(tirage) {
player_coins = player_coins - mise
machine_coins = machine_coins + mise
if (tirage == [9,9,9]) { if (tirage == [9,9,9]) {
player_coins = player_coins + machine_coins player_coins = player_coins + machine_coins
machine_coins = 0 machine_coins = 0
} else if (tirage[0] == tirage[1] && tirage[1]== tirage[2]) { } 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]) { } 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 { } else {
console.log("Perdu") 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 = document.createElement("BUTTON");
var button_1 = document.createTextNode("CLICK ME"); var button_1 = document.createTextNode("CLICK ME");
@ -44,10 +51,11 @@ var player_coins = 100
function jeu() { function jeu() {
if (player_coins > 0) { if (player_coins > 0) {
userinput = document.getElementById("mise").value // a dev var mise = document.getElementById("mise").value // a dev
console.log(userinput) console.log(mise)
var tirage = [nbAlea(), nbAlea(), nbAlea()] var tirage = [nbAlea(), nbAlea(), nbAlea()]
console.log(tirage) console.log(tirage)
gain(tirage) gain(tirage)
update_stats()
} }
} }

3
index.html

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