on peut voir les cartes d'une partie
This commit is contained in:
26
controleurs/jouerPartie_controleur.php
Normal file
26
controleurs/jouerPartie_controleur.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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'];
|
||||||
|
|
||||||
|
$noms = array();
|
||||||
|
foreach ($cartes as $carte) {
|
||||||
|
array_push($noms, $carte['img']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $noms;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_parties_id() {
|
||||||
|
$parties = get_infos_requete("SELECT idpartie FROM partie")['instances'];
|
||||||
|
|
||||||
|
$ids = array();
|
||||||
|
foreach ($parties as $partie) {
|
||||||
|
array_push($ids, $partie['idpartie']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
61
vues/jouerPartie_vue.php
Normal file
61
vues/jouerPartie_vue.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function afficherCarte(string $nomcarte): void
|
||||||
|
{
|
||||||
|
echo '<img src="img/cartes/' . $nomcarte . '" alt="' . $nomcarte . '" width="200" height="320"/>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function afficher_depart(): void
|
||||||
|
{
|
||||||
|
afficherCarte("carteDépart.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
function afficher_arrivee(): void
|
||||||
|
{
|
||||||
|
afficherCarte("carteArrivée.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
function afficherCartes(int $idpartie): void
|
||||||
|
{
|
||||||
|
$cartes = getCardsName($idpartie);
|
||||||
|
|
||||||
|
afficher_depart();
|
||||||
|
foreach ($cartes as $carte) {
|
||||||
|
afficherCarte($carte);
|
||||||
|
}
|
||||||
|
afficher_arrivee();
|
||||||
|
}
|
||||||
|
|
||||||
|
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>';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="panneau_details">
|
||||||
|
|
||||||
|
<h2>Jouer une partie</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_POST['idpartie'])) {
|
||||||
|
afficherCartes($_POST['idpartie']);
|
||||||
|
} else {
|
||||||
|
formulaire_selection_partie();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user