osekour
This commit is contained in:
@@ -5,20 +5,36 @@ 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)
|
||||
function getJoueursPosition(int $idpartie, int $tour, int $pos)
|
||||
{
|
||||
$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;
|
||||
return get_infos_requete("SELECT idjoueur FROM est_en_position WHERE idpartie = "
|
||||
. $idpartie . " AND position = " . $pos . " AND num_tour = " . $tour)['instances'];
|
||||
}
|
||||
|
||||
function get_parties_id() {
|
||||
$parties = get_infos_requete("SELECT idpartie FROM partie")['instances'];
|
||||
function partie_est_a_venir(int $idpartie) {
|
||||
return !empty(get_infos_requete("SELECT idpartie FROM partie WHERE idpartie = " .
|
||||
$idpartie . " AND etat = 'a venir'")['instances']);
|
||||
}
|
||||
|
||||
function get_parties_tour(int $idpartie): int {
|
||||
$tour = get_infos_requete("SELECT * FROM tour WHERE idpartie = "
|
||||
. $idpartie . " ORDER BY num_tour DESC LIMIT 1")['instances'];
|
||||
|
||||
if (empty($tour)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $tour[0]['num_tour'];
|
||||
}
|
||||
|
||||
function getCards(int $idpartie)
|
||||
{
|
||||
return get_infos_requete("SELECT img, idcarte FROM carte JOIN est_compose USING(idcarte) JOIN partie USING(idplateau) WHERE idpartie = " . $idpartie . " ORDER BY rang")['instances'];
|
||||
}
|
||||
|
||||
function get_parties_id()
|
||||
{
|
||||
$parties = get_infos_requete("SELECT idpartie FROM partie WHERE etat = 'a venir'")['instances'];
|
||||
|
||||
$ids = array();
|
||||
foreach ($parties as $partie) {
|
||||
@@ -28,4 +44,8 @@ function get_parties_id() {
|
||||
return $ids;
|
||||
}
|
||||
|
||||
function lancer_partie(int $idpartie) {
|
||||
executer_une_requete("UPDATE partie SET etat = 'en cours' WHERE idpartie = " . $idpartie);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -66,6 +66,10 @@ function afficher_joueurs(int $idpartie)
|
||||
|
||||
function formulaire_ajout_joueurs(int $idpartie)
|
||||
{
|
||||
$joueursPartie = getJoueursPartie($idpartie);
|
||||
if (sizeof($joueursPartie) >= 8) {
|
||||
return;
|
||||
}
|
||||
$joueurs = getJoueurs();
|
||||
echo '<form class="ajouter_joueurs_partie" method="post" action="#">';
|
||||
echo '<select id="joueurs" name="joueur">';
|
||||
@@ -104,7 +108,9 @@ function formulaire_ordre_joueurs(int $idpartie)
|
||||
echo '<option value="honneurJeune">Honneur au plus jeune</option>';
|
||||
echo '<option value="honneurNul">Honneur au moins expériementé</option>';
|
||||
echo '</select>';
|
||||
echo '<input type="submit" name="validerOrdre" value="Mettre en place la partie" />';
|
||||
if (sizeof(getJoueursPartie($idpartie)) >= 2) {
|
||||
echo '<input type="submit" name="validerOrdre" value="Mettre en place la partie" />';
|
||||
}
|
||||
echo '<input type="hidden" name="idpartie" value="' . $idpartie . '" />';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<?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);
|
||||
@@ -16,36 +23,44 @@ function afficher_joueurs(int $idpartie)
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function afficherCarte(string $nomcarte, int $numero): void
|
||||
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) {
|
||||
if ($numero != 0 && $numero != 13) {
|
||||
echo '<p>' . $numero . '</p>';
|
||||
} else {
|
||||
echo '<p>X</p>';
|
||||
}
|
||||
afficher_pions($joueurs);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function afficher_depart(): void
|
||||
function afficher_depart($joueurs): void
|
||||
{
|
||||
afficherCarte("carteDépart.png", 0);
|
||||
afficherCarte("carteDépart.png", 0, $joueurs);
|
||||
}
|
||||
|
||||
function afficher_arrivee(): void
|
||||
{
|
||||
afficherCarte("carteArrivée.png", 0);
|
||||
afficherCarte("carteArrivée.png", 13, []);
|
||||
}
|
||||
|
||||
function afficherCartes(int $idpartie): void
|
||||
function afficherCartes(int $idpartie, int $tour): void
|
||||
{
|
||||
$cartes = getCardsName($idpartie);
|
||||
$cartes = getCards($idpartie);
|
||||
|
||||
echo '<div>';
|
||||
afficher_depart();
|
||||
for ($i = 0; $i < sizeof($cartes); $i++) {
|
||||
afficherCarte($cartes[$i], $i + 1);
|
||||
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>';
|
||||
@@ -64,9 +79,16 @@ function formulaire_selection_partie()
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
function formulaire_selection_des_main()
|
||||
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="jouerPartie_controleur.php" method="post">
|
||||
echo '<form action="#" method="post">
|
||||
<div class="tab">
|
||||
<label for="desBleus">Nombre de dés bleus :</label>
|
||||
<input type="number" id="desBleus" name="desBleus">
|
||||
@@ -80,6 +102,7 @@ function formulaire_selection_des_main()
|
||||
<input type="number" id="desRouges" name="desRouges">
|
||||
</div>
|
||||
<input type="submit" value="Enregistrer la main">
|
||||
<input type="hidden" name="idpartie" value="' . $idpartie . '"/>
|
||||
</form>';
|
||||
}
|
||||
|
||||
@@ -95,13 +118,20 @@ function formulaire_selection_des_main()
|
||||
|
||||
if (isset($_POST['idpartie'])) {
|
||||
$idpartie = (int) $_POST['idpartie'];
|
||||
if (isset($_POST['lancerPartie'])) {
|
||||
lancer_partie($idpartie);
|
||||
}
|
||||
afficher_joueurs($idpartie);
|
||||
afficherCartes($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();
|
||||
}
|
||||
|
||||
formulaire_selection_des_main();
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user