You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.0 KiB

<?php
class Controlleur
{
public function __construct() {
global $rep,$vues;
try{
$action=$_REQUEST['action'];
switch($action){
case NULL:
$this->homePage();
break;
case "deal":
$this->game();
break;
case "VoirScore":
$this->afficherScore();
break;
case "Option":
$this->optionDeJeu();
break;
default:
$dVueEreur[] = "Erreur d'appel php";
require ($rep.$vues['error']);
break;
}
} catch (PDOException $e)
{
echo $e->getMessage();
$dVueEreur[] = "Erreur inattendue PDO!!! ";
require ($rep.$vues['error']);
}
catch (Exception $e2)
{
$dVueEreur[] = "Erreur inattendue!!! ";
require ($rep.$vues['error']);
}
}
public function homePage(){
global $vues, $rep;
require($rep . $vues['homePage']);
}
public function game(){
global $vues, $rep;
if (isset($_GET['action']) && $_GET['action'] == 'deal') {
$_SESSION['deck'] = new Deck($_GET['action']);
$_SESSION['game'] = new Game($_SESSION['deck']);
$game = $_SESSION['game'];
echo json_encode($game->start());
}else if (isset($_GET['action']) && $_GET['action'] == 'submit'){
$deck = $_SESSION['deck'];
echo json_encode($deck->threeMore());
}
require ($rep.$vues['jeu']);
}
public function afficherScore()
{
global $vues, $rep;
$listPlayer = new ModelPlayer();
try {
//$listP = $listPlayer->getScores();
} catch (Exception $e)
{
$listP = array("error" => $e->getMessage());
}
require($rep . $vues['score']);
}
}