...
This commit is contained in:
parent
164bb95eca
commit
30248ae4ef
6039 changed files with 3364 additions and 2287 deletions
54
pfosten/app/Http/Controllers/UsersController.php
Normal file → Executable file
54
pfosten/app/Http/Controllers/UsersController.php
Normal file → Executable file
|
|
@ -17,7 +17,6 @@ class UsersController extends Controller
|
|||
{
|
||||
public function main() {
|
||||
|
||||
|
||||
return view('main');
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +28,6 @@ class UsersController extends Controller
|
|||
return view('users.index', compact('users'));
|
||||
}
|
||||
|
||||
|
||||
public function showUsers() {
|
||||
$users = DB::table('users')->get();
|
||||
return view('users.list', compact('users'));
|
||||
|
|
@ -37,14 +35,11 @@ class UsersController extends Controller
|
|||
|
||||
// Route-Model binding, because parameter in web.php route has same name as functionparameter
|
||||
public function showUser(User $userObject) {
|
||||
|
||||
//return $userObject; // If you want it as a JSON object
|
||||
|
||||
//$user = DB::table('users')->find($id);
|
||||
return view('users.show', compact('userObject'));
|
||||
}
|
||||
|
||||
|
||||
public function edit($user_id) {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
|
@ -111,8 +106,9 @@ class UsersController extends Controller
|
|||
|
||||
$highestDayScore=0;
|
||||
|
||||
// Tagessieg
|
||||
foreach($users as $user) {
|
||||
Log::info("User: ".$user->id.", ".$user->fullname);
|
||||
//Log::info("User: ".$user->id.", ".$user->fullname);
|
||||
$user->totalScore=0; // Summe Ranglisten-Punkte bis heute
|
||||
$user->dayScore=0; // Heute gemachte Ranglisten-Punkte
|
||||
|
||||
|
|
@ -123,14 +119,18 @@ class UsersController extends Controller
|
|||
$games=Game::where('round_id','=',$round->id)->get();
|
||||
//Log::info('Nr of games found: '.count($games)." game->id=".$round->id." user->id=".$user->id );
|
||||
|
||||
|
||||
foreach($games as $game) {
|
||||
//Log::info("game->id=".$game->id.", $user->id=".$user->id);
|
||||
if ($user->id==1) {Log::info("game-id=".$game->id.", user-id=".$user->id);}
|
||||
$tipp = Tipp::where([['game_id','=',$game->id],['user_id','=',$user->id]])->first();
|
||||
if ($tipp) {
|
||||
$score = Tipp::getDayScoreLocal($game->score1,$game->score2,$tipp->score1,$tipp->score2,$tipp->joker);
|
||||
//Log::info("Tipp=".$tipp->id." score=".$score);
|
||||
if ($score > $user->dayWinScore) { $user->dayWinScore=$score; }
|
||||
if ($score > $highestDayScore) { $highestDayScore=$score;}
|
||||
|
||||
if ($score > $user->dayWinScore) {
|
||||
$user->dayWinScore = $score;
|
||||
|
||||
}
|
||||
if ($score > $highestDayScore) { $highestDayScore = $score; }
|
||||
|
||||
} else {
|
||||
Log::info("No tipp found for game_id=".$game->id.", user_id=".$user->id);
|
||||
|
|
@ -138,18 +138,39 @@ class UsersController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$rounds=Round::where([['season_id','=',$currentSeason->id],['id','<=',$round_id]])->orderBy('id')->get();
|
||||
|
||||
//Tendency Key=UserID_Runde
|
||||
$tendencies=array('0_0'=>0);
|
||||
|
||||
|
||||
// Punktrangliste
|
||||
$rounds=Round::where([['season_id','=',$currentSeason->id],['id','<=',$round_id]])->orderBy('id')->get();
|
||||
foreach($rounds as $round) {
|
||||
|
||||
$games=Game::where('round_id','=',$round->id)->orderBy('id')->get();
|
||||
$index=0;
|
||||
|
||||
|
||||
foreach($games as $game) {
|
||||
foreach($users as $user) {
|
||||
|
||||
$key = $user->id."_".$round->id;
|
||||
$user->tendencyCount=0;// 4 correct tendencies ==> +2 bonus score
|
||||
$tipp = Tipp::where('game_id','=',$game->id)->where('user_id','=',$user->id)->first();
|
||||
|
||||
if ($tipp) {
|
||||
// Ranglisten-Punkte berechen
|
||||
$score = Tipp::getScoreLocal($game->score1,$game->score2,$tipp->score1,$tipp->score2,$tipp->joker);
|
||||
|
||||
if ($score>0) {
|
||||
|
||||
if (!array_key_exists($key,$tendencies)) { $tendencies[$key]=0; }
|
||||
$tendencies[$key]+=1;
|
||||
|
||||
if ($user->id==1) {
|
||||
Log::info("Triggered tendency bonus for userid ".$user->id." gameid ".$game->id." roundid ".$round->id." tippid ".$tipp->id." tendency=". $tendencies[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$user->totalScore += $score;
|
||||
|
||||
if ($game->round_id == $round_id) {
|
||||
|
|
@ -160,6 +181,15 @@ class UsersController extends Controller
|
|||
$tippDisplay[$user->id][$game->id][1] = $tipp->score2 ==-1 ? 'x' : $tipp->score2;
|
||||
$tippDisplay[$user->id][$game->id][2] = $tipp->joker;
|
||||
}
|
||||
|
||||
// Increase score here
|
||||
if (array_key_exists($key,$tendencies)) {
|
||||
if ($tendencies[$key] == 4) {
|
||||
Log::info("Increasing score ! userid=" . $user->id . ", gameid " . $game->id . ", roundid " . $round->id . ", tippid " . $tipp->id . ", tendency=" . $tendencies[$key]);
|
||||
$user->totalScore += 2;
|
||||
$user->dayScore+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
$index+=1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue