la tienne

This commit is contained in:
2024-04-18 13:08:25 +02:00
parent 0b2b400091
commit 6b8034b359
2 changed files with 40 additions and 8 deletions

View File

@@ -1,5 +1,10 @@
<?php
function getJoueursPartie(int $idpartie)
{
return get_infos_requete("SELECT * FROM joue JOIN joueur J USING(idjoueur) WHERE joue.idpartie = " . $idpartie . " ORDER BY rang")['instances'];
}
function getCardsName(int $idpartie)
{
$cartes = get_infos_requete("SELECT img FROM carte JOIN est_compose USING(idcarte) JOIN partie USING(idplateau) WHERE idpartie = " . $idpartie . " ORDER BY rang")['instances'];

View File

@@ -1,29 +1,54 @@
<?php
function afficherCarte(string $nomcarte): void
function afficher_joueurs(int $idpartie)
{
echo '<img src="img/cartes/' . $nomcarte . '" alt="' . $nomcarte . '" width="200" height="320"/>';
$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): void
{
echo '<div class="unecarte">';
echo '<img src="img/cartes/' . $nomcarte . '" alt="' . $nomcarte . '" width="100" height="160"/>';
if ($numero != 0) {
echo '<p>' . $numero . '</p>';
} else {
echo '<p>X</p>';
}
echo '</div>';
}
function afficher_depart(): void
{
afficherCarte("carteDépart.png");
afficherCarte("carteDépart.png", 0);
}
function afficher_arrivee(): void
{
afficherCarte("carteArrivée.png");
afficherCarte("carteArrivée.png", 0);
}
function afficherCartes(int $idpartie): void
{
$cartes = getCardsName($idpartie);
echo '<div class="cartejesaispasquoi">';
afficher_depart();
foreach ($cartes as $carte) {
afficherCarte($carte);
for ($i = 0; $i < sizeof($cartes); $i++) {
afficherCarte($cartes[$i], $i + 1);
}
afficher_arrivee();
echo '</div>';
}
function formulaire_selection_partie()
@@ -46,11 +71,13 @@ function formulaire_selection_partie()
<h2>Jouer une partie</h2>
<div>
<div class="tamaman">
<?php
if (isset($_POST['idpartie'])) {
afficherCartes($_POST['idpartie']);
$idpartie = (int) $_POST['idpartie'];
afficher_joueurs($idpartie);
afficherCartes($idpartie);
} else {
formulaire_selection_partie();
}