From 8f3476d58a3408c1211e18073629c2051c511175 Mon Sep 17 00:00:00 2001 From: "sacha.serny" Date: Thu, 24 Mar 2022 09:50:35 +0100 Subject: [PATCH] hi --- app.js | 18 +++++++++++++----- index.html | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index c37369b..cb8737c 100644 --- a/app.js +++ b/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() } } diff --git a/index.html b/index.html index f053580..c02a935 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,9 @@ + +
+
\ No newline at end of file