Quotes Display & Daywin Calculation, Bugfix: 2 extra rankscore for all 4 tendencies in a round
This commit is contained in:
parent
954eca957b
commit
3fa31921f0
9 changed files with 522 additions and 31 deletions
|
|
@ -9,6 +9,7 @@ use App\Payment;
|
|||
use App\Round;
|
||||
use App\Game;
|
||||
use App\Tipp;
|
||||
use App\Quota;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Log;
|
||||
|
|
@ -23,13 +24,13 @@ class UsersController extends Controller
|
|||
$currentSeason=Season::getCurrent();
|
||||
|
||||
if ($currentSeason) {
|
||||
$round_id = Round::getLastLockedRoundId();
|
||||
$round_id = Round::getLastCompleteRoundId();
|
||||
if ($round_id > -1) {
|
||||
$round = Round::where("id", "=", $round_id)->first();
|
||||
$report = $round->report;
|
||||
Log::info("Loaded report:".$report." round-id=".$round_id);
|
||||
$roundname = $round->name;
|
||||
} else { Log::info("No round identified. Last Locked=".$round_id); }
|
||||
} else { Log::info("No round identified. Last Locked=".$round_id); $report="";}
|
||||
} else {Log::info("No current season");}
|
||||
|
||||
return view('main',compact('roundname','report'));
|
||||
|
|
@ -186,9 +187,17 @@ class UsersController extends Controller
|
|||
$roundtipps[$key]['dayscore']=0;
|
||||
|
||||
$roundtipps[$key]['earliest_kickoff']=$entry->game_kickoff;
|
||||
$roundtipps[$key]['hits']=0; // Wenigstens Tendenz getroffen. Wenn 4, dann 2 Punkte Bonus auf rankscore
|
||||
}
|
||||
$roundtipps[$key]['rankscore']+=Tipp::getScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker); // Für alle 4 Spiele
|
||||
if ($user_id==1) {Log::info("Calculating rankscore for round_id ".$round_id." to ".$roundtipps[$key]['rankscore']);}
|
||||
$game_value=Tipp::getScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker); // Für alle 4 Spiele
|
||||
$roundtipps[$key]['rankscore']+=$game_value;
|
||||
if($game_value>0) { $roundtipps[$key]['hits']+=1;}
|
||||
|
||||
|
||||
|
||||
if ($roundtipps[$key]['hits']==4) {$roundtipps[$key]['rankscore']+=2;} // Wenn alle 4 Spiele mind. Tendenz, dann 2 Punkte Bonus
|
||||
|
||||
|
||||
|
||||
|
||||
// START: Add Up Dayscore Win Values for each round
|
||||
|
|
@ -308,30 +317,56 @@ class UsersController extends Controller
|
|||
// Ranknr identifizieren, inkl, geteilter Rankplatzierungen
|
||||
$lastScore=-1;
|
||||
$lastrank=0;
|
||||
$current_list_position=0;
|
||||
$highest_dayscore=0;
|
||||
foreach($rankingDisplay as $key => $user) {
|
||||
$current_list_position+=1;
|
||||
if ($user["rankscore_total"]==$lastScore) {
|
||||
$rankingDisplay[$key]["rank"] = $lastrank;
|
||||
} else {
|
||||
$lastrank +=1;
|
||||
$rankingDisplay[$key]["rank"] = $lastrank;
|
||||
$lastrank = $current_list_position;
|
||||
$rankingDisplay[$key]["rank"] = $current_list_position;
|
||||
$lastScore = $user["rankscore_total"];
|
||||
}
|
||||
|
||||
if ($user["dayscore"]>$highest_dayscore) { $highest_dayscore = $user["dayscore"]; }
|
||||
}
|
||||
|
||||
Log::info("Searching for dayscore winners. Highest dayscore=".$highest_dayscore);
|
||||
|
||||
// is_dayscorewinner setzen (Tagessieg)
|
||||
// Nur wenn alle Spiele eingetragen=gespielt sind !
|
||||
Log::info("Searching for dayscore winners. Highest dayscore=".$highest_dayscore);
|
||||
$daywinner_count=0;
|
||||
$round_completed = Round::isCompleted($max_round_id);
|
||||
foreach($rankingDisplay as $key => $user) {
|
||||
if ($user["dayscore"]>0 && $user["dayscore"]==$highest_dayscore && $round_completed) {
|
||||
$rankingDisplay[$key]["is_dayscorewinner"]=1;
|
||||
$daywinner_count+=1;
|
||||
Log::info("Setting dayscorewin for player:".$user["user_name"]);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: if ($daywinner_count > 6) { ... }
|
||||
|
||||
// Compute Dayscorewin payout (Tagessieg)
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$single_payout=0;
|
||||
|
||||
if ($daywinner_count>0) {
|
||||
$single_payout = $payouts["Tagessieg"] / $daywinner_count ;
|
||||
$single_payout = number_format((float)$single_payout, 2, '.', '');
|
||||
$single_payout = str_replace(".",",",$single_payout);
|
||||
}
|
||||
|
||||
foreach($rankingDisplay as $key => $user) {
|
||||
if ($user["is_dayscorewinner"]==1) {
|
||||
$rankingDisplay[$key]['payout']=$single_payout;
|
||||
} else {
|
||||
$rankingDisplay[$key]['payout']='';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Store game results as separate array. Wir nutzen aus, dass die Ergebnisse in jeder Zeile
|
||||
// von Rankingdisplay abgespeichert sind.
|
||||
$game_results=array(); // 4 Spielergebnisse der angezeigten Runde
|
||||
|
|
@ -345,6 +380,16 @@ class UsersController extends Controller
|
|||
return ($user1['rankscore_total'] < $user2['rankscore_total']);
|
||||
}
|
||||
|
||||
public function show_payouts() {
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
$einsatz = Quota::getQuota($currentSeason->id,"Einsatz");
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
|
||||
Log::info("EINSATZ=".$einsatz);
|
||||
|
||||
return view('users.show_payouts', compact('payouts','active_user_count','einsatz','currentSeason'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue