Commit a55966a0 authored by Arnaud Chevalier's avatar Arnaud Chevalier

fixed history

parent e08ab3a4
Pipeline #6361 failed with stage
var server;
var gameId = window.location.href.substring((window.location.origin + window.location.pathname).length + 8);
var players = [];
function catchUp(tableState) {
updateHistory(tableState)
setBoard(tableState.boardCards);
setHoleCards(tableState.holeCards, tableState.players);
setPlayers(tableState.players);
......@@ -13,6 +15,32 @@ function catchUp(tableState) {
setBB(tableState["BB"]);
}
function updateHistory(tableState) {
var state = tableState;
var txt = '';
console.log(players);
if (players.length > 0) {
console.log("test")
for (var i = 0; i < state['players'].length; i++) {
if (players[i]['state'] !== state['players'][i]['state']) {
if (state['players'][i]['state'].length > 0) {
txt = txt + 'Game event ==> ' + state['players'][i]['name'] + ' : ' + state['players'][i]['state'] + ', <br>'
} else {
txt = txt + 'Game event ==> ' + state['players'][i]['name'] + ' : IN HAND, <br>'
}
}
}
for (var i = 0; i < state['players'].length; i++) {
if (players[i]['won'] !== state['players'][i]['won'] && state['players'][i]['won']) {
txt = txt + 'Hand ' + state['handNbr'] + ' ended ==> ' + state['players'][i]['name'] + ' : ' + 'WON <br>'
}
}
var history = document.getElementById('history');
history.innerHTML += txt;
}
players = state.players;
}
function setActionButtons(tableState) {
var state = $('#state');
if (tableState["handNbr"] > 0) {
......@@ -203,7 +231,7 @@ function setCurrentPot(amount) {
function checkClicked() {
var history = document.getElementById('history');
history.innerHTML += 'You clicked CHECK <br>';
history.innerHTML += 'Your action ==> CHECK <br>';
var url = '/api/game/' + gameId + "/action";
console.log(url);
$.ajax({
......@@ -221,7 +249,7 @@ function checkClicked() {
function foldClicked() {
var history = document.getElementById('history');
history.innerHTML += 'You clicked FLOD <br>';
history.innerHTML += 'Your action ==> FLOD <br>';
var url = '/api/game/' + gameId + "/action";
console.log(url);
$.ajax({
......@@ -239,7 +267,7 @@ function foldClicked() {
function callClicked() {
var history = document.getElementById('history');
history.innerHTML += 'You clicked CALL <br>';
history.innerHTML += 'Your action ==> CALL <br>';
var url = '/api/game/' + gameId + "/action";
console.log(url);
$.ajax({
......@@ -257,7 +285,7 @@ function callClicked() {
function raiseClicked() {
var history = document.getElementById('history');
history.innerHTML += 'You clicked RAISE <br>';
history.innerHTML += 'Your action ==> RAISE <br>';
var url = '/api/game/' + gameId + "/action";
console.log(url);
var amount = document.forms[0].amount.value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment