Import initial du site depuis le serveur
This commit is contained in:
+172
-172
@@ -1,173 +1,173 @@
|
||||
/* Le panneau qui contient tout le message de fin */
|
||||
/* Le rideau qui floute l'arrière-plan */
|
||||
.win-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.7); /* Fond noir semi-transparent */
|
||||
backdrop-filter: blur(8px); /* C'est ici qu'on met le flou ! */
|
||||
z-index: 9998; /* Juste en dessous du panel */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* On ajuste le win-panel pour qu'il soit propre à l'intérieur */
|
||||
.win-panel {
|
||||
position: relative; /* Plus besoin de fixed ici car l'overlay l'est déjà */
|
||||
background: #1a1a1a;
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
border: 3px solid #ffd700;
|
||||
box-shadow: 0 0 50px rgba(0, 0, 0, 1);
|
||||
z-index: 9999;
|
||||
text-align: center;
|
||||
min-width: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
/* Le titre dans le panel */
|
||||
.win-panel h2 {
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
font-family: 'Arial Black', sans-serif;
|
||||
text-transform: uppercase;
|
||||
line-height: 1.4;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
/* Zone qui contient les boutons des joueurs */
|
||||
#winner-buttons-area {
|
||||
display: flex;
|
||||
flex-wrap: wrap; /* Si beaucoup de joueurs, ils vont à la ligne */
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Tes boutons .btn-win (on réutilise le style Or précédent) */
|
||||
.btn-win {
|
||||
background: linear-gradient(to bottom, #ffd700, #b8860b);
|
||||
border: 2px solid #8b4513;
|
||||
color: #000;
|
||||
padding: 15px 30px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.btn-win:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.btn-win:active {
|
||||
transform: translateY(3px);
|
||||
box-shadow: 0 1px 0 #5d2e0a;
|
||||
}
|
||||
|
||||
/* Base commune pour tous les boutons de l'interface */
|
||||
.btn-back, .btn-replay {
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
font-weight: bold;
|
||||
padding: 10px 20px;
|
||||
text-transform: uppercase;
|
||||
transition: all 0.2s ease;
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* Style spécifique : Retour (Style plus sobre / Alerte) */
|
||||
.btn-back {
|
||||
background: linear-gradient(to bottom, #d9534f, #a94442); /* Rouge profond */
|
||||
box-shadow: 0 4px 0 #7b2e2c;
|
||||
}
|
||||
|
||||
.btn-back:hover {
|
||||
filter: brightness(1.1);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 0 #7b2e2c;
|
||||
}
|
||||
|
||||
/* Style spécifique : Rejouer (Style Action / Casino) */
|
||||
.btn-replay {
|
||||
background: linear-gradient(to bottom, #5bc0de, #2aabd2); /* Bleu électrique */
|
||||
box-shadow: 0 4px 0 #1b728c;
|
||||
}
|
||||
|
||||
.btn-replay:hover {
|
||||
filter: brightness(1.1);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 0 #1b728c;
|
||||
}
|
||||
|
||||
/* Animation au clic pour les deux */
|
||||
.btn-back:active, .btn-replay:active {
|
||||
transform: translateY(3px);
|
||||
box-shadow: 0 1px 0 rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.blur-effect {
|
||||
filter: blur(5px);
|
||||
pointer-events: none; /* Empêche de cliquer sur la table derrière */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Le conteneur avec la bordure dorée fine */
|
||||
.money-group {
|
||||
display: inline-flex;
|
||||
align-items: stretch; /* Force le bouton à prendre toute la hauteur */
|
||||
background: #1e1e1e; /* Fond très sombre pour faire ressortir l'or */
|
||||
border: 1px solid #c5a059; /* Bordure Or mat (plus sobre que le jaune brillant) */
|
||||
border-radius: 8px;
|
||||
overflow: hidden; /* Pour que le bouton épouse l'arrondi de la bordure */
|
||||
height: 40px; /* Hauteur fixe pour un look plus pro */
|
||||
}
|
||||
|
||||
/* Le champ de saisie */
|
||||
#money-amount {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
font-size: 1rem;
|
||||
padding: 0 15px;
|
||||
width: 100px; /* Ajustable selon tes besoins */
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Le bouton OK qui occupe tout l'espace à droite */
|
||||
.btn-money {
|
||||
background: linear-gradient(45deg, #d4af37, #f9e27d); /* Fond Or mat */
|
||||
border: none;
|
||||
color: #1e1e1e; /* Texte sombre pour le contraste */
|
||||
cursor: pointer;
|
||||
font-weight: 800;
|
||||
padding: 0 20px; /* Largeur du bouton */
|
||||
text-transform: uppercase;
|
||||
transition: background 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center; /* Centre le texte "OK" verticalement */
|
||||
}
|
||||
|
||||
.btn-money:hover {
|
||||
filter: brightness(1.2); /* Or un peu plus clair au survol */
|
||||
}
|
||||
|
||||
.btn-money:active {
|
||||
filter: brightness(0.8); /* Or plus sombre au clic */
|
||||
}
|
||||
|
||||
/* Suppression des flèches de l'input */
|
||||
#money-amount::-webkit-inner-spin-button,
|
||||
#money-amount::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
/* Le panneau qui contient tout le message de fin */
|
||||
/* Le rideau qui floute l'arrière-plan */
|
||||
.win-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.7); /* Fond noir semi-transparent */
|
||||
backdrop-filter: blur(8px); /* C'est ici qu'on met le flou ! */
|
||||
z-index: 9998; /* Juste en dessous du panel */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* On ajuste le win-panel pour qu'il soit propre à l'intérieur */
|
||||
.win-panel {
|
||||
position: relative; /* Plus besoin de fixed ici car l'overlay l'est déjà */
|
||||
background: #1a1a1a;
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
border: 3px solid #ffd700;
|
||||
box-shadow: 0 0 50px rgba(0, 0, 0, 1);
|
||||
z-index: 9999;
|
||||
text-align: center;
|
||||
min-width: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
/* Le titre dans le panel */
|
||||
.win-panel h2 {
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
font-family: 'Arial Black', sans-serif;
|
||||
text-transform: uppercase;
|
||||
line-height: 1.4;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
/* Zone qui contient les boutons des joueurs */
|
||||
#winner-buttons-area {
|
||||
display: flex;
|
||||
flex-wrap: wrap; /* Si beaucoup de joueurs, ils vont à la ligne */
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Tes boutons .btn-win (on réutilise le style Or précédent) */
|
||||
.btn-win {
|
||||
background: linear-gradient(to bottom, #ffd700, #b8860b);
|
||||
border: 2px solid #8b4513;
|
||||
color: #000;
|
||||
padding: 15px 30px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.btn-win:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.btn-win:active {
|
||||
transform: translateY(3px);
|
||||
box-shadow: 0 1px 0 #5d2e0a;
|
||||
}
|
||||
|
||||
/* Base commune pour tous les boutons de l'interface */
|
||||
.btn-back, .btn-replay {
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
font-weight: bold;
|
||||
padding: 10px 20px;
|
||||
text-transform: uppercase;
|
||||
transition: all 0.2s ease;
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* Style spécifique : Retour (Style plus sobre / Alerte) */
|
||||
.btn-back {
|
||||
background: linear-gradient(to bottom, #d9534f, #a94442); /* Rouge profond */
|
||||
box-shadow: 0 4px 0 #7b2e2c;
|
||||
}
|
||||
|
||||
.btn-back:hover {
|
||||
filter: brightness(1.1);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 0 #7b2e2c;
|
||||
}
|
||||
|
||||
/* Style spécifique : Rejouer (Style Action / Casino) */
|
||||
.btn-replay {
|
||||
background: linear-gradient(to bottom, #5bc0de, #2aabd2); /* Bleu électrique */
|
||||
box-shadow: 0 4px 0 #1b728c;
|
||||
}
|
||||
|
||||
.btn-replay:hover {
|
||||
filter: brightness(1.1);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 0 #1b728c;
|
||||
}
|
||||
|
||||
/* Animation au clic pour les deux */
|
||||
.btn-back:active, .btn-replay:active {
|
||||
transform: translateY(3px);
|
||||
box-shadow: 0 1px 0 rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.blur-effect {
|
||||
filter: blur(5px);
|
||||
pointer-events: none; /* Empêche de cliquer sur la table derrière */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Le conteneur avec la bordure dorée fine */
|
||||
.money-group {
|
||||
display: inline-flex;
|
||||
align-items: stretch; /* Force le bouton à prendre toute la hauteur */
|
||||
background: #1e1e1e; /* Fond très sombre pour faire ressortir l'or */
|
||||
border: 1px solid #c5a059; /* Bordure Or mat (plus sobre que le jaune brillant) */
|
||||
border-radius: 8px;
|
||||
overflow: hidden; /* Pour que le bouton épouse l'arrondi de la bordure */
|
||||
height: 40px; /* Hauteur fixe pour un look plus pro */
|
||||
}
|
||||
|
||||
/* Le champ de saisie */
|
||||
#money-amount {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
font-size: 1rem;
|
||||
padding: 0 15px;
|
||||
width: 100px; /* Ajustable selon tes besoins */
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Le bouton OK qui occupe tout l'espace à droite */
|
||||
.btn-money {
|
||||
background: linear-gradient(45deg, #d4af37, #f9e27d); /* Fond Or mat */
|
||||
border: none;
|
||||
color: #1e1e1e; /* Texte sombre pour le contraste */
|
||||
cursor: pointer;
|
||||
font-weight: 800;
|
||||
padding: 0 20px; /* Largeur du bouton */
|
||||
text-transform: uppercase;
|
||||
transition: background 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center; /* Centre le texte "OK" verticalement */
|
||||
}
|
||||
|
||||
.btn-money:hover {
|
||||
filter: brightness(1.2); /* Or un peu plus clair au survol */
|
||||
}
|
||||
|
||||
.btn-money:active {
|
||||
filter: brightness(0.8); /* Or plus sombre au clic */
|
||||
}
|
||||
|
||||
/* Suppression des flèches de l'input */
|
||||
#money-amount::-webkit-inner-spin-button,
|
||||
#money-amount::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
+108
-108
@@ -1,108 +1,108 @@
|
||||
|
||||
// ################# Ces infos sont a changer en fonction de la BDD ##########################################################
|
||||
|
||||
let text = document.getElementById("text");
|
||||
let money_input = document.getElementById("Money");
|
||||
|
||||
let money = { // Se rapelle de l'argent que chaque joueur a au début de la partie
|
||||
"Ender": 10000,
|
||||
"Sophie": 1000,
|
||||
"Léo": 1000,
|
||||
"Mélanie": 1000,
|
||||
"Jean": 500,
|
||||
"Lucie": 1000
|
||||
};
|
||||
let blinds = { // Se rapelle de l'argent actuellement mis en jeu par chaque joueur
|
||||
"Ender": 20,
|
||||
"Sophie": 30,
|
||||
"Léo": 20,
|
||||
"Mélanie": 20,
|
||||
"Jean": 20,
|
||||
"Lucie": 20
|
||||
};
|
||||
let player_list = ["Ender", "Sophie", "Léo", "Mélanie", "Jean", "Lucie"]; // Liste des joueurs encore en jeu a replir avec la BDD
|
||||
let current_player = "Ender"; // Joueur actuel a prendre depuis la BDD
|
||||
let start_blind = 20; // Blinde de départ a prendre depuis la BDD
|
||||
|
||||
// ##########################################################################################################################
|
||||
let current_blind = 0; // Initialistation de la blinde actuelle en variable globale, mis a jour automatiquement
|
||||
|
||||
|
||||
function ChangePlayer(player) { // Uniquement pour les tests, à remplacer par une fonction qui change de joueur dans la Boucle de jeu
|
||||
current_player = player;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function UpdateStatus() { // Fonction mettant à jour la blinde actuel en fonction des blinds de chaque joueur
|
||||
current_blind = Math.max(...Object.values(blinds));
|
||||
}
|
||||
function UpdateLabels() { // Fonction pour mettre à jour les labels
|
||||
let pot = Object.values(blinds).reduce((a, b) => a + b, 0);
|
||||
let money_labels = {}
|
||||
for (key of Object.keys(money)) {
|
||||
money_labels[key] = money[key] - blinds[key];
|
||||
}
|
||||
|
||||
// Reste à faire avec ton code
|
||||
}
|
||||
|
||||
function SeCoucher() { // fonction pour se coucher, elle vérifie si le joueur est en jeu et si sa mise actuelle est inférieure a la blinde actuel, si c'est le cas, il se couche et est retiré de la liste des joueurs encore en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (current_blind > blinds[current_player] && player_list.includes(current_player)) { // Si le joueur est en jeu et que sa mise actuelle est inférieure a la blinde actuel, il se couche
|
||||
player_list.splice(player_list.indexOf(current_player), 1);
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
|
||||
function Suivre() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il suit
|
||||
UpdateStatus();
|
||||
if (current_blind > blinds[current_player] && money[current_player] >= current_blind) { // Si la blinde actuelle est supérieur a la sienne et qu'il est en capacité de la payer
|
||||
blinds[current_player] = current_blind;
|
||||
} else {
|
||||
Tapis();
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Relancer() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (+money_input.value >= Math.max(...Object.values(money))){
|
||||
Tapis();
|
||||
} else {
|
||||
if (money[current_player] > (current_blind) && +money_input.value <= money[current_player] - current_blind && +money_input.value > 0 && +money_input.value % (start_blind / 2) == 0) { // Si le joueur a assez d'argent pour suivre la blinde actuelle et relancer
|
||||
blinds[current_player] = current_blind + +money_input.value;
|
||||
}
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Tapis() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il fait tapis
|
||||
UpdateStatus();
|
||||
|
||||
if (money[current_player] < Math.max(...Object.values(money))) { // Si le joueur n'est pas le plus riche
|
||||
blinds[current_player] = money[current_player];
|
||||
|
||||
} else { // Si le joueur est le plus riche
|
||||
let temp_money = {...money};
|
||||
temp_money[current_player] = 0;
|
||||
let second_most_rich = Math.max(...Object.values(temp_money));
|
||||
|
||||
|
||||
blinds[current_player] = second_most_rich;
|
||||
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ################# Ces infos sont a changer en fonction de la BDD ##########################################################
|
||||
|
||||
let text = document.getElementById("text");
|
||||
let money_input = document.getElementById("Money");
|
||||
|
||||
let money = { // Se rapelle de l'argent que chaque joueur a au début de la partie
|
||||
"Ender": 10000,
|
||||
"Sophie": 1000,
|
||||
"Léo": 1000,
|
||||
"Mélanie": 1000,
|
||||
"Jean": 500,
|
||||
"Lucie": 1000
|
||||
};
|
||||
let blinds = { // Se rapelle de l'argent actuellement mis en jeu par chaque joueur
|
||||
"Ender": 20,
|
||||
"Sophie": 30,
|
||||
"Léo": 20,
|
||||
"Mélanie": 20,
|
||||
"Jean": 20,
|
||||
"Lucie": 20
|
||||
};
|
||||
let player_list = ["Ender", "Sophie", "Léo", "Mélanie", "Jean", "Lucie"]; // Liste des joueurs encore en jeu a replir avec la BDD
|
||||
let current_player = "Ender"; // Joueur actuel a prendre depuis la BDD
|
||||
let start_blind = 20; // Blinde de départ a prendre depuis la BDD
|
||||
|
||||
// ##########################################################################################################################
|
||||
let current_blind = 0; // Initialistation de la blinde actuelle en variable globale, mis a jour automatiquement
|
||||
|
||||
|
||||
function ChangePlayer(player) { // Uniquement pour les tests, à remplacer par une fonction qui change de joueur dans la Boucle de jeu
|
||||
current_player = player;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function UpdateStatus() { // Fonction mettant à jour la blinde actuel en fonction des blinds de chaque joueur
|
||||
current_blind = Math.max(...Object.values(blinds));
|
||||
}
|
||||
function UpdateLabels() { // Fonction pour mettre à jour les labels
|
||||
let pot = Object.values(blinds).reduce((a, b) => a + b, 0);
|
||||
let money_labels = {}
|
||||
for (key of Object.keys(money)) {
|
||||
money_labels[key] = money[key] - blinds[key];
|
||||
}
|
||||
|
||||
// Reste à faire avec ton code
|
||||
}
|
||||
|
||||
function SeCoucher() { // fonction pour se coucher, elle vérifie si le joueur est en jeu et si sa mise actuelle est inférieure a la blinde actuel, si c'est le cas, il se couche et est retiré de la liste des joueurs encore en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (current_blind > blinds[current_player] && player_list.includes(current_player)) { // Si le joueur est en jeu et que sa mise actuelle est inférieure a la blinde actuel, il se couche
|
||||
player_list.splice(player_list.indexOf(current_player), 1);
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
|
||||
function Suivre() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il suit
|
||||
UpdateStatus();
|
||||
if (current_blind > blinds[current_player] && money[current_player] >= current_blind) { // Si la blinde actuelle est supérieur a la sienne et qu'il est en capacité de la payer
|
||||
blinds[current_player] = current_blind;
|
||||
} else {
|
||||
Tapis();
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Relancer() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (+money_input.value >= Math.max(...Object.values(money))){
|
||||
Tapis();
|
||||
} else {
|
||||
if (money[current_player] > (current_blind) && +money_input.value <= money[current_player] - current_blind && +money_input.value > 0 && +money_input.value % (start_blind / 2) == 0) { // Si le joueur a assez d'argent pour suivre la blinde actuelle et relancer
|
||||
blinds[current_player] = current_blind + +money_input.value;
|
||||
}
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Tapis() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il fait tapis
|
||||
UpdateStatus();
|
||||
|
||||
if (money[current_player] < Math.max(...Object.values(money))) { // Si le joueur n'est pas le plus riche
|
||||
blinds[current_player] = money[current_player];
|
||||
|
||||
} else { // Si le joueur est le plus riche
|
||||
let temp_money = {...money};
|
||||
temp_money[current_player] = 0;
|
||||
let second_most_rich = Math.max(...Object.values(temp_money));
|
||||
|
||||
|
||||
blinds[current_player] = second_most_rich;
|
||||
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
|
||||
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. Ajouter l'argent au blind du joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $current_player_id]);
|
||||
|
||||
// 3. Ajouter le montant au pot de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET pot = pot + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
|
||||
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. Ajouter l'argent au blind du joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $current_player_id]);
|
||||
|
||||
// 3. Ajouter le montant au pot de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET pot = pot + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
?>
|
||||
+22
-22
@@ -1,23 +1,23 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
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. Ajouter de l'argent au joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
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. Ajouter de l'argent au joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
+37
-37
@@ -1,38 +1,38 @@
|
||||
<?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 * FROM players WHERE id = ?");
|
||||
$stmt->execute([$current_player_id]);
|
||||
$player = $stmt->fetch();
|
||||
$money = $player['money'];
|
||||
|
||||
// 3. Mettre à jour la blinde du joueur actuel avec tout son argent
|
||||
$stmt = $db->prepare("UPDATE players SET current_bet = ? WHERE id = ?");
|
||||
$stmt->execute([$money + $player['current_bet'], $current_player_id]);
|
||||
|
||||
// 4. Retirer tout l'argent du joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = 0 WHERE id = ?");
|
||||
$stmt->execute([$current_player_id]);
|
||||
|
||||
// 5. Ajouter le montant au pot de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET pot = pot + ? WHERE id = ?");
|
||||
$stmt->execute([$money, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
<?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 * FROM players WHERE id = ?");
|
||||
$stmt->execute([$current_player_id]);
|
||||
$player = $stmt->fetch();
|
||||
$money = $player['money'];
|
||||
|
||||
// 3. Mettre à jour la blinde du joueur actuel avec tout son argent
|
||||
$stmt = $db->prepare("UPDATE players SET current_bet = ? WHERE id = ?");
|
||||
$stmt->execute([$money + $player['current_bet'], $current_player_id]);
|
||||
|
||||
// 4. Retirer tout l'argent du joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = 0 WHERE id = ?");
|
||||
$stmt->execute([$current_player_id]);
|
||||
|
||||
// 5. Ajouter le montant au pot de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET pot = pot + ? WHERE id = ?");
|
||||
$stmt->execute([$money, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
try {
|
||||
// 1. Changer la blind de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET last_bet = ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
try {
|
||||
// 1. Changer la blind de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET last_bet = ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
@@ -1,48 +1,48 @@
|
||||
<?php
|
||||
require_once 'db.php'; // Ta connexion PDO
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$action = $_POST['action'];
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
|
||||
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. Logique de changement de joueur (Simplifiée)
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE is_folded = 0 AND game_id = ? AND id > ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id, $current_player_id]);
|
||||
$next_player = $stmt->fetch();
|
||||
|
||||
if (!$next_player) { // Si on est au dernier, on revient au premier
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE is_folded=0 AND game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$next_player = $stmt->fetch();
|
||||
}
|
||||
|
||||
// On cherche si le joueur est couché ou pas
|
||||
$stmt = $db->prepare("SELECT is_folded FROM players WHERE id = ?");
|
||||
$stmt->execute([$next_player['id']]);
|
||||
$is_folded = $stmt->fetchColumn();
|
||||
if ($is_folded == 1 || $is_folded === '1') {
|
||||
// Si le joueur est couché, on appelle récursivement pour sauter au suivant
|
||||
$_POST['game_id'] = $game_id; // On remet le game_id pour l'appel récursif
|
||||
echo json_encode(['success' => true, 'message' => 'Joueur couché, passage au suivant.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$next_id = $next_player['id'];
|
||||
|
||||
// 3. Mise à jour de la BDD
|
||||
$stmt = $db->prepare("UPDATE games SET current_player_id = ? WHERE id = ?");
|
||||
$stmt->execute([$next_id, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true, 'next_player_id' => $next_id]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
<?php
|
||||
require_once 'db.php'; // Ta connexion PDO
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$action = $_POST['action'];
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
|
||||
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. Logique de changement de joueur (Simplifiée)
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE is_folded = 0 AND game_id = ? AND id > ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id, $current_player_id]);
|
||||
$next_player = $stmt->fetch();
|
||||
|
||||
if (!$next_player) { // Si on est au dernier, on revient au premier
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE is_folded=0 AND game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$next_player = $stmt->fetch();
|
||||
}
|
||||
|
||||
// On cherche si le joueur est couché ou pas
|
||||
$stmt = $db->prepare("SELECT is_folded FROM players WHERE id = ?");
|
||||
$stmt->execute([$next_player['id']]);
|
||||
$is_folded = $stmt->fetchColumn();
|
||||
if ($is_folded == 1 || $is_folded === '1') {
|
||||
// Si le joueur est couché, on appelle récursivement pour sauter au suivant
|
||||
$_POST['game_id'] = $game_id; // On remet le game_id pour l'appel récursif
|
||||
echo json_encode(['success' => true, 'message' => 'Joueur couché, passage au suivant.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$next_id = $next_player['id'];
|
||||
|
||||
// 3. Mise à jour de la BDD
|
||||
$stmt = $db->prepare("UPDATE games SET current_player_id = ? WHERE id = ?");
|
||||
$stmt->execute([$next_id, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true, 'next_player_id' => $next_id]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
+233
-233
@@ -1,234 +1,234 @@
|
||||
/* config.css */
|
||||
:root {
|
||||
--poker-green: #0e5d32;
|
||||
--gold: #d4af37;
|
||||
--wood: #3e2723;
|
||||
--white: #ffffff;
|
||||
--danger: #b71c1c;
|
||||
}
|
||||
|
||||
label.info {
|
||||
font-size: 0.8rem;
|
||||
color: rgb(141, 141, 141);
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #121212;
|
||||
background-image: radial-gradient(circle, #1a1a1a 0%, #000000 100%);
|
||||
color: var(--white);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: var(--poker-green);
|
||||
padding: 30px 50px;
|
||||
border-radius: 60px;
|
||||
border: 12px solid var(--wood);
|
||||
box-shadow: 0 0 50px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.5);
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: var(--gold);
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
font-size: 1.8rem;
|
||||
margin-bottom: 30px;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
color: var(--gold);
|
||||
font-weight: bold;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
input[type="number"],
|
||||
input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
margin-bottom: 20px;
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
box-sizing: border-box; /* Pour que le padding ne dépasse pas */
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Style spécifique pour la ligne joueur */
|
||||
.player-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.player-row input {
|
||||
margin-bottom: 0; /* On annule la marge pour l'alignement */
|
||||
}
|
||||
|
||||
/* Boutons */
|
||||
button, input[type="submit"] {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
transition: all 0.2s;
|
||||
border: none;
|
||||
}
|
||||
|
||||
button[type="button"] {
|
||||
background-color: var(--wood);
|
||||
color: var(--gold);
|
||||
border: 1px solid var(--gold);
|
||||
padding: 10px 15px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
button[type="button"]:hover {
|
||||
background-color: #4e342e;
|
||||
}
|
||||
|
||||
/* Bouton Poubelle */
|
||||
.player-row button {
|
||||
background-color: var(--danger);
|
||||
color: white;
|
||||
border: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Bouton Démarrer (le gros bouton doré) */
|
||||
input[type="submit"] {
|
||||
width: 100%;
|
||||
background: linear-gradient(135deg, #d4af37 0%, #f9e27d 50%, #d4af37 100%);
|
||||
color: var(--wood);
|
||||
padding: 15px;
|
||||
font-size: 1.2rem;
|
||||
border-radius: 30px;
|
||||
margin-top: 20px;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
input[type="submit"]:hover {
|
||||
transform: scale(1.02);
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
/* Bouton Debug discret en bas */
|
||||
.btn-debug {
|
||||
background: transparent !important;
|
||||
color: rgba(255,255,255,0.3) !important;
|
||||
border: 1px dashed rgba(255,255,255,0.3) !important;
|
||||
width: 100%;
|
||||
margin-top: 30px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
position: absolute;
|
||||
top: 25px; /* Ajuste selon tes goûts */
|
||||
left: 35px; /* Aligné avec le bord du cadre */
|
||||
color: var(--gold);
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.3s, transform 0.2s;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.btn-back:hover {
|
||||
opacity: 1;
|
||||
transform: translateX(-5px); /* Petit effet de glissement vers la gauche */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --- Mode Mobile ---*/
|
||||
/* --- ADAPTATION MOBILE POUR LA CONFIGURATION --- */
|
||||
@media (max-width: 600px) {
|
||||
|
||||
body {
|
||||
padding: 10px; /* On réduit la marge extérieure */
|
||||
align-items: flex-start; /* On aligne en haut pour que le scroll soit naturel */
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20px; /* On réduit le padding interne (30px 50px -> 20px) */
|
||||
border-width: 8px; /* Bordure bois plus fine */
|
||||
border-radius: 30px; /* Moins arrondi pour gagner de la place */
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Le bouton "Retour" */
|
||||
.btn-back {
|
||||
position: relative; /* On le sort de l'absolute pour qu'il ne chevauche pas le titre */
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
margin-bottom: 15px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* 1. Ligne joueur : Le plus important ! */
|
||||
.player-row {
|
||||
flex-direction: column; /* On empile Nom et Poubelle verticalement */
|
||||
align-items: stretch;
|
||||
background: rgba(0,0,0,0.1);
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(212, 175, 55, 0.3);
|
||||
}
|
||||
|
||||
.player-row input {
|
||||
width: 100%; /* Le champ de nom prend toute la largeur */
|
||||
}
|
||||
|
||||
.player-row button {
|
||||
width: 100%; /* Le bouton supprimer devient une large barre rouge */
|
||||
padding: 12px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
/* 2. Inputs plus gros pour le tactile */
|
||||
input[type="number"],
|
||||
input[type="text"] {
|
||||
padding: 15px;
|
||||
font-size: 1.1rem; /* Évite le zoom auto sur iPhone */
|
||||
}
|
||||
|
||||
/* 3. Boutons d'action */
|
||||
button[type="button"] {
|
||||
width: 100%; /* "Ajouter un joueur" prend toute la largeur */
|
||||
padding: 15px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
padding: 18px;
|
||||
font-size: 1.1rem;
|
||||
border-radius: 15px; /* Un peu moins arrondi pour le look mobile */
|
||||
}
|
||||
|
||||
/* Infos de mise (les petits labels gris) */
|
||||
label.info {
|
||||
margin-left: 0;
|
||||
margin-top: -15px;
|
||||
margin-bottom: 15px;
|
||||
display: block;
|
||||
}
|
||||
/* config.css */
|
||||
:root {
|
||||
--poker-green: #0e5d32;
|
||||
--gold: #d4af37;
|
||||
--wood: #3e2723;
|
||||
--white: #ffffff;
|
||||
--danger: #b71c1c;
|
||||
}
|
||||
|
||||
label.info {
|
||||
font-size: 0.8rem;
|
||||
color: rgb(141, 141, 141);
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #121212;
|
||||
background-image: radial-gradient(circle, #1a1a1a 0%, #000000 100%);
|
||||
color: var(--white);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: var(--poker-green);
|
||||
padding: 30px 50px;
|
||||
border-radius: 60px;
|
||||
border: 12px solid var(--wood);
|
||||
box-shadow: 0 0 50px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.5);
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: var(--gold);
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
font-size: 1.8rem;
|
||||
margin-bottom: 30px;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
color: var(--gold);
|
||||
font-weight: bold;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
input[type="number"],
|
||||
input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
margin-bottom: 20px;
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
box-sizing: border-box; /* Pour que le padding ne dépasse pas */
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Style spécifique pour la ligne joueur */
|
||||
.player-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.player-row input {
|
||||
margin-bottom: 0; /* On annule la marge pour l'alignement */
|
||||
}
|
||||
|
||||
/* Boutons */
|
||||
button, input[type="submit"] {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
transition: all 0.2s;
|
||||
border: none;
|
||||
}
|
||||
|
||||
button[type="button"] {
|
||||
background-color: var(--wood);
|
||||
color: var(--gold);
|
||||
border: 1px solid var(--gold);
|
||||
padding: 10px 15px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
button[type="button"]:hover {
|
||||
background-color: #4e342e;
|
||||
}
|
||||
|
||||
/* Bouton Poubelle */
|
||||
.player-row button {
|
||||
background-color: var(--danger);
|
||||
color: white;
|
||||
border: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Bouton Démarrer (le gros bouton doré) */
|
||||
input[type="submit"] {
|
||||
width: 100%;
|
||||
background: linear-gradient(135deg, #d4af37 0%, #f9e27d 50%, #d4af37 100%);
|
||||
color: var(--wood);
|
||||
padding: 15px;
|
||||
font-size: 1.2rem;
|
||||
border-radius: 30px;
|
||||
margin-top: 20px;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
input[type="submit"]:hover {
|
||||
transform: scale(1.02);
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
/* Bouton Debug discret en bas */
|
||||
.btn-debug {
|
||||
background: transparent !important;
|
||||
color: rgba(255,255,255,0.3) !important;
|
||||
border: 1px dashed rgba(255,255,255,0.3) !important;
|
||||
width: 100%;
|
||||
margin-top: 30px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
position: absolute;
|
||||
top: 25px; /* Ajuste selon tes goûts */
|
||||
left: 35px; /* Aligné avec le bord du cadre */
|
||||
color: var(--gold);
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.3s, transform 0.2s;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.btn-back:hover {
|
||||
opacity: 1;
|
||||
transform: translateX(-5px); /* Petit effet de glissement vers la gauche */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --- Mode Mobile ---*/
|
||||
/* --- ADAPTATION MOBILE POUR LA CONFIGURATION --- */
|
||||
@media (max-width: 600px) {
|
||||
|
||||
body {
|
||||
padding: 10px; /* On réduit la marge extérieure */
|
||||
align-items: flex-start; /* On aligne en haut pour que le scroll soit naturel */
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20px; /* On réduit le padding interne (30px 50px -> 20px) */
|
||||
border-width: 8px; /* Bordure bois plus fine */
|
||||
border-radius: 30px; /* Moins arrondi pour gagner de la place */
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Le bouton "Retour" */
|
||||
.btn-back {
|
||||
position: relative; /* On le sort de l'absolute pour qu'il ne chevauche pas le titre */
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
margin-bottom: 15px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* 1. Ligne joueur : Le plus important ! */
|
||||
.player-row {
|
||||
flex-direction: column; /* On empile Nom et Poubelle verticalement */
|
||||
align-items: stretch;
|
||||
background: rgba(0,0,0,0.1);
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(212, 175, 55, 0.3);
|
||||
}
|
||||
|
||||
.player-row input {
|
||||
width: 100%; /* Le champ de nom prend toute la largeur */
|
||||
}
|
||||
|
||||
.player-row button {
|
||||
width: 100%; /* Le bouton supprimer devient une large barre rouge */
|
||||
padding: 12px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
/* 2. Inputs plus gros pour le tactile */
|
||||
input[type="number"],
|
||||
input[type="text"] {
|
||||
padding: 15px;
|
||||
font-size: 1.1rem; /* Évite le zoom auto sur iPhone */
|
||||
}
|
||||
|
||||
/* 3. Boutons d'action */
|
||||
button[type="button"] {
|
||||
width: 100%; /* "Ajouter un joueur" prend toute la largeur */
|
||||
padding: 15px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
padding: 18px;
|
||||
font-size: 1.1rem;
|
||||
border-radius: 15px; /* Un peu moins arrondi pour le look mobile */
|
||||
}
|
||||
|
||||
/* Infos de mise (les petits labels gris) */
|
||||
label.info {
|
||||
margin-left: 0;
|
||||
margin-top: -15px;
|
||||
margin-bottom: 15px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
+92
-92
@@ -1,93 +1,93 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Configuration Poker</title>
|
||||
<style>
|
||||
.player-row { margin-bottom: 10px; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="config.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<button onclick="window.location.href='index.php'" class="btn-back">⬅ Accueil</button>
|
||||
<h1>Configuration de la partie</h1>
|
||||
|
||||
<form action="start_game.php" method="post">
|
||||
<label>Somme de départ :</label>
|
||||
<input type="number" name="start_money" value="1000" required><br><br>
|
||||
|
||||
<label>Blind :</label>
|
||||
<input type="number" name="blind" value="20" required><br><br>
|
||||
|
||||
<label>Joueurs :</label>
|
||||
<label class="info">(Maximum 8 joueurs)</label><br>
|
||||
<div id="players_container">
|
||||
<div class="player-row">
|
||||
<p>1</p><input type="text" name="players[]" placeholder="Nom du joueur" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<button type="button" onclick="addPlayer()">➕ Ajouter un joueur</button>
|
||||
<br>
|
||||
|
||||
<input type="submit" value="Démarrer la partie">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function addPlayer() {
|
||||
// 1. On récupère le conteneur
|
||||
const container = document.getElementById('players_container');
|
||||
|
||||
// 2. On crée une nouvelle ligne
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'player-row';
|
||||
|
||||
|
||||
// 3. On met le HTML dedans (avec le bouton supprimer intégré)
|
||||
newRow.innerHTML = `
|
||||
<p>${container.children.length + 1}</p>
|
||||
<input type="text" name="players[]" placeholder="Nom du joueur" required>
|
||||
<button type="button" onclick="removePlayer(this)">🗑️</button>
|
||||
`;
|
||||
|
||||
// 4. On l'ajoute au conteneur
|
||||
container.appendChild(newRow);
|
||||
}
|
||||
|
||||
function removePlayer(btn) {
|
||||
// On supprime le parent du bouton (la div 'player-row')
|
||||
btn.parentElement.remove();
|
||||
}
|
||||
|
||||
function deleteGame(idPartie) {
|
||||
if (confirm("Êtes-vous sûr de vouloir supprimer cette partie ? Tous les joueurs associés seront effacés.")) {
|
||||
|
||||
// On prépare les données à envoyer
|
||||
let formData = new FormData();
|
||||
formData.append('game_id', idPartie);
|
||||
|
||||
fetch('delete_game.php', {
|
||||
method: 'POST',
|
||||
body: formData // On envoie l'ID au PHP
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
alert(data);
|
||||
// Au lieu de reload, on peut rediriger vers l'accueil
|
||||
window.location.href = 'index.php';
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erreur:', error);
|
||||
alert('Impossible de supprimer la partie.');
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Configuration Poker</title>
|
||||
<style>
|
||||
.player-row { margin-bottom: 10px; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="config.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<button onclick="window.location.href='index.php'" class="btn-back">⬅ Accueil</button>
|
||||
<h1>Configuration de la partie</h1>
|
||||
|
||||
<form action="start_game.php" method="post">
|
||||
<label>Somme de départ :</label>
|
||||
<input type="number" name="start_money" value="1000" required><br><br>
|
||||
|
||||
<label>Blind :</label>
|
||||
<input type="number" name="blind" value="20" required><br><br>
|
||||
|
||||
<label>Joueurs :</label>
|
||||
<label class="info">(Maximum 8 joueurs)</label><br>
|
||||
<div id="players_container">
|
||||
<div class="player-row">
|
||||
<p>1</p><input type="text" name="players[]" placeholder="Nom du joueur" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<button type="button" onclick="addPlayer()">➕ Ajouter un joueur</button>
|
||||
<br>
|
||||
|
||||
<input type="submit" value="Démarrer la partie">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function addPlayer() {
|
||||
// 1. On récupère le conteneur
|
||||
const container = document.getElementById('players_container');
|
||||
|
||||
// 2. On crée une nouvelle ligne
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'player-row';
|
||||
|
||||
|
||||
// 3. On met le HTML dedans (avec le bouton supprimer intégré)
|
||||
newRow.innerHTML = `
|
||||
<p>${container.children.length + 1}</p>
|
||||
<input type="text" name="players[]" placeholder="Nom du joueur" required>
|
||||
<button type="button" onclick="removePlayer(this)">🗑️</button>
|
||||
`;
|
||||
|
||||
// 4. On l'ajoute au conteneur
|
||||
container.appendChild(newRow);
|
||||
}
|
||||
|
||||
function removePlayer(btn) {
|
||||
// On supprime le parent du bouton (la div 'player-row')
|
||||
btn.parentElement.remove();
|
||||
}
|
||||
|
||||
function deleteGame(idPartie) {
|
||||
if (confirm("Êtes-vous sûr de vouloir supprimer cette partie ? Tous les joueurs associés seront effacés.")) {
|
||||
|
||||
// On prépare les données à envoyer
|
||||
let formData = new FormData();
|
||||
formData.append('game_id', idPartie);
|
||||
|
||||
fetch('delete_game.php', {
|
||||
method: 'POST',
|
||||
body: formData // On envoie l'ID au PHP
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
alert(data);
|
||||
// Au lieu de reload, on peut rediriger vers l'accueil
|
||||
window.location.href = 'index.php';
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erreur:', error);
|
||||
alert('Impossible de supprimer la partie.');
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+13
-13
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
// db.php
|
||||
$host = 'localhost';
|
||||
$username = 'root';
|
||||
$password = '';
|
||||
$database = 'poker_paf';
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8", $username, $password);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Erreur de connexion : " . $e->getMessage());
|
||||
}
|
||||
<?php
|
||||
// db.php
|
||||
$host = 'localhost';
|
||||
$username = 'root';
|
||||
$password = '';
|
||||
$database = 'poker_paf';
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8", $username, $password);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Erreur de connexion : " . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
@@ -1,63 +1,63 @@
|
||||
<?php
|
||||
// Désactiver l'affichage des erreurs en sortie pour ne pas polluer le JSON
|
||||
error_reporting(0);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = isset($_POST['game_id']) ? intval($_POST['game_id']) : 0;
|
||||
$winner_id = isset($_POST['winner_id']) ? intval($_POST['winner_id']) : 0;
|
||||
|
||||
try {
|
||||
if ($game_id === 0 || $winner_id === 0) {
|
||||
throw new Exception("ID de partie ou de joueur invalide.");
|
||||
}
|
||||
|
||||
// 1. On récupère le pot de la table et le nom du gagnant
|
||||
$stmt = $db->prepare("SELECT pot FROM games WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
$game = $stmt->fetch();
|
||||
|
||||
$stmt = $db->prepare("SELECT name FROM players WHERE id = ?");
|
||||
$stmt->execute([$winner_id]);
|
||||
$player = $stmt->fetch();
|
||||
|
||||
if (!$game || !$player) {
|
||||
throw new Exception("Données introuvables en base.");
|
||||
}
|
||||
|
||||
$total_pot = intval($game['pot']);
|
||||
$winner_name = $player['name'];
|
||||
|
||||
// 2. On effectue les mises à jour
|
||||
$db->beginTransaction();
|
||||
|
||||
// Ajouter l'argent au gagnant
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + ? WHERE id = ?");
|
||||
$stmt->execute([$total_pot, $winner_id]);
|
||||
|
||||
// Vider le pot de la partie et reset la mise actuelle
|
||||
$stmt = $db->prepare("UPDATE games SET pot = 0, last_bet = 0 WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
// Reset les mises individuelles
|
||||
$stmt = $db->prepare("UPDATE players SET current_bet = 0 WHERE game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
$db->commit();
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'winner_name' => $winner_name,
|
||||
'amount_won' => $total_pot
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
if (isset($db) && $db->inTransaction()) $db->rollBack();
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
<?php
|
||||
// Désactiver l'affichage des erreurs en sortie pour ne pas polluer le JSON
|
||||
error_reporting(0);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = isset($_POST['game_id']) ? intval($_POST['game_id']) : 0;
|
||||
$winner_id = isset($_POST['winner_id']) ? intval($_POST['winner_id']) : 0;
|
||||
|
||||
try {
|
||||
if ($game_id === 0 || $winner_id === 0) {
|
||||
throw new Exception("ID de partie ou de joueur invalide.");
|
||||
}
|
||||
|
||||
// 1. On récupère le pot de la table et le nom du gagnant
|
||||
$stmt = $db->prepare("SELECT pot FROM games WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
$game = $stmt->fetch();
|
||||
|
||||
$stmt = $db->prepare("SELECT name FROM players WHERE id = ?");
|
||||
$stmt->execute([$winner_id]);
|
||||
$player = $stmt->fetch();
|
||||
|
||||
if (!$game || !$player) {
|
||||
throw new Exception("Données introuvables en base.");
|
||||
}
|
||||
|
||||
$total_pot = intval($game['pot']);
|
||||
$winner_name = $player['name'];
|
||||
|
||||
// 2. On effectue les mises à jour
|
||||
$db->beginTransaction();
|
||||
|
||||
// Ajouter l'argent au gagnant
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + ? WHERE id = ?");
|
||||
$stmt->execute([$total_pot, $winner_id]);
|
||||
|
||||
// Vider le pot de la partie et reset la mise actuelle
|
||||
$stmt = $db->prepare("UPDATE games SET pot = 0, last_bet = 0 WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
// Reset les mises individuelles
|
||||
$stmt = $db->prepare("UPDATE players SET current_bet = 0 WHERE game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
$db->commit();
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'winner_name' => $winner_name,
|
||||
'amount_won' => $total_pot
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
if (isset($db) && $db->inTransaction()) $db->rollBack();
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
exit;
|
||||
@@ -1,32 +1,32 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
session_start(); // Obligatoire si tu veux toucher aux sessions
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// 1. Récupérer l'ID envoyé par le JavaScript ($_POST)
|
||||
$game_id = isset($_POST['game_id']) ? intval($_POST['game_id']) : null;
|
||||
|
||||
if ($game_id) {
|
||||
try {
|
||||
// Supprimer les joueurs associés d'abord (intégrité BDD)
|
||||
$stmt = $db->prepare("DELETE FROM players WHERE game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
// Supprimer la partie
|
||||
$stmt = $db->prepare("DELETE FROM games WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
// Nettoyer la session si besoin
|
||||
if (isset($_SESSION['game_id']) && $_SESSION['game_id'] == $game_id) {
|
||||
unset($_SESSION['game_id']);
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'ID de partie manquant.']);
|
||||
}
|
||||
exit;
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
session_start(); // Obligatoire si tu veux toucher aux sessions
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// 1. Récupérer l'ID envoyé par le JavaScript ($_POST)
|
||||
$game_id = isset($_POST['game_id']) ? intval($_POST['game_id']) : null;
|
||||
|
||||
if ($game_id) {
|
||||
try {
|
||||
// Supprimer les joueurs associés d'abord (intégrité BDD)
|
||||
$stmt = $db->prepare("DELETE FROM players WHERE game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
// Supprimer la partie
|
||||
$stmt = $db->prepare("DELETE FROM games WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
// Nettoyer la session si besoin
|
||||
if (isset($_SESSION['game_id']) && $_SESSION['game_id'] == $game_id) {
|
||||
unset($_SESSION['game_id']);
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'ID de partie manquant.']);
|
||||
}
|
||||
exit;
|
||||
?>
|
||||
@@ -1,24 +1,24 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
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. Coucher le joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET is_folded = 1 WHERE id = ?");
|
||||
$stmt->execute([$current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
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. Coucher le joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET is_folded = 1 WHERE id = ?");
|
||||
$stmt->execute([$current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
?>
|
||||
+436
-436
@@ -1,437 +1,437 @@
|
||||
:root {
|
||||
--poker-green: #1a5e33;
|
||||
--poker-border: #3e2723;
|
||||
--gold: #d4af37;
|
||||
--dark-bg: #0a0a0a;
|
||||
--panel-bg: #1a1a1a;
|
||||
--white: #ffffff;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--dark-bg);
|
||||
color: var(--white);
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
margin: 0;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.game-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* 1. Barre de stats */
|
||||
.stats-bar {
|
||||
background: rgba(0,0,0,0.8);
|
||||
padding: 15px 30px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 2px solid var(--poker-border);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
font-size: 1.2rem;
|
||||
color: var(--gold);
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
color: var(--white);
|
||||
text-decoration: none;
|
||||
font-size: 0.9rem;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--poker-border);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* 2. Table de jeu */
|
||||
.table-container {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
padding: 60px; /* Espace pour les noms des joueurs */
|
||||
}
|
||||
|
||||
.poker-table {
|
||||
width: 800px;
|
||||
height: 400px;
|
||||
background-color: var(--poker-green);
|
||||
border: 15px solid var(--poker-border);
|
||||
border-radius: 200px;
|
||||
position: relative;
|
||||
box-shadow: inset 0 0 80px rgba(0,0,0,0.8), 0 10px 30px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.pot-area {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.total-pot {
|
||||
font-size: 3rem;
|
||||
font-weight: bold;
|
||||
color: var(--white);
|
||||
text-shadow: 2px 2px 10px rgba(0,0,0,0.8);
|
||||
}
|
||||
|
||||
.current-bet-display {
|
||||
font-size: 1.2rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* 3. Positionnement des joueurs (8 slots) */
|
||||
.player-slot {
|
||||
position: absolute;
|
||||
width: 140px;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.player-info {
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 12px;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.player-info.active {
|
||||
box-shadow: 0 0 25px var(--gold);
|
||||
transform: scale(1.1);
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.player-name {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--gold);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.player-money {
|
||||
font-size: 1.1rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Coordonnées autour de l'ovale */
|
||||
.slot-0 { top: -60px; left: 50%; transform: translateX(-50%); }
|
||||
.slot-1 { top: 0%; right: -110px; }
|
||||
.slot-2 { top: 50%; right: -150px; transform: translateY(-50%); }
|
||||
.slot-3 { bottom: 0%; right: -110px; }
|
||||
.slot-4 { bottom: -60px; left: 50%; transform: translateX(-50%); }
|
||||
.slot-5 { bottom: 0%; left: -110px; }
|
||||
.slot-6 { top: 50%; left: -150px; transform: translateY(-50%); }
|
||||
.slot-7 { top: 0%; left: -110px; }
|
||||
|
||||
/* 4. Panneau d'action */
|
||||
.action-panel {
|
||||
background: var(--panel-bg);
|
||||
border-top: 4px solid var(--gold);
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.turn-info {
|
||||
margin: 0 0 15px 0;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
transition: 0.2s;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.btn-fold { background: #444; color: white; }
|
||||
.btn-call { background: var(--poker-green); color: white; border: 1px solid var(--gold); }
|
||||
.btn-raise { background: #1e88e5; color: white; }
|
||||
.btn-allin {
|
||||
background: linear-gradient(45deg, #d4af37, #f9e27d);
|
||||
color: #3e2723;
|
||||
box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-5px);
|
||||
filter: brightness(1.2);
|
||||
}
|
||||
|
||||
/* --- Styles pour le bloc Augmenter --- */
|
||||
.raise-group {
|
||||
display: flex;
|
||||
align-items: stretch; /* Pour que l'input et le bouton aient la même hauteur */
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
#raise-amount {
|
||||
width: 100px;
|
||||
padding: 10px;
|
||||
border: 2px solid var(--gold);
|
||||
border-right: none; /* On retire la bordure droite pour coller au bouton */
|
||||
border-radius: 8px 0 0 8px; /* Arrondi seulement à gauche */
|
||||
background: #222;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.btn-validate {
|
||||
padding: 10px 15px;
|
||||
background: var(--gold);
|
||||
color: var(--poker-border);
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 0 8px 8px 0; /* Arrondi seulement à droite */
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.btn-validate:hover {
|
||||
background: #f9e27d;
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
/* Suppression des flèches par défaut de l'input number pour un look plus propre */
|
||||
#raise-amount::-webkit-inner-spin-button,
|
||||
#raise-amount::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.guide-overlay {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
border: 2px solid var(--gold);
|
||||
padding: 20px;
|
||||
border-radius: 15px;
|
||||
z-index: 1000;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
.guide-content h2 {
|
||||
margin: 0 0 15px 0;
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
#guide-btn {
|
||||
background: var(--gold);
|
||||
color: black;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.dealer-badge {
|
||||
position: absolute;
|
||||
top: -15px;
|
||||
right: -15px;
|
||||
background: linear-gradient(45deg, #ffd700, #b8860b);
|
||||
color: #000;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.5);
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
/* On peut aussi ajouter un effet d'ombre sur le joueur qui commence */
|
||||
.player-info.is-dealer {
|
||||
border-color: #ffd700;
|
||||
}
|
||||
|
||||
.btn-next-round {
|
||||
margin-top: 15px;
|
||||
padding: 10px 20px;
|
||||
background: var(--gold);
|
||||
border: none;
|
||||
border-radius: 20px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
|
||||
transition: 0.3s;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.btn-next-round:hover {
|
||||
transform: scale(1.1);
|
||||
background: #fff;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
button.btn-back {
|
||||
background: transparent;
|
||||
border: 1px solid var(--gold);
|
||||
color: var(--gold);
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
font-size: 0.9rem;
|
||||
transition: background 0.3s, color 0.3s;
|
||||
}
|
||||
|
||||
.player-bet {
|
||||
font-size: 0.9rem;
|
||||
color: rgb(141, 141, 141);
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* --- Mode Mobile (pour les petits écrans) --- */
|
||||
/* --- ADAPTATION MOBILE --- */
|
||||
@media (max-width: 900px) {
|
||||
|
||||
/* 1. On permet au corps de défiler si besoin, mais on réduit les espaces */
|
||||
body {
|
||||
height: auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* 2. Barre de stats plus compacte */
|
||||
.stats-bar {
|
||||
padding: 10px;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* 3. LA TABLE : On la réduit pour qu'elle tienne en largeur */
|
||||
.table-container {
|
||||
padding: 40px 10px; /* Moins d'espace autour */
|
||||
min-height: 450px;
|
||||
}
|
||||
|
||||
.poker-table {
|
||||
width: 100%; /* Elle prend toute la largeur dispo */
|
||||
max-width: 350px; /* Mais pas trop non plus */
|
||||
height: 300px;
|
||||
border-width: 8px;
|
||||
border-radius: 100px; /* Plus arrondie pour le format portrait */
|
||||
}
|
||||
|
||||
.total-pot {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
|
||||
/* 4. POSITION DES JOUEURS : On resserre tout */
|
||||
.player-slot {
|
||||
width: 100px; /* Joueurs plus petits sur mobile */
|
||||
}
|
||||
|
||||
.player-name { font-size: 0.7rem; }
|
||||
.player-money { font-size: 0.9rem; }
|
||||
.player-bet { font-size: 0.7rem; }
|
||||
|
||||
/* Ajustement des positions pour que ça ne sorte pas de l'écran */
|
||||
.slot-0 { top: -45px; }
|
||||
.slot-1 { right: -20px; top: 10%; }
|
||||
.slot-2 { right: -40px; }
|
||||
.slot-3 { right: -20px; bottom: 10%; }
|
||||
.slot-4 { bottom: -45px; }
|
||||
.slot-5 { left: -20px; bottom: 10%; }
|
||||
.slot-6 { left: -40px; }
|
||||
.slot-7 { left: -20px; top: 10%; }
|
||||
|
||||
/* 5. PANNEAU D'ACTION : On empile les boutons */
|
||||
.action-panel {
|
||||
padding: 15px 10px;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr; /* 2 colonnes de boutons */
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 5px;
|
||||
min-width: 0; /* On laisse la grille gérer la largeur */
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
/* Le groupe de relance prend toute la largeur sur une ligne de la grille */
|
||||
.raise-group {
|
||||
grid-column: span 2;
|
||||
margin: 0;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#raise-amount {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.btn-allin {
|
||||
grid-column: span 2; /* Le tapis prend toute la largeur pour bien le voir */
|
||||
}
|
||||
|
||||
/* 6. Guide de bienvenue */
|
||||
.guide-overlay {
|
||||
width: 90%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
/* Optionnel : Pour les très petits écrans (iPhone SE, etc.) */
|
||||
@media (max-width: 380px) {
|
||||
.poker-table {
|
||||
height: 250px;
|
||||
}
|
||||
.player-slot {
|
||||
width: 85px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.win-panel {
|
||||
padding: 20px;
|
||||
width: 95%;
|
||||
}
|
||||
.win-panel h2 {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
:root {
|
||||
--poker-green: #1a5e33;
|
||||
--poker-border: #3e2723;
|
||||
--gold: #d4af37;
|
||||
--dark-bg: #0a0a0a;
|
||||
--panel-bg: #1a1a1a;
|
||||
--white: #ffffff;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--dark-bg);
|
||||
color: var(--white);
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
margin: 0;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.game-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* 1. Barre de stats */
|
||||
.stats-bar {
|
||||
background: rgba(0,0,0,0.8);
|
||||
padding: 15px 30px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 2px solid var(--poker-border);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
font-size: 1.2rem;
|
||||
color: var(--gold);
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
color: var(--white);
|
||||
text-decoration: none;
|
||||
font-size: 0.9rem;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--poker-border);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* 2. Table de jeu */
|
||||
.table-container {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
padding: 60px; /* Espace pour les noms des joueurs */
|
||||
}
|
||||
|
||||
.poker-table {
|
||||
width: 800px;
|
||||
height: 400px;
|
||||
background-color: var(--poker-green);
|
||||
border: 15px solid var(--poker-border);
|
||||
border-radius: 200px;
|
||||
position: relative;
|
||||
box-shadow: inset 0 0 80px rgba(0,0,0,0.8), 0 10px 30px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.pot-area {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.total-pot {
|
||||
font-size: 3rem;
|
||||
font-weight: bold;
|
||||
color: var(--white);
|
||||
text-shadow: 2px 2px 10px rgba(0,0,0,0.8);
|
||||
}
|
||||
|
||||
.current-bet-display {
|
||||
font-size: 1.2rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* 3. Positionnement des joueurs (8 slots) */
|
||||
.player-slot {
|
||||
position: absolute;
|
||||
width: 140px;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.player-info {
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 12px;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.player-info.active {
|
||||
box-shadow: 0 0 25px var(--gold);
|
||||
transform: scale(1.1);
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.player-name {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--gold);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.player-money {
|
||||
font-size: 1.1rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Coordonnées autour de l'ovale */
|
||||
.slot-0 { top: -60px; left: 50%; transform: translateX(-50%); }
|
||||
.slot-1 { top: 0%; right: -110px; }
|
||||
.slot-2 { top: 50%; right: -150px; transform: translateY(-50%); }
|
||||
.slot-3 { bottom: 0%; right: -110px; }
|
||||
.slot-4 { bottom: -60px; left: 50%; transform: translateX(-50%); }
|
||||
.slot-5 { bottom: 0%; left: -110px; }
|
||||
.slot-6 { top: 50%; left: -150px; transform: translateY(-50%); }
|
||||
.slot-7 { top: 0%; left: -110px; }
|
||||
|
||||
/* 4. Panneau d'action */
|
||||
.action-panel {
|
||||
background: var(--panel-bg);
|
||||
border-top: 4px solid var(--gold);
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.turn-info {
|
||||
margin: 0 0 15px 0;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
transition: 0.2s;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.btn-fold { background: #444; color: white; }
|
||||
.btn-call { background: var(--poker-green); color: white; border: 1px solid var(--gold); }
|
||||
.btn-raise { background: #1e88e5; color: white; }
|
||||
.btn-allin {
|
||||
background: linear-gradient(45deg, #d4af37, #f9e27d);
|
||||
color: #3e2723;
|
||||
box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-5px);
|
||||
filter: brightness(1.2);
|
||||
}
|
||||
|
||||
/* --- Styles pour le bloc Augmenter --- */
|
||||
.raise-group {
|
||||
display: flex;
|
||||
align-items: stretch; /* Pour que l'input et le bouton aient la même hauteur */
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
#raise-amount {
|
||||
width: 100px;
|
||||
padding: 10px;
|
||||
border: 2px solid var(--gold);
|
||||
border-right: none; /* On retire la bordure droite pour coller au bouton */
|
||||
border-radius: 8px 0 0 8px; /* Arrondi seulement à gauche */
|
||||
background: #222;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.btn-validate {
|
||||
padding: 10px 15px;
|
||||
background: var(--gold);
|
||||
color: var(--poker-border);
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 0 8px 8px 0; /* Arrondi seulement à droite */
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.btn-validate:hover {
|
||||
background: #f9e27d;
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
/* Suppression des flèches par défaut de l'input number pour un look plus propre */
|
||||
#raise-amount::-webkit-inner-spin-button,
|
||||
#raise-amount::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.guide-overlay {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
border: 2px solid var(--gold);
|
||||
padding: 20px;
|
||||
border-radius: 15px;
|
||||
z-index: 1000;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
.guide-content h2 {
|
||||
margin: 0 0 15px 0;
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
#guide-btn {
|
||||
background: var(--gold);
|
||||
color: black;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.dealer-badge {
|
||||
position: absolute;
|
||||
top: -15px;
|
||||
right: -15px;
|
||||
background: linear-gradient(45deg, #ffd700, #b8860b);
|
||||
color: #000;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.5);
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
/* On peut aussi ajouter un effet d'ombre sur le joueur qui commence */
|
||||
.player-info.is-dealer {
|
||||
border-color: #ffd700;
|
||||
}
|
||||
|
||||
.btn-next-round {
|
||||
margin-top: 15px;
|
||||
padding: 10px 20px;
|
||||
background: var(--gold);
|
||||
border: none;
|
||||
border-radius: 20px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
|
||||
transition: 0.3s;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.btn-next-round:hover {
|
||||
transform: scale(1.1);
|
||||
background: #fff;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
button.btn-back {
|
||||
background: transparent;
|
||||
border: 1px solid var(--gold);
|
||||
color: var(--gold);
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
font-size: 0.9rem;
|
||||
transition: background 0.3s, color 0.3s;
|
||||
}
|
||||
|
||||
.player-bet {
|
||||
font-size: 0.9rem;
|
||||
color: rgb(141, 141, 141);
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* --- Mode Mobile (pour les petits écrans) --- */
|
||||
/* --- ADAPTATION MOBILE --- */
|
||||
@media (max-width: 900px) {
|
||||
|
||||
/* 1. On permet au corps de défiler si besoin, mais on réduit les espaces */
|
||||
body {
|
||||
height: auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* 2. Barre de stats plus compacte */
|
||||
.stats-bar {
|
||||
padding: 10px;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* 3. LA TABLE : On la réduit pour qu'elle tienne en largeur */
|
||||
.table-container {
|
||||
padding: 40px 10px; /* Moins d'espace autour */
|
||||
min-height: 450px;
|
||||
}
|
||||
|
||||
.poker-table {
|
||||
width: 100%; /* Elle prend toute la largeur dispo */
|
||||
max-width: 350px; /* Mais pas trop non plus */
|
||||
height: 300px;
|
||||
border-width: 8px;
|
||||
border-radius: 100px; /* Plus arrondie pour le format portrait */
|
||||
}
|
||||
|
||||
.total-pot {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
|
||||
/* 4. POSITION DES JOUEURS : On resserre tout */
|
||||
.player-slot {
|
||||
width: 100px; /* Joueurs plus petits sur mobile */
|
||||
}
|
||||
|
||||
.player-name { font-size: 0.7rem; }
|
||||
.player-money { font-size: 0.9rem; }
|
||||
.player-bet { font-size: 0.7rem; }
|
||||
|
||||
/* Ajustement des positions pour que ça ne sorte pas de l'écran */
|
||||
.slot-0 { top: -45px; }
|
||||
.slot-1 { right: -20px; top: 10%; }
|
||||
.slot-2 { right: -40px; }
|
||||
.slot-3 { right: -20px; bottom: 10%; }
|
||||
.slot-4 { bottom: -45px; }
|
||||
.slot-5 { left: -20px; bottom: 10%; }
|
||||
.slot-6 { left: -40px; }
|
||||
.slot-7 { left: -20px; top: 10%; }
|
||||
|
||||
/* 5. PANNEAU D'ACTION : On empile les boutons */
|
||||
.action-panel {
|
||||
padding: 15px 10px;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr; /* 2 colonnes de boutons */
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 5px;
|
||||
min-width: 0; /* On laisse la grille gérer la largeur */
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
/* Le groupe de relance prend toute la largeur sur une ligne de la grille */
|
||||
.raise-group {
|
||||
grid-column: span 2;
|
||||
margin: 0;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#raise-amount {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.btn-allin {
|
||||
grid-column: span 2; /* Le tapis prend toute la largeur pour bien le voir */
|
||||
}
|
||||
|
||||
/* 6. Guide de bienvenue */
|
||||
.guide-overlay {
|
||||
width: 90%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
/* Optionnel : Pour les très petits écrans (iPhone SE, etc.) */
|
||||
@media (max-width: 380px) {
|
||||
.poker-table {
|
||||
height: 250px;
|
||||
}
|
||||
.player-slot {
|
||||
width: 85px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.win-panel {
|
||||
padding: 20px;
|
||||
width: 95%;
|
||||
}
|
||||
.win-panel h2 {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
}
|
||||
+312
-312
@@ -1,313 +1,313 @@
|
||||
const mysql = require('mysql2');
|
||||
const connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'poker_paf'
|
||||
});
|
||||
|
||||
let actualPlayerID = null; // Variable globale pour stocker l'ID du joueur actuel
|
||||
let actualGameID = null; // Variable globale pour stocker l'ID de la partie actuelle
|
||||
let playerChips = {}; // Objet pour stocker les jetons de chaque joueur
|
||||
let playerNames = {}; // Objet pour stocker les noms de chaque joueur
|
||||
let startBlind = 20; // Blinde de départ à prendre depuis la BDD
|
||||
let blinds = {}; // Objet pour stocker les blinds de chaque joueur
|
||||
// ############################################################################################################################
|
||||
let current_blind = 0; // Initialisation de la blinde actuelle en variable globale, mis à jour automatiquement
|
||||
|
||||
function changePlayer() { // Uniquement pour les tests, à remplacer par une fonction qui change de joueur dans la Boucle de jeu
|
||||
// Récupération du joueur actuel depuis la base de données
|
||||
connection.connect(err => {
|
||||
if (err) {
|
||||
console.error('Erreur de connexion : ' + err.stack);
|
||||
return;
|
||||
}
|
||||
console.log('Connecté à MySQL avec l\'ID ' + connection.threadId);
|
||||
});
|
||||
const sql = "SELECT current_player_id FROM games WHERE game_id = ?";
|
||||
const values = [actualGameID];
|
||||
connection.query(sql, values, (error, results) => {
|
||||
if (error) {
|
||||
console.error('Erreur lors de la récupération du joueur actuel : ' + error.stack);
|
||||
return;
|
||||
}
|
||||
if (results.length > 0) {
|
||||
actualPlayerID = results[0].current_player_id;
|
||||
console.log('Joueur actuel : ' + actualPlayerID);
|
||||
} else {
|
||||
console.log('Aucun résultat trouvé pour le joueur actuel.');
|
||||
}
|
||||
});
|
||||
|
||||
// Changement du joueur actuel dans la base de données (pour les tests)
|
||||
// On cherche le numéro d'ID du joueur suivant l'actuel qui a le même game_id
|
||||
const sql2 = "SELECT player_id FROM players WHERE game_id = ? AND player_id > ? ORDER BY player_id ASC LIMIT 1";
|
||||
const values2 = [actualGameID, actualPlayerID];
|
||||
connection.query(sql2, values2, (error, results) => {
|
||||
if (error) {
|
||||
console.error('Erreur lors de la récupération du joueur suivant : ' + error.stack);
|
||||
return;
|
||||
}
|
||||
if (results.length > 0) {
|
||||
const nextPlayerID = results[0].player_id;
|
||||
const sqlUpdate = "UPDATE games SET current_player_id = ? WHERE game_id = ?";
|
||||
const valuesUpdate = [nextPlayerID, actualGameID];
|
||||
connection.query(sqlUpdate, valuesUpdate, (error, results) => {
|
||||
if (error) {
|
||||
console.error('Erreur lors de la mise à jour du joueur actuel : ' + error.stack);
|
||||
return;
|
||||
}
|
||||
console.log('Joueur actuel mis à jour avec succès.');
|
||||
});
|
||||
} else {
|
||||
console.log('Aucun résultat trouvé pour le joueur suivant.');
|
||||
}
|
||||
});
|
||||
console.log('Changement de joueur : ' + player);
|
||||
}
|
||||
|
||||
function UpdateStatus() { // Fonction mettant à jour la blinde actuel en fonction des blinds de chaque joueur
|
||||
current_blind = Math.max(...Object.values(blinds));
|
||||
}
|
||||
|
||||
function UpdateLabels() { // Fonction pour mettre à jour les labels
|
||||
let pot = Object.values(blinds).reduce((a, b) => a + b, 0);
|
||||
let money_labels = {}
|
||||
for (key of Object.keys(money)) {
|
||||
money_labels[key] = money[key] - blinds[key];
|
||||
}
|
||||
for (const key of Object.keys(money_labels)) {
|
||||
const label = document.getElementById(`label-${key}`);
|
||||
if (label) {
|
||||
label.innerText = money_labels[key] + " 🪙";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SeCoucher() { // fonction pour se coucher, elle vérifie si le joueur est en jeu et si sa mise actuelle est inférieure a la blinde actuel, si c'est le cas, il se couche et est retiré de la liste des joueurs encore en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (current_blind > blinds[current_player] && player_list.includes(current_player)) { // Si le joueur est en jeu et que sa mise actuelle est inférieure a la blinde actuel, il se couche
|
||||
player_list.splice(player_list.indexOf(current_player), 1);
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
|
||||
function Suivre() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il suit
|
||||
UpdateStatus();
|
||||
if (current_blind > blinds[current_player] && money[current_player] >= current_blind) { // Si la blinde actuelle est supérieur a la sienne et qu'il est en capacité de la payer
|
||||
blinds[current_player] = current_blind;
|
||||
} else {
|
||||
Tapis();
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Relancer() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (+money_input.value >= Math.max(...Object.values(money))){
|
||||
Tapis();
|
||||
} else {
|
||||
if (money[current_player] > (current_blind) && +money_input.value <= money[current_player] - current_blind && +money_input.value > 0 && +money_input.value % (start_blind / 2) == 0) { // Si le joueur a assez d'argent pour suivre la blinde actuelle et relancer
|
||||
blinds[current_player] = current_blind + +money_input.value;
|
||||
}
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Tapis() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il fait tapis
|
||||
UpdateStatus();
|
||||
|
||||
if (money[current_player] < Math.max(...Object.values(money))) { // Si le joueur n'est pas le plus riche
|
||||
blinds[current_player] = money[current_player];
|
||||
|
||||
} else { // Si le joueur est le plus riche
|
||||
let temp_money = {...money};
|
||||
temp_money[current_player] = 0;
|
||||
let second_most_rich = Math.max(...Object.values(temp_money));
|
||||
|
||||
|
||||
blinds[current_player] = second_most_rich;
|
||||
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fonction pour mettre à jour les jetons (Chips)
|
||||
function updateChips(playerId, amount, btnElement) {
|
||||
// 1. MISE À JOUR VISUELLE IMMÉDIATE (Optimiste)
|
||||
const playerCard = btnElement.closest('.player-card');
|
||||
const chipsDisplay = playerCard.querySelector('.player-chips');
|
||||
|
||||
// On sauvegarde l'ancienne valeur au cas où le serveur plante
|
||||
const oldChipsValue = chipsDisplay.innerText;
|
||||
let currentChips = parseInt(oldChipsValue);
|
||||
let newChips = currentChips + amount;
|
||||
|
||||
// On change l'affichage tout de suite
|
||||
chipsDisplay.innerHTML = newChips + " 🪙";
|
||||
|
||||
// 2. ENVOI À LA BASE DE DONNÉES
|
||||
const formData = new FormData();
|
||||
formData.append('player_id', playerId);
|
||||
formData.append('amount', amount);
|
||||
|
||||
fetch('update_chips.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.text()) // On récupère en texte pour débugger
|
||||
.then(text => {
|
||||
try {
|
||||
const data = JSON.parse(text);
|
||||
if (!data.success) {
|
||||
throw new Error(data.message);
|
||||
}
|
||||
console.log("Sync DB OK pour joueur " + playerId);
|
||||
} catch (e) {
|
||||
// 3. ANNULATION SI ERREUR
|
||||
console.error("Erreur serveur, retour à l'ancien solde. Réponse reçue :", text);
|
||||
chipsDisplay.innerHTML = oldChipsValue;
|
||||
alert("Erreur de synchronisation : " + text);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
chipsDisplay.innerHTML = oldChipsValue;
|
||||
console.error('Erreur réseau :', error);
|
||||
});
|
||||
}
|
||||
|
||||
let currentStep = 0;
|
||||
const steps = [
|
||||
{ text: "Mélangez et distribuez les cartes (2 par joueur)", btn: "C'est fait !" },
|
||||
{ text: "Au tour de J1 : Posez la Petite Blind", btn: "OK" },
|
||||
{ text: "Au tour de J2 : Posez la Grosse Blind", btn: "OK" },
|
||||
{ text: "Place au jeu ! Suivez les tours en bas.", btn: "Masquer le guide" }
|
||||
];
|
||||
|
||||
function nextStep() {
|
||||
const guideBox = document.getElementById('game-guide');
|
||||
const textZone = document.getElementById('guide-text');
|
||||
const btnZone = document.getElementById('guide-btn');
|
||||
|
||||
if (currentStep < steps.length) {
|
||||
textZone.innerText = steps[currentStep].text;
|
||||
btnZone.innerText = steps[currentStep].btn;
|
||||
currentStep++;
|
||||
} else {
|
||||
// Une fois fini, on cache le guide ou on le réduit
|
||||
guideBox.style.display = 'none';
|
||||
// Ici, on pourrait activer les boutons d'action (Suivre, Miser...)
|
||||
enableActions(true);
|
||||
}
|
||||
}
|
||||
|
||||
function enableActions(status) {
|
||||
const btns = document.querySelectorAll('.btn-action, .btn-gold, .btn-validate');
|
||||
btns.forEach(b => b.disabled = !status);
|
||||
if(!status) {
|
||||
document.querySelector('.action-panel').style.opacity = "0.5";
|
||||
} else {
|
||||
document.querySelector('.action-panel').style.opacity = "1";
|
||||
}
|
||||
}
|
||||
|
||||
// Au chargement, on bloque les actions tant que le guide n'est pas fini
|
||||
window.onload = () => enableActions(false);
|
||||
|
||||
// Ta fonction deleteGame déjà existante (rappel)
|
||||
function deleteGame(idPartie) {
|
||||
if (confirm("Supprimer la partie ?")) {
|
||||
let formData = new FormData();
|
||||
formData.append('game_id', idPartie);
|
||||
|
||||
fetch('delete_game.php', { method: 'POST', body: formData })
|
||||
.then(() => window.location.href = 'index.php');
|
||||
}
|
||||
}
|
||||
|
||||
function playerAction(type) {
|
||||
const raiseInput = document.getElementById('raise-amount');
|
||||
let amount = (type === 'raise') ? raiseInput.value : 0;
|
||||
const gameId = new URLSearchParams(window.location.search).get('game_id');
|
||||
|
||||
// On prépare les données pour le PHP
|
||||
let fd = new FormData();
|
||||
fd.append('action', type);
|
||||
fd.append('amount', amount);
|
||||
fd.append('game_id', gameId);
|
||||
|
||||
fetch('play_action.php', { method: 'POST', body: fd })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// --- ÉTAPE 1 : Gérer le Halo (Tu m'as dit que ça c'est OK) ---
|
||||
document.querySelectorAll('.player-info').forEach(p => p.classList.remove('active'));
|
||||
|
||||
// On trouve la "carte" du nouveau joueur grâce à son ID
|
||||
const nextPlayerSlot = document.querySelector(`[data-id="${data.next_player_id}"]`);
|
||||
const nextInfoBox = nextPlayerSlot.querySelector('.player-info');
|
||||
nextInfoBox.classList.add('active');
|
||||
|
||||
// --- ÉTAPE 2 : Mettre à jour le NOM en bas (C'est ça qui te manque) ---
|
||||
// On récupère le texte du nom à l'intérieur de la carte du nouveau joueur
|
||||
const nextNameRaw = nextInfoBox.querySelector('.player-name').innerText;
|
||||
// On nettoie un peu le texte (pour enlever le "J1 :" par exemple)
|
||||
const cleanName = nextNameRaw.split(':').pop().trim();
|
||||
|
||||
// On l'injecte dans le texte "Au tour de : ..."
|
||||
document.getElementById('active-player-name').innerText = cleanName;
|
||||
|
||||
// --- ÉTAPE 3 : Mettre à jour le POT et vider l'input ---
|
||||
if(data.new_pot) document.getElementById('main-pot').innerText = data.new_pot;
|
||||
if(raiseInput) raiseInput.value = "";
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Erreur action:", err));
|
||||
}
|
||||
|
||||
function startNewRound() {
|
||||
// Récupère l'ID dans l'URL (?game_id=4)
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const gId = urlParams.get('game_id');
|
||||
|
||||
if (!gId) return alert("ID de partie manquant dans l'URL !");
|
||||
|
||||
let fd = new FormData();
|
||||
fd.append('game_id', gId);
|
||||
|
||||
fetch('next_round.php', {
|
||||
method: 'POST',
|
||||
body: fd
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
location.reload(); // On recharge pour voir le nouveau Dealer
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Erreur bouton :", err));
|
||||
}
|
||||
|
||||
function closeTable() {
|
||||
if (confirm("Fermer la table ?")) {
|
||||
// Supprimer la partie et les joueurs associés à la partie dans la db
|
||||
const gameId = new URLSearchParams(window.location.search).get('game_id');
|
||||
fetch('delete_game.php', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({'game_id': gameId})
|
||||
})
|
||||
.then(() => window.location.href = 'index.php');
|
||||
}
|
||||
const mysql = require('mysql2');
|
||||
const connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'poker_paf'
|
||||
});
|
||||
|
||||
let actualPlayerID = null; // Variable globale pour stocker l'ID du joueur actuel
|
||||
let actualGameID = null; // Variable globale pour stocker l'ID de la partie actuelle
|
||||
let playerChips = {}; // Objet pour stocker les jetons de chaque joueur
|
||||
let playerNames = {}; // Objet pour stocker les noms de chaque joueur
|
||||
let startBlind = 20; // Blinde de départ à prendre depuis la BDD
|
||||
let blinds = {}; // Objet pour stocker les blinds de chaque joueur
|
||||
// ############################################################################################################################
|
||||
let current_blind = 0; // Initialisation de la blinde actuelle en variable globale, mis à jour automatiquement
|
||||
|
||||
function changePlayer() { // Uniquement pour les tests, à remplacer par une fonction qui change de joueur dans la Boucle de jeu
|
||||
// Récupération du joueur actuel depuis la base de données
|
||||
connection.connect(err => {
|
||||
if (err) {
|
||||
console.error('Erreur de connexion : ' + err.stack);
|
||||
return;
|
||||
}
|
||||
console.log('Connecté à MySQL avec l\'ID ' + connection.threadId);
|
||||
});
|
||||
const sql = "SELECT current_player_id FROM games WHERE game_id = ?";
|
||||
const values = [actualGameID];
|
||||
connection.query(sql, values, (error, results) => {
|
||||
if (error) {
|
||||
console.error('Erreur lors de la récupération du joueur actuel : ' + error.stack);
|
||||
return;
|
||||
}
|
||||
if (results.length > 0) {
|
||||
actualPlayerID = results[0].current_player_id;
|
||||
console.log('Joueur actuel : ' + actualPlayerID);
|
||||
} else {
|
||||
console.log('Aucun résultat trouvé pour le joueur actuel.');
|
||||
}
|
||||
});
|
||||
|
||||
// Changement du joueur actuel dans la base de données (pour les tests)
|
||||
// On cherche le numéro d'ID du joueur suivant l'actuel qui a le même game_id
|
||||
const sql2 = "SELECT player_id FROM players WHERE game_id = ? AND player_id > ? ORDER BY player_id ASC LIMIT 1";
|
||||
const values2 = [actualGameID, actualPlayerID];
|
||||
connection.query(sql2, values2, (error, results) => {
|
||||
if (error) {
|
||||
console.error('Erreur lors de la récupération du joueur suivant : ' + error.stack);
|
||||
return;
|
||||
}
|
||||
if (results.length > 0) {
|
||||
const nextPlayerID = results[0].player_id;
|
||||
const sqlUpdate = "UPDATE games SET current_player_id = ? WHERE game_id = ?";
|
||||
const valuesUpdate = [nextPlayerID, actualGameID];
|
||||
connection.query(sqlUpdate, valuesUpdate, (error, results) => {
|
||||
if (error) {
|
||||
console.error('Erreur lors de la mise à jour du joueur actuel : ' + error.stack);
|
||||
return;
|
||||
}
|
||||
console.log('Joueur actuel mis à jour avec succès.');
|
||||
});
|
||||
} else {
|
||||
console.log('Aucun résultat trouvé pour le joueur suivant.');
|
||||
}
|
||||
});
|
||||
console.log('Changement de joueur : ' + player);
|
||||
}
|
||||
|
||||
function UpdateStatus() { // Fonction mettant à jour la blinde actuel en fonction des blinds de chaque joueur
|
||||
current_blind = Math.max(...Object.values(blinds));
|
||||
}
|
||||
|
||||
function UpdateLabels() { // Fonction pour mettre à jour les labels
|
||||
let pot = Object.values(blinds).reduce((a, b) => a + b, 0);
|
||||
let money_labels = {}
|
||||
for (key of Object.keys(money)) {
|
||||
money_labels[key] = money[key] - blinds[key];
|
||||
}
|
||||
for (const key of Object.keys(money_labels)) {
|
||||
const label = document.getElementById(`label-${key}`);
|
||||
if (label) {
|
||||
label.innerText = money_labels[key] + " 🪙";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SeCoucher() { // fonction pour se coucher, elle vérifie si le joueur est en jeu et si sa mise actuelle est inférieure a la blinde actuel, si c'est le cas, il se couche et est retiré de la liste des joueurs encore en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (current_blind > blinds[current_player] && player_list.includes(current_player)) { // Si le joueur est en jeu et que sa mise actuelle est inférieure a la blinde actuel, il se couche
|
||||
player_list.splice(player_list.indexOf(current_player), 1);
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
|
||||
function Suivre() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il suit
|
||||
UpdateStatus();
|
||||
if (current_blind > blinds[current_player] && money[current_player] >= current_blind) { // Si la blinde actuelle est supérieur a la sienne et qu'il est en capacité de la payer
|
||||
blinds[current_player] = current_blind;
|
||||
} else {
|
||||
Tapis();
|
||||
}
|
||||
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Relancer() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu
|
||||
UpdateStatus();
|
||||
|
||||
if (+money_input.value >= Math.max(...Object.values(money))){
|
||||
Tapis();
|
||||
} else {
|
||||
if (money[current_player] > (current_blind) && +money_input.value <= money[current_player] - current_blind && +money_input.value > 0 && +money_input.value % (start_blind / 2) == 0) { // Si le joueur a assez d'argent pour suivre la blinde actuelle et relancer
|
||||
blinds[current_player] = current_blind + +money_input.value;
|
||||
}
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
function Tapis() {
|
||||
if (player_list.includes(current_player)) { // Si le joueur est en jeu, il fait tapis
|
||||
UpdateStatus();
|
||||
|
||||
if (money[current_player] < Math.max(...Object.values(money))) { // Si le joueur n'est pas le plus riche
|
||||
blinds[current_player] = money[current_player];
|
||||
|
||||
} else { // Si le joueur est le plus riche
|
||||
let temp_money = {...money};
|
||||
temp_money[current_player] = 0;
|
||||
let second_most_rich = Math.max(...Object.values(temp_money));
|
||||
|
||||
|
||||
blinds[current_player] = second_most_rich;
|
||||
|
||||
}
|
||||
UpdateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fonction pour mettre à jour les jetons (Chips)
|
||||
function updateChips(playerId, amount, btnElement) {
|
||||
// 1. MISE À JOUR VISUELLE IMMÉDIATE (Optimiste)
|
||||
const playerCard = btnElement.closest('.player-card');
|
||||
const chipsDisplay = playerCard.querySelector('.player-chips');
|
||||
|
||||
// On sauvegarde l'ancienne valeur au cas où le serveur plante
|
||||
const oldChipsValue = chipsDisplay.innerText;
|
||||
let currentChips = parseInt(oldChipsValue);
|
||||
let newChips = currentChips + amount;
|
||||
|
||||
// On change l'affichage tout de suite
|
||||
chipsDisplay.innerHTML = newChips + " 🪙";
|
||||
|
||||
// 2. ENVOI À LA BASE DE DONNÉES
|
||||
const formData = new FormData();
|
||||
formData.append('player_id', playerId);
|
||||
formData.append('amount', amount);
|
||||
|
||||
fetch('update_chips.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.text()) // On récupère en texte pour débugger
|
||||
.then(text => {
|
||||
try {
|
||||
const data = JSON.parse(text);
|
||||
if (!data.success) {
|
||||
throw new Error(data.message);
|
||||
}
|
||||
console.log("Sync DB OK pour joueur " + playerId);
|
||||
} catch (e) {
|
||||
// 3. ANNULATION SI ERREUR
|
||||
console.error("Erreur serveur, retour à l'ancien solde. Réponse reçue :", text);
|
||||
chipsDisplay.innerHTML = oldChipsValue;
|
||||
alert("Erreur de synchronisation : " + text);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
chipsDisplay.innerHTML = oldChipsValue;
|
||||
console.error('Erreur réseau :', error);
|
||||
});
|
||||
}
|
||||
|
||||
let currentStep = 0;
|
||||
const steps = [
|
||||
{ text: "Mélangez et distribuez les cartes (2 par joueur)", btn: "C'est fait !" },
|
||||
{ text: "Au tour de J1 : Posez la Petite Blind", btn: "OK" },
|
||||
{ text: "Au tour de J2 : Posez la Grosse Blind", btn: "OK" },
|
||||
{ text: "Place au jeu ! Suivez les tours en bas.", btn: "Masquer le guide" }
|
||||
];
|
||||
|
||||
function nextStep() {
|
||||
const guideBox = document.getElementById('game-guide');
|
||||
const textZone = document.getElementById('guide-text');
|
||||
const btnZone = document.getElementById('guide-btn');
|
||||
|
||||
if (currentStep < steps.length) {
|
||||
textZone.innerText = steps[currentStep].text;
|
||||
btnZone.innerText = steps[currentStep].btn;
|
||||
currentStep++;
|
||||
} else {
|
||||
// Une fois fini, on cache le guide ou on le réduit
|
||||
guideBox.style.display = 'none';
|
||||
// Ici, on pourrait activer les boutons d'action (Suivre, Miser...)
|
||||
enableActions(true);
|
||||
}
|
||||
}
|
||||
|
||||
function enableActions(status) {
|
||||
const btns = document.querySelectorAll('.btn-action, .btn-gold, .btn-validate');
|
||||
btns.forEach(b => b.disabled = !status);
|
||||
if(!status) {
|
||||
document.querySelector('.action-panel').style.opacity = "0.5";
|
||||
} else {
|
||||
document.querySelector('.action-panel').style.opacity = "1";
|
||||
}
|
||||
}
|
||||
|
||||
// Au chargement, on bloque les actions tant que le guide n'est pas fini
|
||||
window.onload = () => enableActions(false);
|
||||
|
||||
// Ta fonction deleteGame déjà existante (rappel)
|
||||
function deleteGame(idPartie) {
|
||||
if (confirm("Supprimer la partie ?")) {
|
||||
let formData = new FormData();
|
||||
formData.append('game_id', idPartie);
|
||||
|
||||
fetch('delete_game.php', { method: 'POST', body: formData })
|
||||
.then(() => window.location.href = 'index.php');
|
||||
}
|
||||
}
|
||||
|
||||
function playerAction(type) {
|
||||
const raiseInput = document.getElementById('raise-amount');
|
||||
let amount = (type === 'raise') ? raiseInput.value : 0;
|
||||
const gameId = new URLSearchParams(window.location.search).get('game_id');
|
||||
|
||||
// On prépare les données pour le PHP
|
||||
let fd = new FormData();
|
||||
fd.append('action', type);
|
||||
fd.append('amount', amount);
|
||||
fd.append('game_id', gameId);
|
||||
|
||||
fetch('play_action.php', { method: 'POST', body: fd })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// --- ÉTAPE 1 : Gérer le Halo (Tu m'as dit que ça c'est OK) ---
|
||||
document.querySelectorAll('.player-info').forEach(p => p.classList.remove('active'));
|
||||
|
||||
// On trouve la "carte" du nouveau joueur grâce à son ID
|
||||
const nextPlayerSlot = document.querySelector(`[data-id="${data.next_player_id}"]`);
|
||||
const nextInfoBox = nextPlayerSlot.querySelector('.player-info');
|
||||
nextInfoBox.classList.add('active');
|
||||
|
||||
// --- ÉTAPE 2 : Mettre à jour le NOM en bas (C'est ça qui te manque) ---
|
||||
// On récupère le texte du nom à l'intérieur de la carte du nouveau joueur
|
||||
const nextNameRaw = nextInfoBox.querySelector('.player-name').innerText;
|
||||
// On nettoie un peu le texte (pour enlever le "J1 :" par exemple)
|
||||
const cleanName = nextNameRaw.split(':').pop().trim();
|
||||
|
||||
// On l'injecte dans le texte "Au tour de : ..."
|
||||
document.getElementById('active-player-name').innerText = cleanName;
|
||||
|
||||
// --- ÉTAPE 3 : Mettre à jour le POT et vider l'input ---
|
||||
if(data.new_pot) document.getElementById('main-pot').innerText = data.new_pot;
|
||||
if(raiseInput) raiseInput.value = "";
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Erreur action:", err));
|
||||
}
|
||||
|
||||
function startNewRound() {
|
||||
// Récupère l'ID dans l'URL (?game_id=4)
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const gId = urlParams.get('game_id');
|
||||
|
||||
if (!gId) return alert("ID de partie manquant dans l'URL !");
|
||||
|
||||
let fd = new FormData();
|
||||
fd.append('game_id', gId);
|
||||
|
||||
fetch('next_round.php', {
|
||||
method: 'POST',
|
||||
body: fd
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
location.reload(); // On recharge pour voir le nouveau Dealer
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Erreur bouton :", err));
|
||||
}
|
||||
|
||||
function closeTable() {
|
||||
if (confirm("Fermer la table ?")) {
|
||||
// Supprimer la partie et les joueurs associés à la partie dans la db
|
||||
const gameId = new URLSearchParams(window.location.search).get('game_id');
|
||||
fetch('delete_game.php', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({'game_id': gameId})
|
||||
})
|
||||
.then(() => window.location.href = 'index.php');
|
||||
}
|
||||
}
|
||||
+636
-636
File diff suppressed because it is too large
Load Diff
@@ -1,19 +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()]);
|
||||
}
|
||||
<?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()]);
|
||||
}
|
||||
?>
|
||||
@@ -1,19 +1,19 @@
|
||||
<?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'];
|
||||
|
||||
echo json_encode(['success' => true, 'player_id' => $current_player_id]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
<?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'];
|
||||
|
||||
echo json_encode(['success' => true, 'player_id' => $current_player_id]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
@@ -1,25 +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()]);
|
||||
}
|
||||
<?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()]);
|
||||
}
|
||||
?>
|
||||
@@ -1,25 +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()]);
|
||||
}
|
||||
<?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()]);
|
||||
}
|
||||
?>
|
||||
@@ -1,19 +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()]);
|
||||
}
|
||||
<?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()]);
|
||||
}
|
||||
?>
|
||||
+181
-181
@@ -1,182 +1,182 @@
|
||||
/* index.css */
|
||||
:root {
|
||||
--poker-green: #0e5d32;
|
||||
--gold: #d4af37;
|
||||
--wood: #3e2723;
|
||||
--white: #ffffff;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #121212;
|
||||
background-image: radial-gradient(circle, #1a1a1a 0%, #000000 100%);
|
||||
color: var(--white);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.welcome-container {
|
||||
background-color: var(--poker-green);
|
||||
padding: 50px;
|
||||
border-radius: 80px;
|
||||
border: 15px solid var(--wood);
|
||||
box-shadow: 0 0 60px rgba(0,0,0,0.9), inset 0 0 30px rgba(0,0,0,0.5);
|
||||
text-align: center;
|
||||
width: 90%;
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: var(--gold);
|
||||
text-transform: uppercase;
|
||||
font-size: 2.2rem;
|
||||
margin-bottom: 40px;
|
||||
text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
|
||||
}
|
||||
|
||||
/* Style pour le lien "Démarrer une partie" */
|
||||
.btn-start {
|
||||
display: inline-block;
|
||||
background: linear-gradient(135deg, #d4af37 0%, #f9e27d 50%, #d4af37 100%);
|
||||
color: var(--wood);
|
||||
text-decoration: none;
|
||||
padding: 15px 30px;
|
||||
font-weight: bold;
|
||||
font-size: 1.2rem;
|
||||
border-radius: 40px;
|
||||
margin-bottom: 40px;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.btn-start:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
|
||||
}
|
||||
|
||||
/* Section rejoindre */
|
||||
.join-section {
|
||||
border-top: 1px solid rgba(255,255,255,0.2);
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
color: var(--gold);
|
||||
margin-bottom: 15px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 5px;
|
||||
padding: 12px;
|
||||
width: 60%;
|
||||
font-size: 1rem;
|
||||
margin-bottom: 15px;
|
||||
outline: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: var(--wood);
|
||||
color: var(--gold);
|
||||
border: 2px solid var(--gold);
|
||||
padding: 10px 20px;
|
||||
font-weight: bold;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #5d3a3a;
|
||||
}
|
||||
|
||||
.btn-join-list{
|
||||
background-color: transparent;
|
||||
color: var(--gold);
|
||||
padding-left: 12px;
|
||||
border: 1px solid var(--gold);
|
||||
padding: 8px 12px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn-join-list:hover {
|
||||
background-color: var(--gold);
|
||||
color: var(--wood);
|
||||
}
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --- Mode Mobile --- */
|
||||
/* --- ADAPTATION MOBILE POUR L'ACCUEIL --- */
|
||||
@media (max-width: 600px) {
|
||||
|
||||
body {
|
||||
/* On permet le scroll si le contenu est plus haut que l'écran */
|
||||
height: auto;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.welcome-container {
|
||||
/* On réduit les bordures massives et le padding */
|
||||
padding: 30px 20px;
|
||||
border-width: 8px; /* Bordure en bois moins épaisse */
|
||||
border-radius: 40px; /* Moins arrondi pour gagner de la place */
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.6rem; /* Titre plus petit */
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
/* Le bouton principal doit être bien large pour le pouce */
|
||||
.btn-start {
|
||||
width: 100%;
|
||||
box-sizing: border-box; /* Pour que le padding n'agrandisse pas la largeur */
|
||||
padding: 18px 20px;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
/* Section rejoindre */
|
||||
input[type="text"] {
|
||||
width: 100%; /* L'input prend toute la largeur */
|
||||
box-sizing: border-box;
|
||||
padding: 15px;
|
||||
font-size: 1.1rem; /* Évite le zoom auto de l'iPhone sur les inputs */
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%; /* Les boutons de validation passent en pleine largeur */
|
||||
padding: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* Pour la liste des parties */
|
||||
li {
|
||||
flex-direction: column; /* On empile le nom et le bouton */
|
||||
gap: 10px;
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.btn-join-list {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
/* index.css */
|
||||
:root {
|
||||
--poker-green: #0e5d32;
|
||||
--gold: #d4af37;
|
||||
--wood: #3e2723;
|
||||
--white: #ffffff;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #121212;
|
||||
background-image: radial-gradient(circle, #1a1a1a 0%, #000000 100%);
|
||||
color: var(--white);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.welcome-container {
|
||||
background-color: var(--poker-green);
|
||||
padding: 50px;
|
||||
border-radius: 80px;
|
||||
border: 15px solid var(--wood);
|
||||
box-shadow: 0 0 60px rgba(0,0,0,0.9), inset 0 0 30px rgba(0,0,0,0.5);
|
||||
text-align: center;
|
||||
width: 90%;
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: var(--gold);
|
||||
text-transform: uppercase;
|
||||
font-size: 2.2rem;
|
||||
margin-bottom: 40px;
|
||||
text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
|
||||
}
|
||||
|
||||
/* Style pour le lien "Démarrer une partie" */
|
||||
.btn-start {
|
||||
display: inline-block;
|
||||
background: linear-gradient(135deg, #d4af37 0%, #f9e27d 50%, #d4af37 100%);
|
||||
color: var(--wood);
|
||||
text-decoration: none;
|
||||
padding: 15px 30px;
|
||||
font-weight: bold;
|
||||
font-size: 1.2rem;
|
||||
border-radius: 40px;
|
||||
margin-bottom: 40px;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.btn-start:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
|
||||
}
|
||||
|
||||
/* Section rejoindre */
|
||||
.join-section {
|
||||
border-top: 1px solid rgba(255,255,255,0.2);
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
color: var(--gold);
|
||||
margin-bottom: 15px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border: 2px solid var(--gold);
|
||||
border-radius: 5px;
|
||||
padding: 12px;
|
||||
width: 60%;
|
||||
font-size: 1rem;
|
||||
margin-bottom: 15px;
|
||||
outline: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: var(--wood);
|
||||
color: var(--gold);
|
||||
border: 2px solid var(--gold);
|
||||
padding: 10px 20px;
|
||||
font-weight: bold;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #5d3a3a;
|
||||
}
|
||||
|
||||
.btn-join-list{
|
||||
background-color: transparent;
|
||||
color: var(--gold);
|
||||
padding-left: 12px;
|
||||
border: 1px solid var(--gold);
|
||||
padding: 8px 12px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn-join-list:hover {
|
||||
background-color: var(--gold);
|
||||
color: var(--wood);
|
||||
}
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --- Mode Mobile --- */
|
||||
/* --- ADAPTATION MOBILE POUR L'ACCUEIL --- */
|
||||
@media (max-width: 600px) {
|
||||
|
||||
body {
|
||||
/* On permet le scroll si le contenu est plus haut que l'écran */
|
||||
height: auto;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.welcome-container {
|
||||
/* On réduit les bordures massives et le padding */
|
||||
padding: 30px 20px;
|
||||
border-width: 8px; /* Bordure en bois moins épaisse */
|
||||
border-radius: 40px; /* Moins arrondi pour gagner de la place */
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.6rem; /* Titre plus petit */
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
/* Le bouton principal doit être bien large pour le pouce */
|
||||
.btn-start {
|
||||
width: 100%;
|
||||
box-sizing: border-box; /* Pour que le padding n'agrandisse pas la largeur */
|
||||
padding: 18px 20px;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
/* Section rejoindre */
|
||||
input[type="text"] {
|
||||
width: 100%; /* L'input prend toute la largeur */
|
||||
box-sizing: border-box;
|
||||
padding: 15px;
|
||||
font-size: 1.1rem; /* Évite le zoom auto de l'iPhone sur les inputs */
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%; /* Les boutons de validation passent en pleine largeur */
|
||||
padding: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* Pour la liste des parties */
|
||||
li {
|
||||
flex-direction: column; /* On empile le nom et le bouton */
|
||||
gap: 10px;
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.btn-join-list {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
+57
-57
@@ -1,58 +1,58 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
session_start();
|
||||
session_destroy(); // On détruit la session pour supprimer l'ID de la partie en cours
|
||||
|
||||
// Récupérer la liste des parties en cours
|
||||
$stmt = $db->query("SELECT id, start_money, start_blind FROM games ORDER BY id DESC");
|
||||
$games = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<title>Poker PAF</title>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='stylesheet' type='text/css' media='screen' href='index.css'>
|
||||
<script src='main.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="welcome-container">
|
||||
<h1>Welcome to Poker PAF</h1>
|
||||
<button onclick="window.location.href='config.php'">Créer une partie</button><br><br>
|
||||
|
||||
<label>Rejoindre une partie :</label><br>
|
||||
<input type="text" id="join_game_id" placeholder="ID de la partie">
|
||||
<button onclick="joinGame()">Rejoindre</button><br><br>
|
||||
<h2>Parties en cours :</h2>
|
||||
<div id="games_list">
|
||||
<?php if (count($games) > 0): ?>
|
||||
<ul>
|
||||
<?php foreach ($games as $game): ?>
|
||||
<li>
|
||||
ID: <?php echo $game['id']; ?> -
|
||||
Start Money: <?php echo $game['start_money']; ?> -
|
||||
Blind: <?php echo $game['start_blind']; ?>
|
||||
<button class="btn-join-list" onclick="window.location.href='game.php?game_id=<?php echo $game['id']; ?>'">Rejoindre</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<p>Aucune partie en cours.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function joinGame() {
|
||||
const gameId = document.getElementById('join_game_id').value;
|
||||
if (gameId) {
|
||||
// Rediriger vers une page de jeu avec l'ID en paramètre
|
||||
window.location.href = `game.php?game_id=${gameId}`;
|
||||
} else {
|
||||
alert('Veuillez entrer un ID de partie valide.');
|
||||
}
|
||||
}
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
session_start();
|
||||
session_destroy(); // On détruit la session pour supprimer l'ID de la partie en cours
|
||||
|
||||
// Récupérer la liste des parties en cours
|
||||
$stmt = $db->query("SELECT id, start_money, start_blind FROM games ORDER BY id DESC");
|
||||
$games = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<title>Poker PAF</title>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='stylesheet' type='text/css' media='screen' href='index.css'>
|
||||
<script src='main.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="welcome-container">
|
||||
<h1>Welcome to Poker PAF</h1>
|
||||
<button onclick="window.location.href='config.php'">Créer une partie</button><br><br>
|
||||
|
||||
<label>Rejoindre une partie :</label><br>
|
||||
<input type="text" id="join_game_id" placeholder="ID de la partie">
|
||||
<button onclick="joinGame()">Rejoindre</button><br><br>
|
||||
<h2>Parties en cours :</h2>
|
||||
<div id="games_list">
|
||||
<?php if (count($games) > 0): ?>
|
||||
<ul>
|
||||
<?php foreach ($games as $game): ?>
|
||||
<li>
|
||||
ID: <?php echo $game['id']; ?> -
|
||||
Start Money: <?php echo $game['start_money']; ?> -
|
||||
Blind: <?php echo $game['start_blind']; ?>
|
||||
<button class="btn-join-list" onclick="window.location.href='game.php?game_id=<?php echo $game['id']; ?>'">Rejoindre</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<p>Aucune partie en cours.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function joinGame() {
|
||||
const gameId = document.getElementById('join_game_id').value;
|
||||
if (gameId) {
|
||||
// Rediriger vers une page de jeu avec l'ID en paramètre
|
||||
window.location.href = `game.php?game_id=${gameId}`;
|
||||
} else {
|
||||
alert('Veuillez entrer un ID de partie valide.');
|
||||
}
|
||||
}
|
||||
</html>
|
||||
@@ -1,31 +1,31 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = intval($_POST['amount']);
|
||||
|
||||
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'];
|
||||
|
||||
// 3. Mettre à jour l'argent du joueur actuel
|
||||
$new_money = $money + $amount;
|
||||
$stmt = $db->prepare("UPDATE players SET money = ? WHERE id = ?");
|
||||
$stmt->execute([$new_money, $current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true, 'money' => $money, 'player_id' => $current_player_id]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = intval($_POST['amount']);
|
||||
|
||||
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'];
|
||||
|
||||
// 3. Mettre à jour l'argent du joueur actuel
|
||||
$new_money = $money + $amount;
|
||||
$stmt = $db->prepare("UPDATE players SET money = ? WHERE id = ?");
|
||||
$stmt->execute([$new_money, $current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true, 'money' => $money, 'player_id' => $current_player_id]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
@@ -1,40 +1,40 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
|
||||
try {
|
||||
// 1. On récupère tous les joueurs
|
||||
$stmt = $db->prepare("SELECT id, is_dealer FROM players WHERE game_id = ? ORDER BY id ASC");
|
||||
$stmt->execute([$game_id]);
|
||||
$players = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (count($players) == 0) throw new Exception("Pas de joueurs");
|
||||
|
||||
// 2. On trouve l'ancien dealer pour désigner le nouveau
|
||||
$oldDealerIndex = -1;
|
||||
foreach ($players as $index => $p) {
|
||||
if ($p['is_dealer'] == 1) { $oldDealerIndex = $index; break; }
|
||||
}
|
||||
|
||||
$nextDealerIndex = ($oldDealerIndex + 1) % count($players);
|
||||
$newDealerId = $players[$nextDealerIndex]['id'];
|
||||
|
||||
// 3. Qui doit parler en premier ? (Normalement c'est celui après le Dealer)
|
||||
$firstPlayerIndex = ($nextDealerIndex + 1) % count($players);
|
||||
$firstPlayerId = $players[$firstPlayerIndex]['id'];
|
||||
|
||||
// 4. MISE À JOUR DE LA BDD
|
||||
// On reset les dealers
|
||||
$db->prepare("UPDATE players SET is_dealer = 0 WHERE game_id = ?")->execute([$game_id]);
|
||||
// On met le nouveau dealer
|
||||
$db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?")->execute([$newDealerId]);
|
||||
// On reset le POT, la MISE et on définit le JOUEUR ACTIF
|
||||
$db->prepare("UPDATE games SET pot = 0, last_bet = 0, current_player_id = ? WHERE id = ?")
|
||||
->execute([$firstPlayerId, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
|
||||
try {
|
||||
// 1. On récupère tous les joueurs
|
||||
$stmt = $db->prepare("SELECT id, is_dealer FROM players WHERE game_id = ? ORDER BY id ASC");
|
||||
$stmt->execute([$game_id]);
|
||||
$players = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (count($players) == 0) throw new Exception("Pas de joueurs");
|
||||
|
||||
// 2. On trouve l'ancien dealer pour désigner le nouveau
|
||||
$oldDealerIndex = -1;
|
||||
foreach ($players as $index => $p) {
|
||||
if ($p['is_dealer'] == 1) { $oldDealerIndex = $index; break; }
|
||||
}
|
||||
|
||||
$nextDealerIndex = ($oldDealerIndex + 1) % count($players);
|
||||
$newDealerId = $players[$nextDealerIndex]['id'];
|
||||
|
||||
// 3. Qui doit parler en premier ? (Normalement c'est celui après le Dealer)
|
||||
$firstPlayerIndex = ($nextDealerIndex + 1) % count($players);
|
||||
$firstPlayerId = $players[$firstPlayerIndex]['id'];
|
||||
|
||||
// 4. MISE À JOUR DE LA BDD
|
||||
// On reset les dealers
|
||||
$db->prepare("UPDATE players SET is_dealer = 0 WHERE game_id = ?")->execute([$game_id]);
|
||||
// On met le nouveau dealer
|
||||
$db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?")->execute([$newDealerId]);
|
||||
// On reset le POT, la MISE et on définit le JOUEUR ACTIF
|
||||
$db->prepare("UPDATE games SET pot = 0, last_bet = 0, current_player_id = ? WHERE id = ?")
|
||||
->execute([$firstPlayerId, $game_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
+266
-266
@@ -1,266 +1,266 @@
|
||||
#### 9.0.0
|
||||
* 27/05/2019
|
||||
* For compatibility with legacy browsers, remove `Symbol` references.
|
||||
|
||||
#### 8.1.1
|
||||
* 24/02/2019
|
||||
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
|
||||
* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
|
||||
|
||||
#### 8.1.0
|
||||
* 23/02/2019
|
||||
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
|
||||
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
|
||||
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
|
||||
* Add `_isBigNumber` to prototype in *bignumber.mjs*.
|
||||
* Add tests for BigNumber creation from object.
|
||||
* Update *API.html*.
|
||||
|
||||
#### 8.0.2
|
||||
* 13/01/2019
|
||||
* #209 `toPrecision` without argument should follow `toString`.
|
||||
* Improve *Use* section of *README*.
|
||||
* Optimise `toString(10)`.
|
||||
* Add verson number to API doc.
|
||||
|
||||
#### 8.0.1
|
||||
* 01/11/2018
|
||||
* Rest parameter must be array type in *bignumber.d.ts*.
|
||||
|
||||
#### 8.0.0
|
||||
* 01/11/2018
|
||||
* [NEW FEATURE] Add `BigNumber.sum` method.
|
||||
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
|
||||
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
|
||||
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
|
||||
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
|
||||
* #183 Add Node.js `crypto` requirement to documentation.
|
||||
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
|
||||
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
|
||||
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
|
||||
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
|
||||
* Update *.travis.yml*.
|
||||
* Remove *bower.json*.
|
||||
|
||||
#### 7.2.1
|
||||
* 24/05/2018
|
||||
* Add `browser` field to *package.json*.
|
||||
|
||||
#### 7.2.0
|
||||
* 22/05/2018
|
||||
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
|
||||
|
||||
#### 7.1.0
|
||||
* 18/05/2018
|
||||
* Add `module` field to *package.json* for *bignumber.mjs*.
|
||||
|
||||
#### 7.0.2
|
||||
* 17/05/2018
|
||||
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
|
||||
* Add note to *README* regarding creating BigNumbers from Number values.
|
||||
|
||||
#### 7.0.1
|
||||
* 26/04/2018
|
||||
* #158 Fix global object variable name typo.
|
||||
|
||||
#### 7.0.0
|
||||
* 26/04/2018
|
||||
* #143 Remove global BigNumber from typings.
|
||||
* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
|
||||
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
|
||||
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
|
||||
* #154 `exponentiatedBy`: allow BigNumber exponent.
|
||||
* #156 Prevent Content Security Policy *unsafe-eval* issue.
|
||||
* `toFraction`: allow `Infinity` maximum denominator.
|
||||
* Comment-out some excess tests to reduce test time.
|
||||
* Amend indentation and other spacing.
|
||||
|
||||
#### 6.0.0
|
||||
* 26/01/2018
|
||||
* #137 Implement `APLHABET` configuration option.
|
||||
* Remove `ERRORS` configuration option.
|
||||
* Remove `toDigits` method; extend `precision` method accordingly.
|
||||
* Remove s`round` method; extend `decimalPlaces` method accordingly.
|
||||
* Remove methods: `ceil`, `floor`, and `truncated`.
|
||||
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
|
||||
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
|
||||
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
|
||||
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
|
||||
* Refactor test suite.
|
||||
* Add *CHANGELOG.md*.
|
||||
* Rewrite *bignumber.d.ts*.
|
||||
* Redo API image.
|
||||
|
||||
#### 5.0.0
|
||||
* 27/11/2017
|
||||
* #81 Don't throw on constructor call without `new`.
|
||||
|
||||
#### 4.1.0
|
||||
* 26/09/2017
|
||||
* Remove node 0.6 from *.travis.yml*.
|
||||
* Add *bignumber.mjs*.
|
||||
|
||||
#### 4.0.4
|
||||
* 03/09/2017
|
||||
* Add missing aliases to *bignumber.d.ts*.
|
||||
|
||||
#### 4.0.3
|
||||
* 30/08/2017
|
||||
* Add types: *bignumber.d.ts*.
|
||||
|
||||
#### 4.0.2
|
||||
* 03/05/2017
|
||||
* #120 Workaround Safari/Webkit bug.
|
||||
|
||||
#### 4.0.1
|
||||
* 05/04/2017
|
||||
* #121 BigNumber.default to BigNumber['default'].
|
||||
|
||||
#### 4.0.0
|
||||
* 09/01/2017
|
||||
* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
|
||||
|
||||
#### 3.1.2
|
||||
* 08/01/2017
|
||||
* Minor documentation edit.
|
||||
|
||||
#### 3.1.1
|
||||
* 08/01/2017
|
||||
* Uncomment `isBigNumber` tests.
|
||||
* Ignore dot files.
|
||||
|
||||
#### 3.1.0
|
||||
* 08/01/2017
|
||||
* Add `isBigNumber` method.
|
||||
|
||||
#### 3.0.2
|
||||
* 08/01/2017
|
||||
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
|
||||
|
||||
#### 3.0.1
|
||||
* 23/11/2016
|
||||
* Apply fix for old ipads with `%` issue, see #57 and #102.
|
||||
* Correct error message.
|
||||
|
||||
#### 3.0.0
|
||||
* 09/11/2016
|
||||
* Remove `require('crypto')` - leave it to the user.
|
||||
* Add `BigNumber.set` as `BigNumber.config` alias.
|
||||
* Default `POW_PRECISION` to `0`.
|
||||
|
||||
#### 2.4.0
|
||||
* 14/07/2016
|
||||
* #97 Add exports to support ES6 imports.
|
||||
|
||||
#### 2.3.0
|
||||
* 07/03/2016
|
||||
* #86 Add modulus parameter to `toPower`.
|
||||
|
||||
#### 2.2.0
|
||||
* 03/03/2016
|
||||
* #91 Permit larger JS integers.
|
||||
|
||||
#### 2.1.4
|
||||
* 15/12/2015
|
||||
* Correct UMD.
|
||||
|
||||
#### 2.1.3
|
||||
* 13/12/2015
|
||||
* Refactor re global object and crypto availability when bundling.
|
||||
|
||||
#### 2.1.2
|
||||
* 10/12/2015
|
||||
* Bugfix: `window.crypto` not assigned to `crypto`.
|
||||
|
||||
#### 2.1.1
|
||||
* 09/12/2015
|
||||
* Prevent code bundler from adding `crypto` shim.
|
||||
|
||||
#### 2.1.0
|
||||
* 26/10/2015
|
||||
* For `valueOf` and `toJSON`, include the minus sign with negative zero.
|
||||
|
||||
#### 2.0.8
|
||||
* 2/10/2015
|
||||
* Internal round function bugfix.
|
||||
|
||||
#### 2.0.6
|
||||
* 31/03/2015
|
||||
* Add bower.json. Tweak division after in-depth review.
|
||||
|
||||
#### 2.0.5
|
||||
* 25/03/2015
|
||||
* Amend README. Remove bitcoin address.
|
||||
|
||||
#### 2.0.4
|
||||
* 25/03/2015
|
||||
* Critical bugfix #58: division.
|
||||
|
||||
#### 2.0.3
|
||||
* 18/02/2015
|
||||
* Amend README. Add source map.
|
||||
|
||||
#### 2.0.2
|
||||
* 18/02/2015
|
||||
* Correct links.
|
||||
|
||||
#### 2.0.1
|
||||
* 18/02/2015
|
||||
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
|
||||
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
|
||||
* Add an `another` method to enable multiple independent constructors to be created.
|
||||
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
|
||||
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
|
||||
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
|
||||
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
|
||||
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
|
||||
* Improve code quality.
|
||||
* Improve documentation.
|
||||
|
||||
#### 2.0.0
|
||||
* 29/12/2014
|
||||
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
|
||||
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
|
||||
* Store a BigNumber's coefficient in base 1e14, rather than base 10.
|
||||
* Add fast path for integers to BigNumber constructor.
|
||||
* Incorporate the library into the online documentation.
|
||||
|
||||
#### 1.5.0
|
||||
* 13/11/2014
|
||||
* Add `toJSON` and `decimalPlaces` methods.
|
||||
|
||||
#### 1.4.1
|
||||
* 08/06/2014
|
||||
* Amend README.
|
||||
|
||||
#### 1.4.0
|
||||
* 08/05/2014
|
||||
* Add `toNumber`.
|
||||
|
||||
#### 1.3.0
|
||||
* 08/11/2013
|
||||
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
|
||||
* Maximum radix to 64.
|
||||
|
||||
#### 1.2.1
|
||||
* 17/10/2013
|
||||
* Sign of zero when x < 0 and x + (-x) = 0.
|
||||
|
||||
#### 1.2.0
|
||||
* 19/9/2013
|
||||
* Throw Error objects for stack.
|
||||
|
||||
#### 1.1.1
|
||||
* 22/8/2013
|
||||
* Show original value in constructor error message.
|
||||
|
||||
#### 1.1.0
|
||||
* 1/8/2013
|
||||
* Allow numbers with trailing radix point.
|
||||
|
||||
#### 1.0.1
|
||||
* Bugfix: error messages with incorrect method name
|
||||
|
||||
#### 1.0.0
|
||||
* 8/11/2012
|
||||
* Initial release
|
||||
#### 9.0.0
|
||||
* 27/05/2019
|
||||
* For compatibility with legacy browsers, remove `Symbol` references.
|
||||
|
||||
#### 8.1.1
|
||||
* 24/02/2019
|
||||
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
|
||||
* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
|
||||
|
||||
#### 8.1.0
|
||||
* 23/02/2019
|
||||
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
|
||||
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
|
||||
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
|
||||
* Add `_isBigNumber` to prototype in *bignumber.mjs*.
|
||||
* Add tests for BigNumber creation from object.
|
||||
* Update *API.html*.
|
||||
|
||||
#### 8.0.2
|
||||
* 13/01/2019
|
||||
* #209 `toPrecision` without argument should follow `toString`.
|
||||
* Improve *Use* section of *README*.
|
||||
* Optimise `toString(10)`.
|
||||
* Add verson number to API doc.
|
||||
|
||||
#### 8.0.1
|
||||
* 01/11/2018
|
||||
* Rest parameter must be array type in *bignumber.d.ts*.
|
||||
|
||||
#### 8.0.0
|
||||
* 01/11/2018
|
||||
* [NEW FEATURE] Add `BigNumber.sum` method.
|
||||
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
|
||||
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
|
||||
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
|
||||
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
|
||||
* #183 Add Node.js `crypto` requirement to documentation.
|
||||
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
|
||||
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
|
||||
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
|
||||
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
|
||||
* Update *.travis.yml*.
|
||||
* Remove *bower.json*.
|
||||
|
||||
#### 7.2.1
|
||||
* 24/05/2018
|
||||
* Add `browser` field to *package.json*.
|
||||
|
||||
#### 7.2.0
|
||||
* 22/05/2018
|
||||
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
|
||||
|
||||
#### 7.1.0
|
||||
* 18/05/2018
|
||||
* Add `module` field to *package.json* for *bignumber.mjs*.
|
||||
|
||||
#### 7.0.2
|
||||
* 17/05/2018
|
||||
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
|
||||
* Add note to *README* regarding creating BigNumbers from Number values.
|
||||
|
||||
#### 7.0.1
|
||||
* 26/04/2018
|
||||
* #158 Fix global object variable name typo.
|
||||
|
||||
#### 7.0.0
|
||||
* 26/04/2018
|
||||
* #143 Remove global BigNumber from typings.
|
||||
* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
|
||||
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
|
||||
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
|
||||
* #154 `exponentiatedBy`: allow BigNumber exponent.
|
||||
* #156 Prevent Content Security Policy *unsafe-eval* issue.
|
||||
* `toFraction`: allow `Infinity` maximum denominator.
|
||||
* Comment-out some excess tests to reduce test time.
|
||||
* Amend indentation and other spacing.
|
||||
|
||||
#### 6.0.0
|
||||
* 26/01/2018
|
||||
* #137 Implement `APLHABET` configuration option.
|
||||
* Remove `ERRORS` configuration option.
|
||||
* Remove `toDigits` method; extend `precision` method accordingly.
|
||||
* Remove s`round` method; extend `decimalPlaces` method accordingly.
|
||||
* Remove methods: `ceil`, `floor`, and `truncated`.
|
||||
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
|
||||
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
|
||||
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
|
||||
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
|
||||
* Refactor test suite.
|
||||
* Add *CHANGELOG.md*.
|
||||
* Rewrite *bignumber.d.ts*.
|
||||
* Redo API image.
|
||||
|
||||
#### 5.0.0
|
||||
* 27/11/2017
|
||||
* #81 Don't throw on constructor call without `new`.
|
||||
|
||||
#### 4.1.0
|
||||
* 26/09/2017
|
||||
* Remove node 0.6 from *.travis.yml*.
|
||||
* Add *bignumber.mjs*.
|
||||
|
||||
#### 4.0.4
|
||||
* 03/09/2017
|
||||
* Add missing aliases to *bignumber.d.ts*.
|
||||
|
||||
#### 4.0.3
|
||||
* 30/08/2017
|
||||
* Add types: *bignumber.d.ts*.
|
||||
|
||||
#### 4.0.2
|
||||
* 03/05/2017
|
||||
* #120 Workaround Safari/Webkit bug.
|
||||
|
||||
#### 4.0.1
|
||||
* 05/04/2017
|
||||
* #121 BigNumber.default to BigNumber['default'].
|
||||
|
||||
#### 4.0.0
|
||||
* 09/01/2017
|
||||
* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
|
||||
|
||||
#### 3.1.2
|
||||
* 08/01/2017
|
||||
* Minor documentation edit.
|
||||
|
||||
#### 3.1.1
|
||||
* 08/01/2017
|
||||
* Uncomment `isBigNumber` tests.
|
||||
* Ignore dot files.
|
||||
|
||||
#### 3.1.0
|
||||
* 08/01/2017
|
||||
* Add `isBigNumber` method.
|
||||
|
||||
#### 3.0.2
|
||||
* 08/01/2017
|
||||
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
|
||||
|
||||
#### 3.0.1
|
||||
* 23/11/2016
|
||||
* Apply fix for old ipads with `%` issue, see #57 and #102.
|
||||
* Correct error message.
|
||||
|
||||
#### 3.0.0
|
||||
* 09/11/2016
|
||||
* Remove `require('crypto')` - leave it to the user.
|
||||
* Add `BigNumber.set` as `BigNumber.config` alias.
|
||||
* Default `POW_PRECISION` to `0`.
|
||||
|
||||
#### 2.4.0
|
||||
* 14/07/2016
|
||||
* #97 Add exports to support ES6 imports.
|
||||
|
||||
#### 2.3.0
|
||||
* 07/03/2016
|
||||
* #86 Add modulus parameter to `toPower`.
|
||||
|
||||
#### 2.2.0
|
||||
* 03/03/2016
|
||||
* #91 Permit larger JS integers.
|
||||
|
||||
#### 2.1.4
|
||||
* 15/12/2015
|
||||
* Correct UMD.
|
||||
|
||||
#### 2.1.3
|
||||
* 13/12/2015
|
||||
* Refactor re global object and crypto availability when bundling.
|
||||
|
||||
#### 2.1.2
|
||||
* 10/12/2015
|
||||
* Bugfix: `window.crypto` not assigned to `crypto`.
|
||||
|
||||
#### 2.1.1
|
||||
* 09/12/2015
|
||||
* Prevent code bundler from adding `crypto` shim.
|
||||
|
||||
#### 2.1.0
|
||||
* 26/10/2015
|
||||
* For `valueOf` and `toJSON`, include the minus sign with negative zero.
|
||||
|
||||
#### 2.0.8
|
||||
* 2/10/2015
|
||||
* Internal round function bugfix.
|
||||
|
||||
#### 2.0.6
|
||||
* 31/03/2015
|
||||
* Add bower.json. Tweak division after in-depth review.
|
||||
|
||||
#### 2.0.5
|
||||
* 25/03/2015
|
||||
* Amend README. Remove bitcoin address.
|
||||
|
||||
#### 2.0.4
|
||||
* 25/03/2015
|
||||
* Critical bugfix #58: division.
|
||||
|
||||
#### 2.0.3
|
||||
* 18/02/2015
|
||||
* Amend README. Add source map.
|
||||
|
||||
#### 2.0.2
|
||||
* 18/02/2015
|
||||
* Correct links.
|
||||
|
||||
#### 2.0.1
|
||||
* 18/02/2015
|
||||
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
|
||||
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
|
||||
* Add an `another` method to enable multiple independent constructors to be created.
|
||||
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
|
||||
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
|
||||
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
|
||||
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
|
||||
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
|
||||
* Improve code quality.
|
||||
* Improve documentation.
|
||||
|
||||
#### 2.0.0
|
||||
* 29/12/2014
|
||||
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
|
||||
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
|
||||
* Store a BigNumber's coefficient in base 1e14, rather than base 10.
|
||||
* Add fast path for integers to BigNumber constructor.
|
||||
* Incorporate the library into the online documentation.
|
||||
|
||||
#### 1.5.0
|
||||
* 13/11/2014
|
||||
* Add `toJSON` and `decimalPlaces` methods.
|
||||
|
||||
#### 1.4.1
|
||||
* 08/06/2014
|
||||
* Amend README.
|
||||
|
||||
#### 1.4.0
|
||||
* 08/05/2014
|
||||
* Add `toNumber`.
|
||||
|
||||
#### 1.3.0
|
||||
* 08/11/2013
|
||||
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
|
||||
* Maximum radix to 64.
|
||||
|
||||
#### 1.2.1
|
||||
* 17/10/2013
|
||||
* Sign of zero when x < 0 and x + (-x) = 0.
|
||||
|
||||
#### 1.2.0
|
||||
* 19/9/2013
|
||||
* Throw Error objects for stack.
|
||||
|
||||
#### 1.1.1
|
||||
* 22/8/2013
|
||||
* Show original value in constructor error message.
|
||||
|
||||
#### 1.1.0
|
||||
* 1/8/2013
|
||||
* Allow numbers with trailing radix point.
|
||||
|
||||
#### 1.0.1
|
||||
* Bugfix: error messages with incorrect method name
|
||||
|
||||
#### 1.0.0
|
||||
* 8/11/2012
|
||||
* Initial release
|
||||
|
||||
+23
-23
@@ -1,23 +1,23 @@
|
||||
The MIT Licence.
|
||||
|
||||
Copyright (c) 2019 Michael Mclaughlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
The MIT Licence.
|
||||
|
||||
Copyright (c) 2019 Michael Mclaughlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
+268
-268
@@ -1,268 +1,268 @@
|
||||

|
||||
|
||||
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
|
||||
|
||||
[](https://travis-ci.org/MikeMcl/bignumber.js)
|
||||
|
||||
<br />
|
||||
|
||||
## Features
|
||||
|
||||
- Integers and decimals
|
||||
- Simple API but full-featured
|
||||
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
|
||||
- 8 KB minified and gzipped
|
||||
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
|
||||
- Includes a `toFraction` and a correctly-rounded `squareRoot` method
|
||||
- Supports cryptographically-secure pseudo-random number generation
|
||||
- No dependencies
|
||||
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
|
||||
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
|
||||
|
||||

|
||||
|
||||
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
|
||||
It's less than half the size but only works with decimal numbers and only has half the methods.
|
||||
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
|
||||
|
||||
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
|
||||
|
||||
## Load
|
||||
|
||||
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
|
||||
|
||||
Browser:
|
||||
|
||||
```html
|
||||
<script src='path/to/bignumber.js'></script>
|
||||
```
|
||||
|
||||
[Node.js](http://nodejs.org):
|
||||
|
||||
```bash
|
||||
$ npm install bignumber.js
|
||||
```
|
||||
|
||||
```javascript
|
||||
const BigNumber = require('bignumber.js');
|
||||
```
|
||||
|
||||
ES6 module:
|
||||
|
||||
```javascript
|
||||
import BigNumber from "./bignumber.mjs"
|
||||
```
|
||||
|
||||
AMD loader libraries such as [requireJS](http://requirejs.org/):
|
||||
|
||||
```javascript
|
||||
require(['bignumber'], function(BigNumber) {
|
||||
// Use BigNumber here in local scope. No global BigNumber.
|
||||
});
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber,
|
||||
|
||||
```javascript
|
||||
let x = new BigNumber(123.4567);
|
||||
let y = BigNumber('123456.7e-3');
|
||||
let z = new BigNumber(x);
|
||||
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true
|
||||
```
|
||||
|
||||
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value.
|
||||
|
||||
```javascript
|
||||
let x = new BigNumber('1111222233334444555566');
|
||||
x.toString(); // "1.111222233334444555566e+21"
|
||||
x.toFixed(); // "1111222233334444555566"
|
||||
```
|
||||
|
||||
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision.
|
||||
|
||||
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
||||
|
||||
```javascript
|
||||
// Precision loss from using numeric literals with more than 15 significant digits.
|
||||
new BigNumber(1.0000000000000001) // '1'
|
||||
new BigNumber(88259496234518.57) // '88259496234518.56'
|
||||
new BigNumber(99999999999999999999) // '100000000000000000000'
|
||||
|
||||
// Precision loss from using numeric literals outside the range of Number values.
|
||||
new BigNumber(2e+308) // 'Infinity'
|
||||
new BigNumber(1e-324) // '0'
|
||||
|
||||
// Precision loss from the unexpected result of arithmetic with Number values.
|
||||
new BigNumber(0.7 + 0.1) // '0.7999999999999999'
|
||||
```
|
||||
|
||||
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
|
||||
|
||||
```javascript
|
||||
new BigNumber(Number.MAX_VALUE.toString(2), 2)
|
||||
```
|
||||
|
||||
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range.
|
||||
|
||||
```javascript
|
||||
a = new BigNumber(1011, 2) // "11"
|
||||
b = new BigNumber('zz.9', 36) // "1295.25"
|
||||
c = a.plus(b) // "1306.25"
|
||||
```
|
||||
|
||||
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||
|
||||
A BigNumber is immutable in the sense that it is not changed by its methods.
|
||||
|
||||
```javascript
|
||||
0.3 - 0.1 // 0.19999999999999998
|
||||
x = new BigNumber(0.3)
|
||||
x.minus(0.1) // "0.2"
|
||||
x // "0.3"
|
||||
```
|
||||
|
||||
The methods that return a BigNumber can be chained.
|
||||
|
||||
```javascript
|
||||
x.dividedBy(y).plus(z).times(9)
|
||||
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
|
||||
```
|
||||
|
||||
Some of the longer method names have a shorter alias.
|
||||
|
||||
```javascript
|
||||
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true
|
||||
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true
|
||||
```
|
||||
|
||||
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods.
|
||||
|
||||
```javascript
|
||||
x = new BigNumber(255.5)
|
||||
x.toExponential(5) // "2.55500e+2"
|
||||
x.toFixed(5) // "255.50000"
|
||||
x.toPrecision(5) // "255.50"
|
||||
x.toNumber() // 255.5
|
||||
```
|
||||
|
||||
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||
|
||||
```javascript
|
||||
x.toString(16) // "ff.8"
|
||||
```
|
||||
|
||||
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation.
|
||||
|
||||
```javascript
|
||||
y = new BigNumber('1234567.898765')
|
||||
y.toFormat(2) // "1,234,567.90"
|
||||
```
|
||||
|
||||
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor.
|
||||
|
||||
The other arithmetic operations always give the exact result.
|
||||
|
||||
```javascript
|
||||
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
|
||||
|
||||
x = new BigNumber(2)
|
||||
y = new BigNumber(3)
|
||||
z = x.dividedBy(y) // "0.6666666667"
|
||||
z.squareRoot() // "0.8164965809"
|
||||
z.exponentiatedBy(-3) // "3.3749999995"
|
||||
z.toString(2) // "0.1010101011"
|
||||
z.multipliedBy(z) // "0.44444444448888888889"
|
||||
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
|
||||
```
|
||||
|
||||
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument
|
||||
|
||||
```javascript
|
||||
y = new BigNumber(355)
|
||||
pi = y.dividedBy(113) // "3.1415929204"
|
||||
pi.toFraction() // [ "7853982301", "2500000000" ]
|
||||
pi.toFraction(1000) // [ "355", "113" ]
|
||||
```
|
||||
|
||||
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values.
|
||||
|
||||
```javascript
|
||||
x = new BigNumber(NaN) // "NaN"
|
||||
y = new BigNumber(Infinity) // "Infinity"
|
||||
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
|
||||
```
|
||||
|
||||
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
||||
|
||||
```javascript
|
||||
x = new BigNumber(-123.456);
|
||||
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
|
||||
x.e // 2 exponent
|
||||
x.s // -1 sign
|
||||
```
|
||||
|
||||
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration.
|
||||
|
||||
```javascript
|
||||
// Set DECIMAL_PLACES for the original BigNumber constructor
|
||||
BigNumber.set({ DECIMAL_PLACES: 10 })
|
||||
|
||||
// Create another BigNumber constructor, optionally passing in a configuration object
|
||||
BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
|
||||
|
||||
x = new BigNumber(1)
|
||||
y = new BN(1)
|
||||
|
||||
x.div(3) // '0.3333333333'
|
||||
y.div(3) // '0.33333'
|
||||
```
|
||||
|
||||
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
|
||||
|
||||
## Test
|
||||
|
||||
The *test/modules* directory contains the test scripts for each method.
|
||||
|
||||
The tests can be run with Node.js or a browser. For Node.js use
|
||||
|
||||
$ npm test
|
||||
|
||||
or
|
||||
|
||||
$ node test/test
|
||||
|
||||
To test a single method, use, for example
|
||||
|
||||
$ node test/methods/toFraction
|
||||
|
||||
For the browser, open *test/test.html*.
|
||||
|
||||
## Build
|
||||
|
||||
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
|
||||
|
||||
npm install uglify-js -g
|
||||
|
||||
then
|
||||
|
||||
npm run build
|
||||
|
||||
will create *bignumber.min.js*.
|
||||
|
||||
A source map will also be created in the root directory.
|
||||
|
||||
## Feedback
|
||||
|
||||
Open an issue, or email
|
||||
|
||||
Michael
|
||||
|
||||
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
|
||||
|
||||
## Licence
|
||||
|
||||
The MIT Licence.
|
||||
|
||||
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
|
||||

|
||||
|
||||
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
|
||||
|
||||
[](https://travis-ci.org/MikeMcl/bignumber.js)
|
||||
|
||||
<br />
|
||||
|
||||
## Features
|
||||
|
||||
- Integers and decimals
|
||||
- Simple API but full-featured
|
||||
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
|
||||
- 8 KB minified and gzipped
|
||||
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
|
||||
- Includes a `toFraction` and a correctly-rounded `squareRoot` method
|
||||
- Supports cryptographically-secure pseudo-random number generation
|
||||
- No dependencies
|
||||
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
|
||||
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
|
||||
|
||||

|
||||
|
||||
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
|
||||
It's less than half the size but only works with decimal numbers and only has half the methods.
|
||||
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
|
||||
|
||||
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
|
||||
|
||||
## Load
|
||||
|
||||
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
|
||||
|
||||
Browser:
|
||||
|
||||
```html
|
||||
<script src='path/to/bignumber.js'></script>
|
||||
```
|
||||
|
||||
[Node.js](http://nodejs.org):
|
||||
|
||||
```bash
|
||||
$ npm install bignumber.js
|
||||
```
|
||||
|
||||
```javascript
|
||||
const BigNumber = require('bignumber.js');
|
||||
```
|
||||
|
||||
ES6 module:
|
||||
|
||||
```javascript
|
||||
import BigNumber from "./bignumber.mjs"
|
||||
```
|
||||
|
||||
AMD loader libraries such as [requireJS](http://requirejs.org/):
|
||||
|
||||
```javascript
|
||||
require(['bignumber'], function(BigNumber) {
|
||||
// Use BigNumber here in local scope. No global BigNumber.
|
||||
});
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber,
|
||||
|
||||
```javascript
|
||||
let x = new BigNumber(123.4567);
|
||||
let y = BigNumber('123456.7e-3');
|
||||
let z = new BigNumber(x);
|
||||
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true
|
||||
```
|
||||
|
||||
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value.
|
||||
|
||||
```javascript
|
||||
let x = new BigNumber('1111222233334444555566');
|
||||
x.toString(); // "1.111222233334444555566e+21"
|
||||
x.toFixed(); // "1111222233334444555566"
|
||||
```
|
||||
|
||||
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision.
|
||||
|
||||
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
||||
|
||||
```javascript
|
||||
// Precision loss from using numeric literals with more than 15 significant digits.
|
||||
new BigNumber(1.0000000000000001) // '1'
|
||||
new BigNumber(88259496234518.57) // '88259496234518.56'
|
||||
new BigNumber(99999999999999999999) // '100000000000000000000'
|
||||
|
||||
// Precision loss from using numeric literals outside the range of Number values.
|
||||
new BigNumber(2e+308) // 'Infinity'
|
||||
new BigNumber(1e-324) // '0'
|
||||
|
||||
// Precision loss from the unexpected result of arithmetic with Number values.
|
||||
new BigNumber(0.7 + 0.1) // '0.7999999999999999'
|
||||
```
|
||||
|
||||
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
|
||||
|
||||
```javascript
|
||||
new BigNumber(Number.MAX_VALUE.toString(2), 2)
|
||||
```
|
||||
|
||||
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range.
|
||||
|
||||
```javascript
|
||||
a = new BigNumber(1011, 2) // "11"
|
||||
b = new BigNumber('zz.9', 36) // "1295.25"
|
||||
c = a.plus(b) // "1306.25"
|
||||
```
|
||||
|
||||
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||
|
||||
A BigNumber is immutable in the sense that it is not changed by its methods.
|
||||
|
||||
```javascript
|
||||
0.3 - 0.1 // 0.19999999999999998
|
||||
x = new BigNumber(0.3)
|
||||
x.minus(0.1) // "0.2"
|
||||
x // "0.3"
|
||||
```
|
||||
|
||||
The methods that return a BigNumber can be chained.
|
||||
|
||||
```javascript
|
||||
x.dividedBy(y).plus(z).times(9)
|
||||
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
|
||||
```
|
||||
|
||||
Some of the longer method names have a shorter alias.
|
||||
|
||||
```javascript
|
||||
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true
|
||||
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true
|
||||
```
|
||||
|
||||
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods.
|
||||
|
||||
```javascript
|
||||
x = new BigNumber(255.5)
|
||||
x.toExponential(5) // "2.55500e+2"
|
||||
x.toFixed(5) // "255.50000"
|
||||
x.toPrecision(5) // "255.50"
|
||||
x.toNumber() // 255.5
|
||||
```
|
||||
|
||||
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||
|
||||
```javascript
|
||||
x.toString(16) // "ff.8"
|
||||
```
|
||||
|
||||
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation.
|
||||
|
||||
```javascript
|
||||
y = new BigNumber('1234567.898765')
|
||||
y.toFormat(2) // "1,234,567.90"
|
||||
```
|
||||
|
||||
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor.
|
||||
|
||||
The other arithmetic operations always give the exact result.
|
||||
|
||||
```javascript
|
||||
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
|
||||
|
||||
x = new BigNumber(2)
|
||||
y = new BigNumber(3)
|
||||
z = x.dividedBy(y) // "0.6666666667"
|
||||
z.squareRoot() // "0.8164965809"
|
||||
z.exponentiatedBy(-3) // "3.3749999995"
|
||||
z.toString(2) // "0.1010101011"
|
||||
z.multipliedBy(z) // "0.44444444448888888889"
|
||||
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
|
||||
```
|
||||
|
||||
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument
|
||||
|
||||
```javascript
|
||||
y = new BigNumber(355)
|
||||
pi = y.dividedBy(113) // "3.1415929204"
|
||||
pi.toFraction() // [ "7853982301", "2500000000" ]
|
||||
pi.toFraction(1000) // [ "355", "113" ]
|
||||
```
|
||||
|
||||
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values.
|
||||
|
||||
```javascript
|
||||
x = new BigNumber(NaN) // "NaN"
|
||||
y = new BigNumber(Infinity) // "Infinity"
|
||||
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
|
||||
```
|
||||
|
||||
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
||||
|
||||
```javascript
|
||||
x = new BigNumber(-123.456);
|
||||
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
|
||||
x.e // 2 exponent
|
||||
x.s // -1 sign
|
||||
```
|
||||
|
||||
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration.
|
||||
|
||||
```javascript
|
||||
// Set DECIMAL_PLACES for the original BigNumber constructor
|
||||
BigNumber.set({ DECIMAL_PLACES: 10 })
|
||||
|
||||
// Create another BigNumber constructor, optionally passing in a configuration object
|
||||
BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
|
||||
|
||||
x = new BigNumber(1)
|
||||
y = new BN(1)
|
||||
|
||||
x.div(3) // '0.3333333333'
|
||||
y.div(3) // '0.33333'
|
||||
```
|
||||
|
||||
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
|
||||
|
||||
## Test
|
||||
|
||||
The *test/modules* directory contains the test scripts for each method.
|
||||
|
||||
The tests can be run with Node.js or a browser. For Node.js use
|
||||
|
||||
$ npm test
|
||||
|
||||
or
|
||||
|
||||
$ node test/test
|
||||
|
||||
To test a single method, use, for example
|
||||
|
||||
$ node test/methods/toFraction
|
||||
|
||||
For the browser, open *test/test.html*.
|
||||
|
||||
## Build
|
||||
|
||||
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
|
||||
|
||||
npm install uglify-js -g
|
||||
|
||||
then
|
||||
|
||||
npm run build
|
||||
|
||||
will create *bignumber.min.js*.
|
||||
|
||||
A source map will also be created in the root directory.
|
||||
|
||||
## Feedback
|
||||
|
||||
Open an issue, or email
|
||||
|
||||
Michael
|
||||
|
||||
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
|
||||
|
||||
## Licence
|
||||
|
||||
The MIT Licence.
|
||||
|
||||
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
|
||||
|
||||
+1829
-1829
File diff suppressed because it is too large
Load Diff
+2902
-2902
File diff suppressed because it is too large
Load Diff
+2888
-2888
File diff suppressed because it is too large
Load Diff
+2237
-2237
File diff suppressed because it is too large
Load Diff
+40
-40
@@ -1,40 +1,40 @@
|
||||
{
|
||||
"name": "bignumber.js",
|
||||
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
|
||||
"version": "9.0.0",
|
||||
"keywords": [
|
||||
"arbitrary",
|
||||
"precision",
|
||||
"arithmetic",
|
||||
"big",
|
||||
"number",
|
||||
"decimal",
|
||||
"float",
|
||||
"biginteger",
|
||||
"bigdecimal",
|
||||
"bignumber",
|
||||
"bigint",
|
||||
"bignum"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MikeMcl/bignumber.js.git"
|
||||
},
|
||||
"main": "bignumber",
|
||||
"module": "bignumber.mjs",
|
||||
"browser": "bignumber.js",
|
||||
"types": "bignumber.d.ts",
|
||||
"author": {
|
||||
"name": "Michael Mclaughlin",
|
||||
"email": "M8ch88l@gmail.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "node test/test",
|
||||
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
{
|
||||
"name": "bignumber.js",
|
||||
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
|
||||
"version": "9.0.0",
|
||||
"keywords": [
|
||||
"arbitrary",
|
||||
"precision",
|
||||
"arithmetic",
|
||||
"big",
|
||||
"number",
|
||||
"decimal",
|
||||
"float",
|
||||
"biginteger",
|
||||
"bigdecimal",
|
||||
"bignumber",
|
||||
"bigint",
|
||||
"bignum"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MikeMcl/bignumber.js.git"
|
||||
},
|
||||
"main": "bignumber",
|
||||
"module": "bignumber.mjs",
|
||||
"browser": "bignumber.js",
|
||||
"types": "bignumber.d.ts",
|
||||
"author": {
|
||||
"name": "Michael Mclaughlin",
|
||||
"email": "M8ch88l@gmail.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "node test/test",
|
||||
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = intval($_POST['amount']);
|
||||
|
||||
try {
|
||||
$db->beginTransaction();
|
||||
|
||||
// 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();
|
||||
$player_id = $game['current_player_id'];
|
||||
|
||||
// 2. Retirer l'argent au joueur
|
||||
$stmt = $db->prepare("UPDATE players SET money = money - ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $player_id]);
|
||||
|
||||
// 3. Ajouter l'argent au POT de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET pot = pot + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
// 4. Mettre à jour la mise actuelle (last_bet) pour les suivants
|
||||
$stmt = $db->prepare("UPDATE games SET last_bet = ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
// 5. Mettre à jour la mise actuelle du joueur
|
||||
$stmt = $db->prepare("UPDATE players SET current_bet = current_bet + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $player_id]);
|
||||
|
||||
$db->commit();
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$db->rollBack();
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = intval($_POST['amount']);
|
||||
|
||||
try {
|
||||
$db->beginTransaction();
|
||||
|
||||
// 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();
|
||||
$player_id = $game['current_player_id'];
|
||||
|
||||
// 2. Retirer l'argent au joueur
|
||||
$stmt = $db->prepare("UPDATE players SET money = money - ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $player_id]);
|
||||
|
||||
// 3. Ajouter l'argent au POT de la partie
|
||||
$stmt = $db->prepare("UPDATE games SET pot = pot + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
// 4. Mettre à jour la mise actuelle (last_bet) pour les suivants
|
||||
$stmt = $db->prepare("UPDATE games SET last_bet = ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $game_id]);
|
||||
|
||||
// 5. Mettre à jour la mise actuelle du joueur
|
||||
$stmt = $db->prepare("UPDATE players SET current_bet = current_bet + ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $player_id]);
|
||||
|
||||
$db->commit();
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$db->rollBack();
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
|
||||
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. Retirer de l'argent au joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = money - ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
|
||||
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. Retirer de l'argent au joueur actuel
|
||||
$stmt = $db->prepare("UPDATE players SET money = money - ? WHERE id = ?");
|
||||
$stmt->execute([$amount, $current_player_id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,46 +1,46 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
|
||||
// Création d'un partie
|
||||
$start_money = $_POST['start_money'];
|
||||
$start_blind = $_POST['blind'];
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO games (start_money, start_blind) VALUES (:start_money, :start_blind)");
|
||||
$stmt->execute([
|
||||
':start_money' => $start_money,
|
||||
':start_blind' => $start_blind
|
||||
]);
|
||||
|
||||
// Récupération de l'ID de la partie créée
|
||||
$game_id = $db->lastInsertId();
|
||||
|
||||
// Création des joueurs
|
||||
$players = $_POST['players'];
|
||||
foreach ($players as $player_name) {
|
||||
$stmt = $db->prepare("INSERT INTO players (name, game_id, money) VALUES (:name, :game_id, :start_money)");
|
||||
$stmt->execute([
|
||||
':name' => $player_name,
|
||||
':game_id' => $game_id,
|
||||
':start_money' => $start_money
|
||||
]);
|
||||
}
|
||||
|
||||
// Définir le premier joueur comme dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$first_player = $stmt->fetch();
|
||||
|
||||
$first_player_id = $first_player['id'];
|
||||
|
||||
$stmt = $db->prepare("UPDATE games SET current_player_id = ? WHERE id = ?");
|
||||
$stmt->execute([$first_player_id, $game_id]);
|
||||
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?");
|
||||
$stmt->execute([$first_player_id]);
|
||||
|
||||
// Redirection vers la page de jeu
|
||||
header("Location: game.php?game_id=$game_id");
|
||||
session_start();
|
||||
$_SESSION['game_id'] = $game_id; // Stocker l'ID de la partie dans la session pour y accéder plus tard
|
||||
exit();
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
|
||||
// Création d'un partie
|
||||
$start_money = $_POST['start_money'];
|
||||
$start_blind = $_POST['blind'];
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO games (start_money, start_blind) VALUES (:start_money, :start_blind)");
|
||||
$stmt->execute([
|
||||
':start_money' => $start_money,
|
||||
':start_blind' => $start_blind
|
||||
]);
|
||||
|
||||
// Récupération de l'ID de la partie créée
|
||||
$game_id = $db->lastInsertId();
|
||||
|
||||
// Création des joueurs
|
||||
$players = $_POST['players'];
|
||||
foreach ($players as $player_name) {
|
||||
$stmt = $db->prepare("INSERT INTO players (name, game_id, money) VALUES (:name, :game_id, :start_money)");
|
||||
$stmt->execute([
|
||||
':name' => $player_name,
|
||||
':game_id' => $game_id,
|
||||
':start_money' => $start_money
|
||||
]);
|
||||
}
|
||||
|
||||
// Définir le premier joueur comme dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$first_player = $stmt->fetch();
|
||||
|
||||
$first_player_id = $first_player['id'];
|
||||
|
||||
$stmt = $db->prepare("UPDATE games SET current_player_id = ? WHERE id = ?");
|
||||
$stmt->execute([$first_player_id, $game_id]);
|
||||
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?");
|
||||
$stmt->execute([$first_player_id]);
|
||||
|
||||
// Redirection vers la page de jeu
|
||||
header("Location: game.php?game_id=$game_id");
|
||||
session_start();
|
||||
$_SESSION['game_id'] = $game_id; // Stocker l'ID de la partie dans la session pour y accéder plus tard
|
||||
exit();
|
||||
?>
|
||||
@@ -1,63 +1,63 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
session_start();
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
|
||||
try {
|
||||
|
||||
// 1. Vérifier que la partie existe
|
||||
$stmt = $db->prepare("SELECT id FROM games WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
if (!$stmt->fetch()) {
|
||||
throw new Exception("La partie n'existe pas.");
|
||||
}
|
||||
|
||||
// 2. Faire en sorte que le dealer de la partie soit le joueur suivant l'actuel dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE is_dealer = 1 AND game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
$current_dealer = $stmt->fetch();
|
||||
if ($current_dealer) {
|
||||
$current_dealer_id = $current_dealer['id'];
|
||||
// On remet à 0 le dealer actuel
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 0 WHERE id = ?");
|
||||
$stmt->execute([$current_dealer_id]);
|
||||
// On cherche le prochain dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? AND id > ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id, $current_dealer_id]);
|
||||
$next_dealer = $stmt->fetch();
|
||||
if (!$next_dealer) { // Si on est au dernier, on revient au premier
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$next_dealer = $stmt->fetch();
|
||||
}
|
||||
$next_dealer_id = $next_dealer['id'];
|
||||
// On met à jour le nouveau dealer
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?");
|
||||
$stmt->execute([$next_dealer_id]);
|
||||
} else {
|
||||
// Si aucun dealer n'est défini, on choisit le premier joueur comme dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$first_player = $stmt->fetch();
|
||||
if ($first_player) {
|
||||
$first_player_id = $first_player['id'];
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?");
|
||||
$stmt->execute([$first_player_id]);
|
||||
} else {
|
||||
throw new Exception("Aucun joueur dans la partie pour devenir dealer.");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. On réveille les joueurs endormis
|
||||
$stmt = $db->prepare("UPDATE players SET is_folded = 0 WHERE game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => "Nouvelle partie commencée, dealer mis à jour."]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
session_start();
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$game_id = intval($_POST['game_id']);
|
||||
|
||||
try {
|
||||
|
||||
// 1. Vérifier que la partie existe
|
||||
$stmt = $db->prepare("SELECT id FROM games WHERE id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
if (!$stmt->fetch()) {
|
||||
throw new Exception("La partie n'existe pas.");
|
||||
}
|
||||
|
||||
// 2. Faire en sorte que le dealer de la partie soit le joueur suivant l'actuel dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE is_dealer = 1 AND game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
$current_dealer = $stmt->fetch();
|
||||
if ($current_dealer) {
|
||||
$current_dealer_id = $current_dealer['id'];
|
||||
// On remet à 0 le dealer actuel
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 0 WHERE id = ?");
|
||||
$stmt->execute([$current_dealer_id]);
|
||||
// On cherche le prochain dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? AND id > ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id, $current_dealer_id]);
|
||||
$next_dealer = $stmt->fetch();
|
||||
if (!$next_dealer) { // Si on est au dernier, on revient au premier
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$next_dealer = $stmt->fetch();
|
||||
}
|
||||
$next_dealer_id = $next_dealer['id'];
|
||||
// On met à jour le nouveau dealer
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?");
|
||||
$stmt->execute([$next_dealer_id]);
|
||||
} else {
|
||||
// Si aucun dealer n'est défini, on choisit le premier joueur comme dealer
|
||||
$stmt = $db->prepare("SELECT id FROM players WHERE game_id = ? ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([$game_id]);
|
||||
$first_player = $stmt->fetch();
|
||||
if ($first_player) {
|
||||
$first_player_id = $first_player['id'];
|
||||
$stmt = $db->prepare("UPDATE players SET is_dealer = 1 WHERE id = ?");
|
||||
$stmt->execute([$first_player_id]);
|
||||
} else {
|
||||
throw new Exception("Aucun joueur dans la partie pour devenir dealer.");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. On réveille les joueurs endormis
|
||||
$stmt = $db->prepare("UPDATE players SET is_folded = 0 WHERE game_id = ?");
|
||||
$stmt->execute([$game_id]);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => "Nouvelle partie commencée, dealer mis à jour."]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
require_once 'db.php'; // On n'appelle plus config.php qui pollue avec son HTML
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
if (!isset($_POST['player_id'], $_POST['amount'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Données manquantes']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$player_id = intval($_POST['player_id']);
|
||||
$amount = intval($_POST['amount']);
|
||||
|
||||
// On met à jour
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + :amount WHERE id = :id");
|
||||
$stmt->execute([
|
||||
':amount' => $amount,
|
||||
':id' => $player_id
|
||||
]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
<?php
|
||||
require_once 'db.php'; // On n'appelle plus config.php qui pollue avec son HTML
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
if (!isset($_POST['player_id'], $_POST['amount'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Données manquantes']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$player_id = intval($_POST['player_id']);
|
||||
$amount = intval($_POST['amount']);
|
||||
|
||||
// On met à jour
|
||||
$stmt = $db->prepare("UPDATE players SET money = money + :amount WHERE id = :id");
|
||||
$stmt->execute([
|
||||
':amount' => $amount,
|
||||
':id' => $player_id
|
||||
]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user