create party view
This commit is contained in:
72
vues/creerPartie_vue.php
Normal file
72
vues/creerPartie_vue.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
function champs_cartes($nom, $titre) {
|
||||
|
||||
$nbCartes = 1;
|
||||
|
||||
if (isset($_POST[$nom])) {
|
||||
$nbCartes = (int) $_POST[$nom];
|
||||
}
|
||||
|
||||
echo '<select id="' . $nom . '" name="' . $nom . '">';
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
echo '<option value="' . $i . '"';
|
||||
if ($i == $nbCartes) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>' . $i . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
echo '<label for="' . $nom . '">' . $titre . '</label><br/>';
|
||||
|
||||
if (isset($_POST[$nom])) {
|
||||
return (int) $_POST[$nom];
|
||||
}
|
||||
|
||||
return (int) 0;
|
||||
}
|
||||
|
||||
function afficher_formulaire() {
|
||||
$total = 0;
|
||||
|
||||
echo '<form class="formulaire_partie" method="post" action="#">';
|
||||
|
||||
$total += champs_cartes('nbCartesVertes', 'Nombre de cartes vertes');
|
||||
$total += champs_cartes('nbCartesOranges', 'Nombre de cartes oranges');
|
||||
$total += champs_cartes('nbCartesNoires', 'Nombre de cartes noires');
|
||||
|
||||
|
||||
if($total > 0) {
|
||||
echo '<div>Total : ' . $total . '</div>';
|
||||
if ($total > 10) {
|
||||
echo '<div> Trop de cartes !!!!!!</div>';
|
||||
} else {
|
||||
echo '<input type="submit" name="creerPartie" value="Créer une partie" />';
|
||||
}
|
||||
}
|
||||
|
||||
echo '<input type="submit" name="validerCartes" value="Valider le nombre de cartes" />';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="panneau_details">
|
||||
|
||||
<h2>Créer une partie</h2>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['creerPartie'])) {
|
||||
$total = (int)$_POST['nbCartesVertes'] + (int)$_POST['nbCartesOranges'] + (int)$_POST['nbCartesNoires'];
|
||||
if ($total < 10) {
|
||||
creerPartie($_POST['nbCartesVertes'], $_POST['nbCartesOranges'], $_POST['nbCartesNoires']);
|
||||
} else {
|
||||
afficher_formulaire();
|
||||
}
|
||||
} else {
|
||||
afficher_formulaire();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user