some hotfixes
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
// Fonction et variables essentiel
|
||||
|
||||
async function SqlRequest(action, params = {}) {
|
||||
@@ -96,6 +94,7 @@ loginForm.addEventListener('submit', async function(event) {
|
||||
await SqlRequest('addPlayer', {game_id: gameId, name: player.value, money: start_money});
|
||||
}
|
||||
const result = await SqlRequest('setFirstPlayer', {game_id: gameId})
|
||||
console.log(result)
|
||||
if (result.success) {
|
||||
window.location.href = 'admin-login.html?game_id=' + gameId;
|
||||
} else {
|
||||
|
||||
+45
-7
@@ -81,24 +81,26 @@ async function updateClientInterface() {
|
||||
const actionPanel = document.querySelector('.action-panel');
|
||||
|
||||
// --- 1. GESTION DES PANNEAUX DE VICTOIRE (SYNCHRO SSE) ---
|
||||
|
||||
console.log("DEBUG STATUS SSE:", gameData.status);
|
||||
if (gameData.status === 'deciding') {
|
||||
// L'admin est en train de choisir : on affiche "Attente"
|
||||
showWaitingForWinner();
|
||||
}
|
||||
}
|
||||
|
||||
else if (gameData.status === 'finished' && gameData.winner_id) {
|
||||
// Un gagnant a été validé en BDD
|
||||
const winner = playersData.find(p => Number(p.id) === Number(gameData.winner_id));
|
||||
const winnerName = winner ? winner.name : "Un joueur";
|
||||
|
||||
// showVictoryScreen s'occupe maintenant de supprimer l'ancien panneau
|
||||
// showVictoryScreen s'occupe maintenant de supprimer l'ancien panneau
|
||||
// avant d'afficher le nouveau avec les confettis.
|
||||
showVictoryScreen(winnerName, gameData.pot);
|
||||
}
|
||||
}
|
||||
|
||||
else if (gameData.status === 'playing') {
|
||||
// Si l'admin a relancé la partie (StartNewGame), on nettoie les panneaux
|
||||
// pour ceux qui n'auraient pas cliqué sur "OK"
|
||||
closeVictoryScreen();
|
||||
closeVictoryScreen();
|
||||
}
|
||||
|
||||
// --- 2. GESTION DU HASH POUR L'INTERFACE DE TABLE ---
|
||||
@@ -106,10 +108,10 @@ async function updateClientInterface() {
|
||||
const currentHash = `${gameData.pot}-${gameData.current_player_id}-${gameData.last_bet}-${gameData.is_locked}-${gameData.status}`;
|
||||
if (currentHash === lastDataHash) return;
|
||||
lastDataHash = currentHash;
|
||||
|
||||
|
||||
setupPlayers();
|
||||
getCurrentPlayer();
|
||||
|
||||
|
||||
// --- 3. GESTION DES BOUTONS ET DU TOUR ---
|
||||
|
||||
const isLocked = Number(gameData.is_locked) === 1;
|
||||
@@ -118,8 +120,10 @@ async function updateClientInterface() {
|
||||
const inputs = document.querySelectorAll('.action-buttons button, .raise-group input, .raise-group button');
|
||||
|
||||
// Bordure de tour
|
||||
|
||||
if (!isLocked && isMyTurn && gameData.status === 'playing') {
|
||||
actionPanel.classList.add('my-turn-border');
|
||||
|
||||
} else {
|
||||
actionPanel.classList.remove('my-turn-border');
|
||||
}
|
||||
@@ -127,15 +131,45 @@ async function updateClientInterface() {
|
||||
if (isLocked) {
|
||||
if (turnInfo) turnInfo.innerHTML = `<span style="color: #f1c40f; font-weight: bold;">🔒 Jeu verrouillé. En attente de l'Admin...</span>`;
|
||||
inputs.forEach(el => el.disabled = true);
|
||||
|
||||
} else if (!isMyTurn) {
|
||||
if (turnInfo && currentPlayer) {
|
||||
turnInfo.innerHTML = `Attente de <strong style="color: #e74c3c;">${currentPlayer.name}</strong>...`;
|
||||
}
|
||||
|
||||
inputs.forEach(el => el.disabled = true);
|
||||
} else {
|
||||
if (turnInfo) turnInfo.innerHTML = `<span style="color: #2ecc71; font-weight: bold;">✅ C'est à vous de jouer !</span>`;
|
||||
inputs.forEach(el => el.disabled = false);
|
||||
}
|
||||
// --- 3.bis BOUTON INTELLIGENT (Seulement si c'est mon tour) ---
|
||||
const currentMiseTable = Number(gameData.last_bet);
|
||||
const btnFollow = document.getElementById('btn-call');
|
||||
const btnFold = document.getElementById('btn-fold');
|
||||
|
||||
if (currentMiseTable === 0) {
|
||||
// PERSONNE N'A MISÉ : "Rester"
|
||||
if (btnFollow) {
|
||||
btnFollow.textContent = `Rester (Passer son tour)`;
|
||||
btnFollow.onclick = () => playerCall();
|
||||
btnFollow.className = "btn btn-stay";
|
||||
}
|
||||
if (btnFold) {
|
||||
btnFold.disabled = true; // Désactivé car inutile de se coucher
|
||||
btnFold.style.opacity = "0.5";
|
||||
}
|
||||
} else {
|
||||
// UNE MISE EXISTE : "Suivre"
|
||||
if (btnFollow) {
|
||||
btnFollow.textContent = `Suivre (${currentMiseTable} 🪙)`;
|
||||
btnFollow.onclick = () => playerFollow();
|
||||
btnFollow.className = "btn btn-call";
|
||||
}
|
||||
if (btnFold) {
|
||||
btnFold.disabled = false;
|
||||
btnFold.style.opacity = "1";
|
||||
}
|
||||
}
|
||||
|
||||
// Mise à jour du label du haut
|
||||
if (currentPlayer && activePlayerLabel) {
|
||||
@@ -414,6 +448,10 @@ async function playerFollow() {
|
||||
}
|
||||
}
|
||||
|
||||
async function playerCall() {
|
||||
changePlayer();
|
||||
}
|
||||
|
||||
async function playerAllIn() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const viewerId = Number(urlParams.get('player_id'));
|
||||
|
||||
@@ -394,8 +394,18 @@ async function declareWinner(playerId) {
|
||||
if (resStatus && resStatus.success) {
|
||||
console.log("✅ Statut passé à 'finished'");
|
||||
|
||||
// Mise à jour de l'interface Admin
|
||||
showAdminWinPanel(playerId);
|
||||
// On met a jour les valeurs dans BDD
|
||||
const result = await SqlRequest('declare_winner', {
|
||||
game_id: gameData.id,
|
||||
player_id: playerId
|
||||
});
|
||||
|
||||
if (result && result.success){
|
||||
// Mise à jour de l'interface Admin
|
||||
showAdminWinPanel(playerId);
|
||||
} else {
|
||||
console.log("Dommage tu y étais presque")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
alert("Erreur lors de la mise à jour du gagnant.");
|
||||
|
||||
Reference in New Issue
Block a user