138 lines
3.4 KiB
PHP
138 lines
3.4 KiB
PHP
<?php
|
|
|
|
function afficher_pions($joueurs)
|
|
{
|
|
foreach ($joueurs as $joueur) {
|
|
echo '<img src="img/pions/pion1.png" alt="pion1" width="50"/>';
|
|
}
|
|
}
|
|
|
|
function afficher_joueurs(int $idpartie)
|
|
{
|
|
$joueurs = getJoueursPartie($idpartie);
|
|
echo '<div>';
|
|
echo '<p>Joueurs : </p>';
|
|
foreach ($joueurs as $joueur) {
|
|
$couleur = $joueur['couleur_pion'];
|
|
$couleur_hex = "000000";
|
|
if (!is_null($couleur)) {
|
|
$couleur_hex = dechex($couleur);
|
|
}
|
|
echo '<p style="color:#' . $couleur_hex . ';">' . $joueur['pseudo'] . " (" . $joueur['prenom'] . " " . $joueur['nom'] . ')</p>';
|
|
}
|
|
echo '</div>';
|
|
}
|
|
|
|
function afficherCarte(string $nomcarte, int $numero, $joueurs): void
|
|
{
|
|
echo '<div class="unecarte">';
|
|
echo '<img src="img/cartes/' . $nomcarte . '" alt="' . $nomcarte . '" width="100" height="160"/>';
|
|
if ($numero != 0 && $numero != 13) {
|
|
echo '<p>' . $numero . '</p>';
|
|
} else {
|
|
echo '<p>X</p>';
|
|
}
|
|
afficher_pions($joueurs);
|
|
echo '</div>';
|
|
}
|
|
|
|
function afficher_depart($joueurs): void
|
|
{
|
|
afficherCarte("carteDépart.png", 0, $joueurs);
|
|
}
|
|
|
|
function afficher_arrivee(): void
|
|
{
|
|
afficherCarte("carteArrivée.png", 13, []);
|
|
}
|
|
|
|
function afficherCartes(int $idpartie, int $tour): void
|
|
{
|
|
$cartes = getCards($idpartie);
|
|
|
|
echo '<div>';
|
|
if ($tour == 0) {
|
|
afficher_depart(getJoueursPartie($idpartie));
|
|
for ($i = 0; $i < sizeof($cartes); $i++) {
|
|
afficherCarte($cartes[$i]['img'], $i + 1, []);
|
|
}
|
|
} else {
|
|
afficher_depart(getJoueursPosition($idpartie, $tour, 0));
|
|
for ($i = 0; $i < sizeof($cartes); $i++) {
|
|
afficherCarte($cartes[$i]['img'], $i + 1, []);
|
|
}
|
|
}
|
|
afficher_arrivee();
|
|
echo '</div>';
|
|
}
|
|
|
|
function formulaire_selection_partie()
|
|
{
|
|
$parties = get_parties_id();
|
|
echo '<form class="choisir_partie" method="post" action="#">';
|
|
echo '<select id="idpartie" name="idpartie">';
|
|
foreach ($parties as $partie) {
|
|
echo '<option value="' . $partie . '">' . $partie . '</option>';
|
|
}
|
|
echo '</select>';
|
|
echo '<input type="submit" name="soumettre" value="Valider"/>';
|
|
echo '</form>';
|
|
}
|
|
|
|
function formulaire_lancer_partie(int $idpartie) {
|
|
echo '<form class="lancer_partie" method="post" action="#">';
|
|
echo '<input type="submit" name="lancerPartie" value="Lancer la partie"/>';
|
|
echo '<input type="hidden" name="idpartie" value="' . $idpartie . '"/>';
|
|
echo '</form>';
|
|
}
|
|
|
|
function formulaire_selection_des_main(int $idpartie)
|
|
{
|
|
echo '<form action="#" method="post">
|
|
<div class="tab">
|
|
<label for="desBleus">Nombre de dés bleus :</label>
|
|
<input type="number" id="desBleus" name="desBleus">
|
|
</div>
|
|
<div class="tab">
|
|
<label for="desJaunes">Nombre de dés jaunes :</label>
|
|
<input type="number" id="desJaunes" name="desJaunes">
|
|
</div>
|
|
<div class="tab">
|
|
<label for="desRouges">Nombre de dés rouges :</label>
|
|
<input type="number" id="desRouges" name="desRouges">
|
|
</div>
|
|
<input type="submit" value="Enregistrer la main">
|
|
<input type="hidden" name="idpartie" value="' . $idpartie . '"/>
|
|
</form>';
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<div class="panneau_details">
|
|
|
|
<h2>Jouer une partie</h2>
|
|
|
|
<div>
|
|
<?php
|
|
|
|
if (isset($_POST['idpartie'])) {
|
|
$idpartie = (int) $_POST['idpartie'];
|
|
if (isset($_POST['lancerPartie'])) {
|
|
lancer_partie($idpartie);
|
|
}
|
|
afficher_joueurs($idpartie);
|
|
afficherCartes($idpartie, get_parties_tour($idpartie));
|
|
if (partie_est_a_venir($idpartie)) {
|
|
formulaire_lancer_partie($idpartie);
|
|
} else {
|
|
formulaire_selection_des_main($idpartie);
|
|
}
|
|
} else {
|
|
formulaire_selection_partie();
|
|
}
|
|
|
|
?>
|
|
</div>
|
|
|
|
</div>
|