Implementation of final round (Ranking Payouts) incl. extension of Geldrangliste Display
This commit is contained in:
parent
27dd7d97f3
commit
50cc4c75bf
5 changed files with 8400 additions and 31 deletions
|
|
@ -296,6 +296,7 @@ class Tipp extends Model
|
|||
$roundtipps[$key]['earliest_kickoff']=$entry->game_kickoff;
|
||||
$roundtipps[$key]['hits']=0; // Wenigstens Tendenz getroffen. Wenn 4, dann 2 Punkte Bonus auf rankscore
|
||||
$roundtipps[$key]['is_dayscorewinner']=0;
|
||||
$roundtipps[$key]["ranking_payout"]=0; // Existiert nur in der letzten Runde
|
||||
}
|
||||
if (!array_key_exists('is_completed',$roundData[$round_id])) {
|
||||
$roundData[$round_id]['is_completed'] = true;
|
||||
|
|
@ -389,7 +390,9 @@ class Tipp extends Model
|
|||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$totalDayWinPayout = 0;
|
||||
|
||||
$round_count=0;
|
||||
foreach ($round_ids as $round_id) {
|
||||
$round_count +=1;
|
||||
$totalDayWinPayout += $payouts["tagessieg"];
|
||||
|
||||
$highestDayScore = $highestDayscores[$round_id];
|
||||
|
|
@ -443,6 +446,47 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$quotas=Quota::getQuotas($currentSeason->id);
|
||||
if ($round_count==$quotas["Runden"]) {
|
||||
// Ranking Payout ausschütten
|
||||
$payout_groups =array();
|
||||
|
||||
foreach($user_ids as $user_id) {
|
||||
$key = $round_count."_".$user_id;
|
||||
$rank = $roundtipps[$key]["rank"];
|
||||
//Log::info("Setting ranking_payout for user_id ".$user_id);
|
||||
//TODO: Do it for any number of rank payouts
|
||||
if ($rank<11) {
|
||||
if (!array_key_exists($rank,$payout_groups)) {
|
||||
$payout_groups[$rank]=array();
|
||||
}
|
||||
array_push($payout_groups[$rank],$user_id);
|
||||
}
|
||||
}
|
||||
|
||||
// platz0= unsused, just for getting place equal to rank position.
|
||||
$rank_names=['platz0','platz1','platz2','platz3','platz4','platz5','platz6','platz7','platz8','platz9','platz10'];
|
||||
|
||||
// Ausschüttungsgruppen für Platzierung bilden
|
||||
foreach([1,2,3,4,5,6,7,8,9,10] as $rank) { // Jedes Payout, das verteilt werden muss
|
||||
$current_rank = $rank;
|
||||
$rankPayout=$payouts[$rank_names[$rank]];
|
||||
|
||||
while($current_rank) {
|
||||
while (!array_key_exists($current_rank, $payout_groups)) { $current_rank -=1; }
|
||||
$groupsize = sizeof($payout_groups[$current_rank]);
|
||||
|
||||
$single_payout = $rankPayout / $groupsize;
|
||||
foreach($payout_groups[$current_rank] as $user_id) {
|
||||
$key = $round_count."_".$user_id;
|
||||
$roundtipps[$key]["ranking_payout"] += $single_payout;
|
||||
}
|
||||
$current_rank=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////// END OF ROUNDTIPPS CREATION ///////////////////
|
||||
|
||||
$response = array();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue