diff --git a/SRC/app/Http/Controllers/GameController.php b/SRC/app/Http/Controllers/GameController.php index ce9bea7..94ba20e 100755 --- a/SRC/app/Http/Controllers/GameController.php +++ b/SRC/app/Http/Controllers/GameController.php @@ -25,43 +25,45 @@ class GameController extends Controller { public function chooseDifMemo() { return view('frontend/memo_level'); } - + 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(5)->get(); + $oes = Oeuvre::orderByRaw("RAND()")->take(5)->get(); } - return view('frontend/memo', ['oeuvres' => $oes, 'niveau' => $niveau]); + $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(); @@ -85,7 +87,7 @@ class GameController extends Controller { $listeOeuvre = $ListeOeuvre = ListeOeuvre::ofUser($id)->activeListOeuvre()->first(); if($listeOeuvre == '') $games = []; - else + else $games = $listeOeuvre->jeux()->get(); return view('referent_games', ['games' => $games]); diff --git a/SRC/public/js/memory.js b/SRC/public/js/memory.js index 6895eae..5da9b2f 100644 --- a/SRC/public/js/memory.js +++ b/SRC/public/js/memory.js @@ -31,10 +31,11 @@ * */ - function Memory( options, level ) { + function Memory( options, level, nbcase ) { + console.log(nbcase); this.options = extend( {}, this.options ); extend( this.options, options ); - this._init(level); + this._init(level, nbcase); } /** @@ -44,7 +45,7 @@ * ready for game setup. */ - Memory.prototype._init = function(level) { + Memory.prototype._init = function(level,nbcase) { this.game = document.createElement("div"); this.game.id = "mg"; this.game.className = "mg"; @@ -65,7 +66,7 @@ this.gameMessages.id = "mg__onend"; this.gameMessages.className = "mg__onend"; - this._setupGame(level); + this._setupGame(level,nbcase); }; /** @@ -85,7 +86,7 @@ * 3 : game is finished */ - Memory.prototype._setupGame = function(level) { + Memory.prototype._setupGame = function(level, nbcase) { var self = this; this.gameState = 1; this.cards = shuffle(this.options.cards); @@ -98,7 +99,7 @@ this.flippedTiles = 0; this.chosenLevel = ""; this.numMoves = 0; - this._setupGameWrapper(level); + this._setupGameWrapper(level, nbcase); } /** @@ -108,7 +109,8 @@ * tiles will reside and where all the game play happens. */ - Memory.prototype._setupGameWrapper = function(levelNode) { + Memory.prototype._setupGameWrapper = function(levelNode,nbcase) { + this.nbcase = nbcase; this.level = levelNode; this.gameContents.className = "mg__contents mg__level-"+this.level; this.game.appendChild(this.gameWrapper); @@ -137,7 +139,7 @@ else if(this.level == 2) {this.gridX = 3; this.gridY= 2; } else { this.gridX = 2; this.gridY=4 ; } // this.gridY = this.gridX ; - this.numTiles = this.gridX * this.gridY; + this.numTiles = this.nbcase*2; //this.halfNumTiles = this.gridX; this.halfNumTiles = this.numTiles/2; this.newCards = []; @@ -234,8 +236,8 @@ */ "document"in self&&("classList"in document.createElement("_")?!function(){"use strict";var a=document.createElement("_");if(a.classList.add("c1","c2"),!a.classList.contains("c2")){var b=function(a){var b=DOMTokenList.prototype[a];DOMTokenList.prototype[a]=function(a){var c,d=arguments.length;for(c=0;d>c;c++)a=arguments[c],b.call(this,a)}};b("add"),b("remove")}if(a.classList.toggle("c3",!1),a.classList.contains("c3")){var c=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(a,b){return 1 in arguments&&!this.contains(a)==!b?b:c.call(this,a)}}a=null}():!function(a){"use strict";if("Element"in a){var b="classList",c="prototype",d=a.Element[c],e=Object,f=String[c].trim||function(){return this.replace(/^\s+|\s+$/g,"")},g=Array[c].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},h=function(a,b){this.name=a,this.code=DOMException[a],this.message=b},i=function(a,b){if(""===b)throw new h("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new h("INVALID_CHARACTER_ERR","String contains an invalid character");return g.call(a,b)},j=function(a){for(var b=f.call(a.getAttribute("class")||""),c=b?b.split(/\s+/):[],d=0,e=c.length;e>d;d++)this.push(c[d]);this._updateClassName=function(){a.setAttribute("class",this.toString())}},k=j[c]=[],l=function(){return new j(this)};if(h[c]=Error[c],k.item=function(a){return this[a]||null},k.contains=function(a){return a+="",-1!==i(this,a)},k.add=function(){var a,b=arguments,c=0,d=b.length,e=!1;do a=b[c]+"",-1===i(this,a)&&(this.push(a),e=!0);while(++c @endsection @@ -17,7 +17,7 @@ @section('page-scripts') -@endsection \ No newline at end of file +@endsection