From 3c8f636146a1a8c2fb27241d3bf009ffed2b0a1e Mon Sep 17 00:00:00 2001 From: DonRenando Date: Wed, 18 Mar 2015 14:47:15 +0100 Subject: [PATCH] Create GameController.php --- SRC/app/Http/Controllers/GameController.php | 110 ++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 SRC/app/Http/Controllers/GameController.php diff --git a/SRC/app/Http/Controllers/GameController.php b/SRC/app/Http/Controllers/GameController.php new file mode 100644 index 0000000..0f1372c --- /dev/null +++ b/SRC/app/Http/Controllers/GameController.php @@ -0,0 +1,110 @@ + $nbOr]); + } + + public function playMemo($niveau) { + $idRef = Cookie::get('referent'); + $configjeu = Referent::find($idRef)->configjeu()->where('actifMemo', '=', '1')->first(); + if($configjeu && count($configjeu->oeuvres) >= 1) { + $oes = $configjeu->oeuvres; + } else { + $oes = Oeuvre::orderByRaw("RAND()")->take(8)->get(); + $niveau = 1; + } + $params = json_decode($configjeu->parametres); + + return view('frontend/memo', ['oeuvres' => $oes, 'niveau' => $niveau, 'nbBloc'=>$params->{"m".$niveau}]); + } + + public function chooseDifPuzzle() { + return view('frontend/puzzle_level'); + } + + public function playPuzzle($niveau) { + + $idRef = Cookie::get('referent'); + $ref = Referent::find($idRef); + $configjeu = $ref->configjeu()->where('actifPuzzle', '=', '1')->first(); + + if($configjeu && count($configjeu->oeuvres) >= 1) { + $oes = $configjeu->oeuvres; + $params = json_decode($configjeu->parametres); + $nbTab = $params->pt; + $dimension = $params->{ "p".$niveau}; + + } else { + $oes = Oeuvre::orderByRaw("RAND()")->take(5)->get(); + $nbTab = 3; + $dimension = 2; + } + + return view('frontend/puzzle', ['oeuvres' => $oes, 'dimension' => $dimension, 'nbTab' => $nbTab]); + + } + public function index() + { + $res = User::referents()->get(); + return view('home',['referent' => $res]); + } + + public function findReferents($reg) { + + $res = User::referents()->name($reg)->get(); + return Response::json($res->toArray()); + } + + /** + * Show referent games + * + * @param String $id + * @return Response + */ + public function showReferentGames($id) + { + $listeOeuvre = $ListeOeuvre = ListeOeuvre::ofUser($id)->activeListOeuvre()->first(); + if($listeOeuvre == '') + $games = []; + else + $games = $listeOeuvre->jeux()->get(); + + return view('referent_games', ['games' => $games]); + } + + /** + * Show one referent game + * + * @param String $id + * @param String $idGame + * @return Response + */ + public function showOneReferentGame($id, $idGame) + { + return view('one_referent_game', ['referent' => $id, 'game' => $idGame]); + } + +}