Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit ee1a4e55 authored by Arnaud Chevalier's avatar Arnaud Chevalier

pot updated autoatically on poker page

parent 702b9812
......@@ -252,7 +252,8 @@ function catchUp(tableState) {
setHeroCards(testhand);
setOpponentCards(testhand);
setPlayers(tableState.players);
setPots(testhand);
//setPots(testhand);
setPots(tableState);
moveButton(targetSeat + 1);
......@@ -437,7 +438,18 @@ function setCard(div, card) {
div.css('background-image', getCardSrc(card['Rank'], card['Suit']))
}
function setPots(hand) {
function setPots(tableState) {
var currentPot = 0;
for(var i = 0; i < tableState['players'].length; i++){
console.log(i);
currentPot = currentPot + parseFloat(tableState['players'][i]['chipsOnTable']);
}
console.log(tableState);
setCurrentPot(currentPot);
setTotalPot(parseFloat(tableState['pot']));
}
/*function setPots(hand) {
// TODO: Handle side pots on all-ins
var curPot = 0.0;
var totalPot = 0.0;
......@@ -469,7 +481,7 @@ function setPots(hand) {
setCurrentPot(curPot);
setTotalPot(totalPot);
}
}*/
function setTotalPot(amount) {
$('#total-pot').text('Total pot: $' + amount.toFixed(2));
......@@ -479,7 +491,7 @@ function setCurrentPot(amount) {
if (amount == 0)
$('#current-pot').text("");
else
$('#current-pot').text('$' + amount.toFixed(2));
$('#current-pot').text('Current pot: $' + amount.toFixed(2));
}
function getChipSrc(chipValue) {
......
......@@ -9,7 +9,7 @@ class Player:
# INIT
def __init__(self, name):
self.__uniqueId = uuid4()
self.__uniqueId = str(uuid4())
self.__hand = Hand()
self.__chips = int(0)
self.__cards = []
......
from uuid import uuid4
import uuid as uuid
from flask import Flask, render_template, request, redirect, url_for, make_response, jsonify, send_from_directory
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from table import Table
from player.player import Player
app = Flask(__name__, static_url_path='/front/')
......@@ -9,7 +9,7 @@ app = Flask(__name__, static_url_path='/front/')
games = {}
@app.route("/api/game/<string:gameId>") # TODO: add game ID
@app.route("/api/game/<string:gameId>")
def gameState(gameId):
playerId = request.cookies.get("userId")
if gameId in games.keys():
......
......@@ -31,7 +31,7 @@ class GameState(Enum):
class Table(object):
def __init__(self, maxPlayers):
self.uniqueId = uuid4()
self.uniqueId = str(uuid4())
self.maxPlayers = maxPlayers
self.gameState = GameState.IDLE
self.players = []
......
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