Add get methods
This commit is contained in:
@@ -122,6 +122,15 @@ foreach ($players as $p) {
|
|||||||
let current_blind = 0;
|
let current_blind = 0;
|
||||||
let blinds = {}; // On stocke les mises en cours ici
|
let blinds = {}; // On stocke les mises en cours ici
|
||||||
let money = {}; // On stocke le solde des joueurs ici
|
let money = {}; // On stocke le solde des joueurs ici
|
||||||
|
let players = []; // On stocke les infos des joueurs ici
|
||||||
|
|
||||||
|
// --- RECUPERATION DES DONNEES DE BASE AU CHARGEMENT ---
|
||||||
|
|
||||||
|
// On ajoute les joueurs dans
|
||||||
|
<?php foreach ($players as $p): ?>
|
||||||
|
getActualPlayerBlind(); // On récupère les blinds pour chaque joueur
|
||||||
|
getActualPlayerMoney(); // On récupère les soldes pour chaque joueur
|
||||||
|
|
||||||
|
|
||||||
// --- LES FONCTIONS DE JEU (Logique visuelle) ---
|
// --- LES FONCTIONS DE JEU (Logique visuelle) ---
|
||||||
|
|
||||||
@@ -257,6 +266,88 @@ foreach ($players as $p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getActualPlayerMoney() {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append('game_id', actualGameID);
|
||||||
|
|
||||||
|
fetch('get_player_money.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
players.push({
|
||||||
|
id: data.player_id,
|
||||||
|
money: data.money
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("Erreur : " + data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error("Erreur fetch:", err));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActualPlayerBlind() {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append('game_id', actualGameID);
|
||||||
|
|
||||||
|
fetch('get_player_blind.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
players.push({
|
||||||
|
id: data.player_id,
|
||||||
|
blind: data.blind
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("Erreur : " + data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error("Erreur fetch:", err));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActualGameBlind() {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append('game_id', actualGameID);
|
||||||
|
|
||||||
|
fetch('get_actual_game_blind.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
currentBlind = data.blind; // On met à jour l'affichage de la blind
|
||||||
|
} else {
|
||||||
|
alert("Erreur : " + data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error("Erreur fetch:", err));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTotalGameBlind() {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append('game_id', actualGameID);
|
||||||
|
|
||||||
|
fetch('get_total_blind.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
totalBlind = data.total_blind; // On met à jour l'affichage du pot total
|
||||||
|
} else {
|
||||||
|
alert("Erreur : " + data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error("Erreur fetch:", err));
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db.php';
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$game_id = intval($_POST['game_id']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Récupérer la blind de la partie
|
||||||
|
$stmt = $db->prepare("SELECT last_bet FROM games WHERE id = ?");
|
||||||
|
$stmt->execute([$game_id]);
|
||||||
|
$game = $stmt->fetch();
|
||||||
|
$last_bet = $game['last_bet'];
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'blind' => $last_bet]);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db.php';
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$game_id = intval($_POST['game_id']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Récupérer l'ID du joueur actuel
|
||||||
|
$stmt = $db->prepare("SELECT current_player_id FROM games WHERE id = ?");
|
||||||
|
$stmt->execute([$game_id]);
|
||||||
|
$game = $stmt->fetch();
|
||||||
|
$current_player_id = $game['current_player_id'];
|
||||||
|
|
||||||
|
// 2. Récupérer la blind du joueur actuel
|
||||||
|
$stmt = $db->prepare("SELECT current_bet FROM players WHERE id = ?");
|
||||||
|
$stmt->execute([$current_player_id]);
|
||||||
|
$player = $stmt->fetch();
|
||||||
|
$blind = $player['current_bet'];
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'blind' => $blind, 'player_id' => $current_player_id]);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db.php';
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$game_id = intval($_POST['game_id']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Récupérer l'ID du joueur actuel
|
||||||
|
$stmt = $db->prepare("SELECT current_player_id FROM games WHERE id = ?");
|
||||||
|
$stmt->execute([$game_id]);
|
||||||
|
$game = $stmt->fetch();
|
||||||
|
$current_player_id = $game['current_player_id'];
|
||||||
|
|
||||||
|
// 2. Récupérer l'argent du joueur actuel
|
||||||
|
$stmt = $db->prepare("SELECT money FROM players WHERE id = ?");
|
||||||
|
$stmt->execute([$current_player_id]);
|
||||||
|
$player = $stmt->fetch();
|
||||||
|
$money = $player['money'];
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'money' => $money, 'player_id' => $current_player_id]);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db.php';
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$game_id = intval($_POST['game_id']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Récupérer la blind de la partie
|
||||||
|
$stmt = $db->prepare("SELECT pot FROM games WHERE id = ?");
|
||||||
|
$stmt->execute([$game_id]);
|
||||||
|
$game = $stmt->fetch();
|
||||||
|
$pot = $game['pot'];
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'total_blind' => $pot]);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user