* @copyright 2023 Bartolomé Sintes Marco * @license http://www.gnu.org/licenses/agpl.txt AGPL 3 or later * @version 2023-12-05 * @link https://www.mclibre.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ // Se accede a la sesión session_name("simon-2"); session_start(); $longitud = rand(2, 7); $colores = ["red", "yellow", "green", "blue"]; if (!isset($_SESSION["objetivo"]) || !isset($_SESSION["jugador"]) || !isset($_SESSION["fallo"]) || !isset($_SESSION["completado"])) { for ($i = 0; $i < $longitud; $i++) { $_SESSION["objetivo"][] = $colores[array_rand($colores)]; } $_SESSION["jugador"] = []; $_SESSION["fallo"] = false; $_SESSION["completado"] = false; } ?> Simon (2). Minijuegos. Sesiones. Ejercicios. PHP. Bartolomé Sintes Marco. www.mclibre.org

Simon (2)

Secuencia a reproducir:

\n"; print "\n"; print "

\n"; foreach ($_SESSION["objetivo"] as $color) { print " \n"; print " \n"; } print "

\n"; print "\n"; ?>

Haga clic en los colores:

Colores elegidos:

\n"; print "\n"; print "

\n"; foreach ($_SESSION["jugador"] as $color) { print " \n"; print " \n"; } print "

\n"; } if ($_SESSION["fallo"]) { print "

¡Lo siento! Se ha equivocado. Pulse Reiniciar para comenzar de nuevo.

\n"; print "\n"; } if ($_SESSION["completado"]) { print "

¡Enhorabuena! Ha repetido correctamente la secuencia. Pulse Reiniciar para comenzar de nuevo.

\n"; print "\n"; } ?>