function checkWon() { $m = new UserGamesModel(Config::$mvc_bd_nombre, Config::$mvc_bd_usuario, Config::$mvc_bd_clave, Config::$mvc_bd_hostname); session_start(); $game = $_SESSION['game']; $nick = $_SESSION["username"]; $game = $m->getGame($game, $nick); $color = array('green' => false, 'yellow' => false, 'blue' => false, 'red' => false, 'purple' => false, 'orange' => false); foreach ($game as $g) { if ($g['PregAcertada'] == 1) { switch ($g['categoria']) { case 'Ciencia': $color['green'] = true; break; case 'Historia': $color['yellow'] = true; break; case 'Geografía': $color['blue'] = true; break; case 'Arte y literatura': $color['red'] = true; break; case 'Espectáculos': $color['purple'] = true; break; case 'Deportes': $color['orange'] = true; break; case 'Maravilloso mundo de Disney': $color['green'] = true; break; case 'Monstruos y villanos': $color['yellow'] = true; break; case 'Había una vez': $color['blue'] = true; break; case 'Lugares y objetos': $color['red'] = true; break; case 'Estrellas secundarias': $color['purple'] = true; break; case 'Héroes y heroínas': $color['orange'] = true; break; } } } foreach ($color as $c) { if ($c == false) { echo false; return; } } echo true; return; }
public function game() { $m = new UserGamesModel(Config::$mvc_bd_nombre, Config::$mvc_bd_usuario, Config::$mvc_bd_clave, Config::$mvc_bd_hostname); $_SESSION['game'] = $_POST['game']; $game = $_POST['game']; $nick = $_SESSION["username"]; $params = array('game' => $m->getGame($game, $nick), 'world' => $m->getWorld($game), 'level' => $m->getLevel($nick)); if ($params['game'] == 'GameFinished') { $text = "UPS! Esta partida ya no está en juego!"; require __DIR__ . '/templates/errorGame.php'; } else { if ($params['game'] == 'NotYourTurn') { $text = "UPS! No es tu turno en esta partida!"; require __DIR__ . '/templates/errorGame.php'; } else { require __DIR__ . '/templates/game.php'; } } }
<?php require_once '../Config.php'; require_once '../UserGamesModel.php'; $m = new UserGamesModel(Config::$mvc_bd_nombre, Config::$mvc_bd_usuario, Config::$mvc_bd_clave, Config::$mvc_bd_hostname); session_start(); $game = $_SESSION['game']; $nick = $_SESSION["username"]; $params = array('game' => $m->getGame($game, $nick), 'world' => $m->getWorld($game)); if ($params['game'] != 'GameFinished') { $color = array('green' => '#C6C6C6', 'yellow' => '#C6C6C6', 'blue' => '#C6C6C6', 'red' => '#C6C6C6', 'purple' => '#C6C6C6', 'orange' => '#C6C6C6'); foreach ($params['game'] as $game) { if ($game['PregAcertada'] == 1) { switch ($game['categoria']) { case 'Ciencia': $color['green'] = '#00FF00'; break; case 'Historia': $color['yellow'] = '#FFFF00'; break; case 'Geografía': $color['blue'] = '#00FFF7'; break; case 'Arte y literatura': $color['red'] = '#FF0000'; break; case 'Espectáculos': $color['purple'] = '#FF00F3'; break; case 'Deportes': $color['orange'] = '#FFAF00';