This commit is contained in:
sidya82 2015-03-20 18:41:46 +01:00
commit c88eb5ff23
29 changed files with 106 additions and 33 deletions

109
SRC/app/Http/Controllers/GameController.php Normal file → Executable file
View File

@ -5,7 +5,6 @@ use App\Referent;
use App\ConfigJeu;
use App\Oeuvre;
use Cookie;
class GameController extends Controller {
/**
@ -24,10 +23,8 @@ class GameController extends Controller {
* @return Response
*/
public function chooseDifMemo() {
return view('frontend/memo_level');
}
public function chooseDifPuzzle() {
return view('frontend/puzzle_level');
$nbOr = Cookie::get('referent');
return view('frontend/memo_level', ['nbOr' => $nbOr]);
}
public function playMemo($niveau) {
@ -46,30 +43,98 @@ class GameController extends Controller {
return view('frontend/memo', ['oeuvres' => $oes, 'niveau' => $niveau, 'nbBloc'=>$bloc]);
}
public function chooseDifPuzzle() {
return view('frontend/puzzle_level');
}
public function playPuzzle($niveau) {
try {
$idRef = Cookie::get('referent');
$ref = Referent::findOrFail($idRef);
$configjeu = $ref->configjeu()->where('actifPuzzle', '=', '1')->firstOrFail();
if(count($configjeu->oeuvres->count()) >= 1) {
$oes = $configjeu->oeuvres()->select('image')->get();
$params = json_decode($configjeu->parametres);
$nbTab = $params->pt;
$dimension = $params->{"p" . $niveau};
if(!(isset($dimension) && is_numeric($dimension))) throw new ModelNotFoundException();
} else throw new ModelNotFoundException();
} catch(ModelNotFoundException $e) {
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->select('image')->get();
$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, 'niveau' => $niveau]);
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]);
}
public function index() {
$res = User::referents()->get();
return view('home', ['referent' => $res]);
/**
* 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]);
}
public function setRecords($idTrophee) {
$values = Cookie::get('trophee');
if ($values === false)
$values = [0, 0, 0];
switch ($idTrophee) {
case '1':
$values[0]++;
break;
case '2':
$values[1]++;
break;
case '3':
$values[2]++;
break;
default:
break;
}
$response->withCookie(Cookie::forever('trophee', $values));
}
}

0
SRC/app/Http/Controllers/ImageController.php Normal file → Executable file
View File

0
SRC/public/css/bootstrap-sandstone.min.css vendored Normal file → Executable file
View File

0
SRC/public/css/frontend.css Normal file → Executable file
View File

0
SRC/public/fonts/glyphicons-halflings-regular.eot Normal file → Executable file
View File

0
SRC/public/fonts/glyphicons-halflings-regular.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

0
SRC/public/fonts/glyphicons-halflings-regular.ttf Normal file → Executable file
View File

0
SRC/public/fonts/glyphicons-halflings-regular.woff Normal file → Executable file
View File

0
SRC/public/fonts/glyphicons-halflings-regular.woff2 Normal file → Executable file
View File

0
SRC/public/imgs/Search.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
SRC/public/imgs/adminbg.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 219 KiB

0
SRC/public/imgs/adminbgOrgi.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 429 KiB

After

Width:  |  Height:  |  Size: 429 KiB

0
SRC/public/imgs/avatar/7.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

0
SRC/public/imgs/bg.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

0
SRC/public/imgs/favicon.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

0
SRC/public/imgs/games.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

0
SRC/public/imgs/home.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

0
SRC/public/imgs/memo/memo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

0
SRC/public/imgs/memo/memo2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

0
SRC/public/imgs/previouspage.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

0
SRC/public/imgs/puzzle.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
SRC/public/imgs/puzzle/puzzle.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

0
SRC/public/imgs/trophees/argent.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

0
SRC/public/imgs/trophees/or.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 236 KiB

0
SRC/public/js/firework.js Normal file → Executable file
View File

0
SRC/resources/views/auth/reset.blade.php Normal file → Executable file
View File

View File

@ -10,13 +10,21 @@
<div class="game" onclick="location.href='{{ URL::to('memo') }}'"><img src="imgs/memo/memo2.png"></div>
<div class="game" onclick="location.href='{{ URL::to('puzzle') }}'"><img src="imgs/puzzle/puzzle.png"></div>
<div style="line-height:50px;"><img style="height:50px; vertical-align:middle;width:50px" src="{{ URL::to('imgs/trophees/or.png') }}"><span style="vertical-align:middle;font-size:20px">1</span>
<br>
<div style="display:inline-block;">
<img style="height:100px; vertical-align:middle;width:100px" src="{{ URL::to('imgs/trophees/bronze.png') }}"><br>
{{$nbBronze}}
</div>
<div style="display:inline-block;">
<img style="height:100px; vertical-align:middle;width:100px" src="{{ URL::to('imgs/trophees/argent.png') }}"><br>
{{$nbArgent}}
</div>
<div style="display:inline-block;">
<img style="height:100px; vertical-align:middle;width:100px" src="{{ URL::to('imgs/trophees/or.png') }}"><br>
{{$nbOr}}
</div>
<img style="height:50px; vertical-align:middle;width:50px" src="{{ URL::to('imgs/trophees/or.png') }}"><span style="vertical-align:middle;font-size:20px">2</span>
<img style="height:50px; vertical-align:middle;width:50px" src="{{ URL::to('imgs/trophees/or.png') }}"><span style="vertical-align:middle;font-size:20px">4</span>
</div>
</div>
@endsection

View File

@ -18,9 +18,9 @@
}
function preload () {
game.load.spritesheet('balls', '{{ URL::to('imgs/puzzle/balls.png') }}', 17, 17);
game.load.image('trophee3', '{{ URL::to('imgs/trophees/or.png') }}');
game.load.image('trophee2', '{{ URL::to('imgs/trophees/argent.png') }}');
game.load.image('trophee1', '{{ URL::to('imgs/trophees/bronze.png') }}');
game.load.image('trophy3', '{{ URL::to('imgs/trophees/or.png') }}');
game.load.image('trophy2', '{{ URL::to('imgs/trophees/argent.png') }}');
game.load.image('trophy1', '{{ URL::to('imgs/trophees/bronze.png') }}');
for(i=1; i<=selection.length; i++) {
game.load.spritesheet("tableau"+i, selection[i-1].src, selection[i-1].width/dimensions[0], selection[i-1].height/dimensions[1]);
@ -173,15 +173,15 @@
pieces.forEach(function(item){game.add.tween(item).to( { alpha: 0 }, 1000).start();});
var trophee = game.world.create(game.world.centerX,game.world.centerY, "trophee");
var trophee = game.world.create(game.world.centerX,game.world.centerY, ("trophy"+trophy));
trophee.anchor.setTo(0.5,0.5);
trophee.width = 270;
trophee.height = 270;
trophee.alpha = 0;
tween = game.add.tween(trophee).to( { alpha: 1 }, 1000).start();
setTimeout(function(){
location.href = "{{URL::to('/')}}";
}, 4000);
location.href = "{{URL::to('puzzle/jouer')}}" + "/" + trophy;
}, 5000);
// TODO appel ajax
//var t1 = game.world.create(game.world.centerX,game.world.centerY, "tableau1");
//t1.anchor.setTo(0.5,0.5);