diff --git a/controleurs/jouerPartie_controleur.php b/controleurs/jouerPartie_controleur.php index 82a204f..38cb595 100644 --- a/controleurs/jouerPartie_controleur.php +++ b/controleurs/jouerPartie_controleur.php @@ -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); +} + ?> \ No newline at end of file diff --git a/vues/creerPartie_vue.php b/vues/creerPartie_vue.php index 16ca38e..6916db7 100644 --- a/vues/creerPartie_vue.php +++ b/vues/creerPartie_vue.php @@ -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 '
'; } diff --git a/vues/jouerPartie_vue.php b/vues/jouerPartie_vue.php index 438eb06..c955676 100644 --- a/vues/jouerPartie_vue.php +++ b/vues/jouerPartie_vue.php @@ -1,5 +1,12 @@ '; + } +} + function afficher_joueurs(int $idpartie) { $joueurs = getJoueursPartie($idpartie); @@ -16,36 +23,44 @@ function afficher_joueurs(int $idpartie) echo ''; } -function afficherCarte(string $nomcarte, int $numero): void +function afficherCarte(string $nomcarte, int $numero, $joueurs): void { echo '' . $numero . '
'; } else { echo 'X
'; } + afficher_pions($joueurs); echo '