Completed Dayscore Ranking
This commit is contained in:
parent
1f5e056b7f
commit
76947b1df9
7 changed files with 294 additions and 155 deletions
|
|
@ -21,7 +21,7 @@ class SeasonsController extends Controller
|
|||
$active_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->whereNotNull('paid_date')->get() );
|
||||
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
|
||||
if (!$quotas) { Quota::createDefaultQuota($currentSeason->id);}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,9 +136,9 @@ class TippsController extends Controller
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
$tippLink="/tipps#".\App\Round::getFirstTippableRound()->id;
|
||||
// Redirect to the Rounds Index
|
||||
return redirect('/tipps');
|
||||
return redirect($tippLink);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -179,15 +179,9 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function ranking($max_round_id) {
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
|
||||
|
||||
// Check ob mindestens eine Runde der Saison gelockt ist angezeigt werden kann
|
||||
if($max_round_id==-1) {
|
||||
$max_round_id = Round::getLastLockedRoundId();
|
||||
|
|
@ -222,11 +216,8 @@ class UsersController extends Controller
|
|||
$user_ids=array();
|
||||
$round_ids=array();
|
||||
|
||||
|
||||
|
||||
|
||||
// Write sql result to roundtipps (score per round & user)
|
||||
if ($max_round_id==-1) { $max_round_id=Round::getLastLockedRoundId(); }
|
||||
|
||||
foreach ($result as $entry) {
|
||||
$round_id = $entry->round_id;
|
||||
if ($max_round_id >-1 && $round_id>$max_round_id) break;
|
||||
|
|
@ -241,125 +232,245 @@ class UsersController extends Controller
|
|||
$roundtipps[$key]=array();
|
||||
$roundtipps[$key]['tipps']=array();
|
||||
$roundtipps[$key]['results']=array();
|
||||
|
||||
$roundtipps[$key]['joker']=array();
|
||||
$roundtipps[$key]['round_completed']=true; // Um ggfs.
|
||||
$roundtipps[$key]['user_name'] = $entry->user_name;
|
||||
$roundtipps[$key]['user_id'] = $entry->user_id;
|
||||
|
||||
$roundtipps[$key]['rankscore']=0;
|
||||
$roundtipps[$key]['dayscore']=0;
|
||||
|
||||
$roundtipps[$key]['payout']=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]['is_dayscorewinner']=0; // Wenigstens Tendenz getroffen. Wenn 4, dann 2 Punkte Bonus auf 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
|
||||
|
||||
if ($entry->game_score1==-1 || $entry->game_score2==-1) { $roundtipps[$key]['round_completed'] = false; }
|
||||
|
||||
array_push($roundtipps[$key]['tipps'],$entry->tipp_score1);
|
||||
array_push($roundtipps[$key]['tipps'],$entry->tipp_score2);
|
||||
array_push($roundtipps[$key]['results'],$entry->game_score1);
|
||||
array_push($roundtipps[$key]['results'],$entry->game_score2);
|
||||
array_push($roundtipps[$key]['joker'],$entry->joker);
|
||||
|
||||
if ( $entry->game_kickoff < $roundtipps[$key]['earliest_kickoff'] ) { $roundtipps[$key]['earliest_kickoff'] = $entry->game_kickoff; }
|
||||
}
|
||||
// NOW ALL KEYS FOR ROUNDTIPPS (ROUND & USER) EXIST
|
||||
|
||||
|
||||
|
||||
// START: Add Up Dayscore Win Values for each round
|
||||
$tipp_hits = intdiv($roundtipps[$key]['dayscore'],100);
|
||||
$joker_value = $roundtipps[$key]['dayscore'] - $tipp_hits*100;
|
||||
|
||||
$current_score=Tipp::getDayScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker);
|
||||
$current_tipp_hit = intdiv($current_score,100);
|
||||
$current_joker_value = $current_score - ( $current_tipp_hit * 100 );
|
||||
|
||||
$hits_total = $tipp_hits + $current_tipp_hit;
|
||||
$current_joker_value = max($joker_value,$current_joker_value);
|
||||
$roundtipps[$key]["dayscore"] = $hits_total * 100 + $current_joker_value;
|
||||
// END: Add Up Dayscore Win Values
|
||||
|
||||
|
||||
|
||||
if ($entry->game_kickoff < $roundtipps[$key]['earliest_kickoff']) { $roundtipps[$key]['earliest_kickoff']=$entry->game_kickoff; }
|
||||
|
||||
array_push($roundtipps[$key]['tipps'], $entry->tipp_score1, $entry->tipp_score2, $entry->joker);
|
||||
array_push($roundtipps[$key]['results'], $entry->game_score1, $entry->game_score2);
|
||||
|
||||
|
||||
|
||||
// CALCULATION OF SCORES, RANKS, ETC.
|
||||
|
||||
// FIRST LOOP: COMPUTE AGGREGATED VALUES
|
||||
$highestDayscores=array();
|
||||
foreach($user_ids as $user_id) {
|
||||
$totalRankScore=0;
|
||||
foreach($round_ids as $round_id) {
|
||||
|
||||
|
||||
$key=$round_id."_".$user_id;
|
||||
|
||||
// Compute Dayscore values
|
||||
$dayScore1WithRankScore = Tipp::getDayScoreLocal($roundtipps[$key]['results'][0],$roundtipps[$key]['results'][1],$roundtipps[$key]['tipps'][0],$roundtipps[$key]['tipps'][1],$roundtipps[$key]['joker'][0],$roundtipps[$key]['rankscore']);
|
||||
$dayScore2WithRankScore = Tipp::getDayScoreLocal($roundtipps[$key]['results'][2],$roundtipps[$key]['results'][3],$roundtipps[$key]['tipps'][2],$roundtipps[$key]['tipps'][3],$roundtipps[$key]['joker'][1],$roundtipps[$key]['rankscore']);
|
||||
$dayScore3WithRankScore = Tipp::getDayScoreLocal($roundtipps[$key]['results'][4],$roundtipps[$key]['results'][5],$roundtipps[$key]['tipps'][4],$roundtipps[$key]['tipps'][5],$roundtipps[$key]['joker'][2],$roundtipps[$key]['rankscore']);
|
||||
$dayScore4WithRankScore = Tipp::getDayScoreLocal($roundtipps[$key]['results'][6],$roundtipps[$key]['results'][7],$roundtipps[$key]['tipps'][6],$roundtipps[$key]['tipps'][7],$roundtipps[$key]['joker'][3],$roundtipps[$key]['rankscore']);
|
||||
|
||||
$totalDayScoreWithRankScore = Tipp::addDayScoreValues($dayScore1WithRankScore,$dayScore2WithRankScore);
|
||||
$totalDayScoreWithRankScore = Tipp::addDayScoreValues($totalDayScoreWithRankScore,$dayScore3WithRankScore);
|
||||
$totalDayScoreWithRankScore = Tipp::addDayScoreValues($totalDayScoreWithRankScore,$dayScore4WithRankScore);
|
||||
|
||||
$roundtipps[$key]['dayScoreWithRankScore'] = $totalDayScoreWithRankScore;
|
||||
$roundtipps[$key]['dayscore'] = Tipp::getDayScoreWithoutRankScore($totalDayScoreWithRankScore);
|
||||
if (!array_key_exists($round_id,$highestDayscores)) { $highestDayscores[$round_id] = 0;}
|
||||
if ($highestDayscores[$round_id] < $roundtipps[$key]['dayscore'] ) { $highestDayscores[$round_id]=$roundtipps[$key]['dayscore'];}
|
||||
|
||||
$totalRankScore += $roundtipps[$key]["rankscore"];
|
||||
$roundtipps[$key]['totalRankScore'] = $totalRankScore;
|
||||
}
|
||||
}
|
||||
|
||||
Log::info("max_round_id=".$max_round_id);
|
||||
////////////////////////////////////////////////////////
|
||||
// Sortier-Array nach Rang (nur für max_round_id)
|
||||
$userRankings = array();
|
||||
foreach ($user_ids as $user_id) {
|
||||
$key = $max_round_id."_".$user_id;
|
||||
array_push($userRankings, [$user_id , $roundtipps[$key]['totalRankScore']]);
|
||||
|
||||
}
|
||||
usort($userRankings,array($this, 'cmpRank'));
|
||||
|
||||
// Ranknr identifizieren, inkl, geteilter Rankplatzierungen nur für max_round_id notwendig, da der Rest ja gar nicht angezeigt wird
|
||||
$lastScore=-1;
|
||||
$lastrank=0;
|
||||
$current_list_position=0;
|
||||
foreach($userRankings as $userRank) {
|
||||
$user_id=$userRank[0];
|
||||
$totalRankScore=$userRank[1];
|
||||
|
||||
$key=$max_round_id."_".$user_id;
|
||||
$current_list_position+=1;
|
||||
if ($roundtipps[$key]["totalRankScore"]==$lastScore) {
|
||||
$roundtipps[$key]["rank"] = $lastrank;
|
||||
} else {
|
||||
$lastrank = $current_list_position;
|
||||
$roundtipps[$key]["rank"] = $current_list_position;
|
||||
$lastScore = $totalRankScore;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// START OF HURTFUL 6 PLACE RESTRICTION IF DAYSCORE WIN (exception: completely even scores)
|
||||
// If more than 6 DayScoreWinners: Restrict by dayscore (rank)
|
||||
// Compute highest dayscore
|
||||
|
||||
foreach ($round_ids as $round_id) {
|
||||
$highestDayScore = $highestDayscores[$round_id];
|
||||
$usersWithHighestDayScore = array();
|
||||
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($roundtipps[$key]['dayscore'] == $highestDayScore && $roundtipps[$key]['round_completed']) {
|
||||
array_push($usersWithHighestDayScore, [$user_id, $roundtipps[$key]['dayScoreWithRankScore']]);
|
||||
}
|
||||
}
|
||||
if (sizeof($usersWithHighestDayScore) > 6) {
|
||||
usort($usersWithHighestDayScore, array($this, 'cmpDayWin'));
|
||||
}
|
||||
$count = 0;
|
||||
$cutOffScore = 0;
|
||||
$dayScoreWinnersIds = array();
|
||||
foreach ($usersWithHighestDayScore as $user) { // Feld0: user_id, dayScoreWithRankScore
|
||||
$count += 1;
|
||||
if ($count > 6) {
|
||||
if ($user[1] < $cutOffScore) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
array_push($dayScoreWinnersIds, $user[0]);
|
||||
$key = $round_id . "_" . $user[0];
|
||||
$roundtipps[$key]['is_dayscorewinner'] = true;
|
||||
Log::info("Dayscorewinner Round " . $round_id . " = " . $roundtipps[$key]["user_name"]);
|
||||
$cutOffScore = $user[1];
|
||||
}
|
||||
|
||||
// Compute Dayscorewin payout (Tagessieg)
|
||||
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$single_payout = 0;
|
||||
$winnerCount = sizeof($dayScoreWinnersIds);
|
||||
if ($winnerCount > 0) {
|
||||
$single_payout = $payouts["Tagessieg"] / $winnerCount;
|
||||
$single_payout = number_format((float)$single_payout, 2, '.', '');
|
||||
$single_payout = str_replace(".", ",", $single_payout);
|
||||
}
|
||||
|
||||
foreach ($round_ids as $round_id) {
|
||||
foreach ($user_ids as $user_id) {
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($roundtipps[$key]['is_dayscorewinner']) {
|
||||
|
||||
|
||||
$roundtipps[$key]['payout'] = $single_payout;
|
||||
} else {
|
||||
$roundtipps[$key]['payout'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////// END OF ROUNDTIPPS CREATION ///////////////////
|
||||
|
||||
///////////////////////////// DISPLAY AUFBAU /////////////////////////////
|
||||
|
||||
///
|
||||
// AUFBAU RANKINGLISTE A.K.A. RANKINGDISPLAY AB HIER NUR NOCH ANZEIGE-SPEZIFIKA !
|
||||
// Aufbau der Rankingliste in rankingDisplay, sowie aufaddieren der jeweiligen Punkte.
|
||||
// Loop through games and users (again)
|
||||
$rankingDisplay=array();
|
||||
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$rankscore_total= 0;
|
||||
$payout_sum = 0;
|
||||
|
||||
foreach($round_ids as $round_id) {
|
||||
if ($user_id==1) { Log::info("Accumulating display data for round_id ".$round_id); }
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($user_id==1) { Log::info("Dayscore round: ".$round_id." = ".$roundtipps[$key]['dayscore']);}
|
||||
if ($user_id==1) { Log::info("Rankscore round: ".$round_id." = ".$roundtipps[$key]['rankscore']);}
|
||||
$round_id = $max_round_id;
|
||||
|
||||
if (!array_key_exists($user_id, $rankingDisplay)) {
|
||||
$rankingDisplay[$user_id] = array();
|
||||
$key = $round_id . "_" . $user_id;
|
||||
|
||||
$rankingDisplay[$user_id]["user_id"] = $user_id;
|
||||
if (!array_key_exists($user_id, $rankingDisplay)) {
|
||||
$rankingDisplay[$user_id] = array();
|
||||
|
||||
$rankingDisplay[$user_id]["user_name"] = $roundtipps[$key]["user_name"];
|
||||
$rankingDisplay[$user_id]["is_dayscorewinner"] = 0;
|
||||
$rankingDisplay[$user_id]["user_id"] = $user_id;
|
||||
$rankingDisplay[$user_id]["round_id"] = $round_id;
|
||||
$rankingDisplay[$user_id]["rank"] = $roundtipps[$key]["rank"];
|
||||
$rankingDisplay[$user_id]["payout"] = $roundtipps[$key]["payout"];
|
||||
$rankingDisplay[$user_id]["user_name"] = $roundtipps[$key]["user_name"];
|
||||
$rankingDisplay[$user_id]["is_dayscorewinner"] = $roundtipps[$key]["is_dayscorewinner"];
|
||||
|
||||
if ($user_id==1) { Log::info("rankscore after user init for display round_id ".$round_id." = ".$roundtipps[$key]["rankscore"]);}
|
||||
if ($round_id==4 && $roundtipps[$key]["is_dayscorewinner"]) {
|
||||
Log::info("Dayscorewinner: ".$roundtipps[$key]["user_name"]);
|
||||
}
|
||||
|
||||
if ($user_id==1) { Log::info("rankscore after user init for display round_id ".$round_id." = ".$roundtipps[$key]["rankscore"]);}
|
||||
$rankingDisplay[$user_id]["rankscore"] = $roundtipps[$key]["rankscore"]; // Summe Rangwertung alle 4 Spiele/Tipps der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
$rankingDisplay[$user_id]["dayscore"] = $roundtipps[$key]["dayscore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
|
||||
$rankingDisplay[$user_id]["rankscore_total"] = $rankscore_total + $roundtipps[$key]["rankscore"];
|
||||
$rankscore_total=$rankingDisplay[$user_id]["rankscore_total"];
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score1"] = $roundtipps[$key]["tipps"][0];
|
||||
$rankingDisplay[$user_id]["tipp_score2"] = $roundtipps[$key]["tipps"][1];
|
||||
$rankingDisplay[$user_id]["joker1"] = $roundtipps[$key]["tipps"][2];
|
||||
$rankingDisplay[$user_id]["result_score1"] = $roundtipps[$key]["results"][0];
|
||||
$rankingDisplay[$user_id]["result_score2"] = $roundtipps[$key]["results"][1];
|
||||
|
||||
// Determine coloration for Game1
|
||||
$rankingDisplay[$user_id]["trendCol1"] = Tipp::trendCol($roundtipps[$key]["results"][0],$roundtipps[$key]["results"][1],
|
||||
$roundtipps[$key]["tipps"][0],$roundtipps[$key]["tipps"][1],
|
||||
$roundtipps[$key]["tipps"][2]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score3"] = $roundtipps[$key]["tipps"][3];
|
||||
$rankingDisplay[$user_id]["tipp_score4"] = $roundtipps[$key]["tipps"][4];
|
||||
$rankingDisplay[$user_id]["joker2"] = $roundtipps[$key]["tipps"][5];
|
||||
$rankingDisplay[$user_id]["result_score3"] = $roundtipps[$key]["results"][2];
|
||||
$rankingDisplay[$user_id]["result_score4"] = $roundtipps[$key]["results"][3];
|
||||
|
||||
// Determine coloration for Game2
|
||||
$rankingDisplay[$user_id]["trendCol2"] = Tipp::trendCol($roundtipps[$key]["results"][2],$roundtipps[$key]["results"][3],
|
||||
$roundtipps[$key]["tipps"][3],$roundtipps[$key]["tipps"][4],
|
||||
$roundtipps[$key]["tipps"][5]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score5"] = $roundtipps[$key]["tipps"][6];
|
||||
$rankingDisplay[$user_id]["tipp_score6"] = $roundtipps[$key]["tipps"][7];
|
||||
$rankingDisplay[$user_id]["joker3"] = $roundtipps[$key]["tipps"][8];
|
||||
$rankingDisplay[$user_id]["result_score5"] = $roundtipps[$key]["results"][4];
|
||||
$rankingDisplay[$user_id]["result_score6"] = $roundtipps[$key]["results"][5];
|
||||
// Determine coloration for Game3
|
||||
$rankingDisplay[$user_id]["trendCol3"] = Tipp::trendCol($roundtipps[$key]["results"][4],$roundtipps[$key]["results"][5],
|
||||
$roundtipps[$key]["tipps"][6],$roundtipps[$key]["tipps"][7],
|
||||
$roundtipps[$key]["tipps"][8]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score7"] = $roundtipps[$key]["tipps"][9];
|
||||
$rankingDisplay[$user_id]["tipp_score8"] = $roundtipps[$key]["tipps"][10];
|
||||
$rankingDisplay[$user_id]["joker4"] = $roundtipps[$key]["tipps"][11];
|
||||
$rankingDisplay[$user_id]["result_score7"] = $roundtipps[$key]["results"][6];
|
||||
$rankingDisplay[$user_id]["result_score8"] = $roundtipps[$key]["results"][7];
|
||||
// Determine coloration for Game4
|
||||
$rankingDisplay[$user_id]["trendCol4"] = Tipp::trendCol($roundtipps[$key]["results"][6],$roundtipps[$key]["results"][7],
|
||||
$roundtipps[$key]["tipps"][9],$roundtipps[$key]["tipps"][10],
|
||||
$roundtipps[$key]["tipps"][11]);
|
||||
$rankingDisplay[$user_id]["dayScoreWithRankScore"] = $roundtipps[$key]["dayScoreWithRankScore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
}
|
||||
|
||||
$rankingDisplay[$user_id]["totalRankScore"] = $roundtipps[$key]['totalRankScore'];
|
||||
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score1"] = $roundtipps[$key]["tipps"][0];
|
||||
$rankingDisplay[$user_id]["tipp_score2"] = $roundtipps[$key]["tipps"][1];
|
||||
$rankingDisplay[$user_id]["joker1"] = $roundtipps[$key]["joker"][0];
|
||||
$rankingDisplay[$user_id]["result_score1"] = $roundtipps[$key]["results"][0];
|
||||
$rankingDisplay[$user_id]["result_score2"] = $roundtipps[$key]["results"][1];
|
||||
|
||||
// Determine coloration for Game1
|
||||
$rankingDisplay[$user_id]["trendCol1"] = Tipp::trendCol($roundtipps[$key]["results"][0],$roundtipps[$key]["results"][1],
|
||||
$roundtipps[$key]["tipps"][0],$roundtipps[$key]["tipps"][1],
|
||||
$roundtipps[$key]["joker"][0]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score3"] = $roundtipps[$key]["tipps"][2];
|
||||
$rankingDisplay[$user_id]["tipp_score4"] = $roundtipps[$key]["tipps"][3];
|
||||
$rankingDisplay[$user_id]["joker2"] = $roundtipps[$key]["joker"][1];
|
||||
$rankingDisplay[$user_id]["result_score3"] = $roundtipps[$key]["results"][2];
|
||||
$rankingDisplay[$user_id]["result_score4"] = $roundtipps[$key]["results"][3];
|
||||
|
||||
// Determine coloration for Game2
|
||||
$rankingDisplay[$user_id]["trendCol2"] = Tipp::trendCol($roundtipps[$key]["results"][2],$roundtipps[$key]["results"][3],
|
||||
$roundtipps[$key]["tipps"][2],$roundtipps[$key]["tipps"][3],
|
||||
$roundtipps[$key]["joker"][1]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score5"] = $roundtipps[$key]["tipps"][4];
|
||||
$rankingDisplay[$user_id]["tipp_score6"] = $roundtipps[$key]["tipps"][5];
|
||||
$rankingDisplay[$user_id]["joker3"] = $roundtipps[$key]["joker"][2];
|
||||
$rankingDisplay[$user_id]["result_score5"] = $roundtipps[$key]["results"][4];
|
||||
$rankingDisplay[$user_id]["result_score6"] = $roundtipps[$key]["results"][5];
|
||||
// Determine coloration for Game3
|
||||
$rankingDisplay[$user_id]["trendCol3"] = Tipp::trendCol($roundtipps[$key]["results"][4],$roundtipps[$key]["results"][5],
|
||||
$roundtipps[$key]["tipps"][4],$roundtipps[$key]["tipps"][5],
|
||||
$roundtipps[$key]["joker"][2]);
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score7"] = $roundtipps[$key]["tipps"][6];
|
||||
$rankingDisplay[$user_id]["tipp_score8"] = $roundtipps[$key]["tipps"][7];
|
||||
$rankingDisplay[$user_id]["joker4"] = $roundtipps[$key]["joker"][3];
|
||||
$rankingDisplay[$user_id]["result_score7"] = $roundtipps[$key]["results"][6];
|
||||
$rankingDisplay[$user_id]["result_score8"] = $roundtipps[$key]["results"][7];
|
||||
// Determine coloration for Game4
|
||||
$rankingDisplay[$user_id]["trendCol4"] = Tipp::trendCol($roundtipps[$key]["results"][6],$roundtipps[$key]["results"][7],
|
||||
$roundtipps[$key]["tipps"][6],$roundtipps[$key]["tipps"][7],
|
||||
$roundtipps[$key]["joker"][3]);
|
||||
|
||||
}
|
||||
|
||||
$userids = array_keys($rankingDisplay);
|
||||
|
|
@ -376,71 +487,29 @@ class UsersController extends Controller
|
|||
}
|
||||
$rankingDisplay = $entries;
|
||||
|
||||
// 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 = $current_list_position;
|
||||
$rankingDisplay[$key]["rank"] = $current_list_position;
|
||||
$lastScore = $user["rankscore_total"];
|
||||
}
|
||||
|
||||
if ($user["dayscore"]>$highest_dayscore) { $highest_dayscore = $user["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
|
||||
array_push($game_results,$rankingDisplay[0]["result_score1"],$rankingDisplay[0]["result_score2"],$rankingDisplay[0]["result_score3"],$rankingDisplay[0]["result_score4"],$rankingDisplay[0]["result_score5"],$rankingDisplay[0]["result_score6"],$rankingDisplay[0]["result_score7"],$rankingDisplay[0]["result_score8"]);
|
||||
|
||||
$game_results=array(); // 4 Spielergebnisse der angezeigten Runde
|
||||
array_push($game_results,$rankingDisplay[0]["result_score1"],$rankingDisplay[0]["result_score2"],$rankingDisplay[0]["result_score3"],$rankingDisplay[0]["result_score4"],$rankingDisplay[0]["result_score5"],$rankingDisplay[0]["result_score6"],$rankingDisplay[0]["result_score7"],$rankingDisplay[0]["result_score8"]);
|
||||
|
||||
return view('users.ranking', compact('all_rounds','rankingDisplay','userids','round','games','game_results'));
|
||||
}
|
||||
|
||||
public function cmp($user1, $user2) {
|
||||
return ($user1['rankscore_total'] < $user2['rankscore_total']);
|
||||
return ($user1['totalRankScore'] < $user2['totalRankScore']);
|
||||
}
|
||||
public function cmpDayWin($user1, $user2) {
|
||||
return ($user1[1] < $user2[1]); // Feld0: user_id, Feld1: dayScoreWithRankScore
|
||||
}
|
||||
public function cmpRank($rank1, $rank2) {
|
||||
return ($rank1[1] < $rank2[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function show_payouts() {
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
|
|
|||
|
|
@ -104,9 +104,9 @@ class Tipp extends Model
|
|||
|
||||
// Bei Tagessieg gilt nur wer am meisten genau richtig getippt hat,
|
||||
// Bei Gleichstand wer den höchsten Jokersieg hat ( Jokersieg mit mehr Toren zählt mehr)
|
||||
|
||||
|
||||
public static function getDayScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker) {
|
||||
// Bei Gleichstand gilt die Summe aller Rankscores, deshalb wird sie auch im Ergebnis gespeichert
|
||||
// Fürs Dayscore-Bewerten ist rankscore allerdings irrelevant. Mit Rank nur fürs Sortieren, um die Auswahl einzugrenzen.
|
||||
public static function getDayScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker, $rankScore=0) {
|
||||
if ($tipp1==-1||$tipp2==-1||$goals1==-1||$goals2==-1) { return 0; } // Ungetippt oder Spiel hat noch kein Ergebnis
|
||||
if ( ($tipp1 != $goals1) || ($tipp2 != $goals2) ) return 0;
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ class Tipp extends Model
|
|||
if ($joker) {
|
||||
$jokerValue = max(0, $goals1 + $goals2 - 3) + 1;
|
||||
}
|
||||
return 100 + $jokerValue;
|
||||
return 1000 + $jokerValue * 100 + $rankScore;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -210,4 +210,34 @@ class Tipp extends Model
|
|||
Tipp::createTipps($user->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Struktur: gameval * 1000 + jokerValue * 100 + rankscore
|
||||
public static function addDayScoreValues($val1, $val2) {
|
||||
$gameVal1 = intdiv($val1 , 1000);
|
||||
$gameVal2 = intdiv( $val2, 1000);
|
||||
|
||||
$jokerVal1 = intdiv(($val1 - $gameVal1*1000),100);
|
||||
$jokerVal2 = intdiv(($val2 - $gameVal2*1000),100);
|
||||
|
||||
if ( $gameVal1 ==0 ) { $jokerVal1=0; $rankVal1=0; }
|
||||
if ( $gameVal2 ==0 ) { $jokerVal2=0; $rankVal2=0; }
|
||||
|
||||
$rankVal1 = $val1 - $gameVal1*1000 - $jokerVal1*100;
|
||||
$rankVal2 = $val2 - $gameVal2*1000 - $jokerVal2*100;
|
||||
|
||||
// Minimaler Brainfuck, da $rankVal1 und $rankVal2 immer gleich sein sollten
|
||||
$result = ($gameVal1 + $gameVal2) * 1000 + max($jokerVal1, $jokerVal2) * 100 + max ($rankVal1, $rankVal2);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getDayScoreWithoutRankScore($val) {
|
||||
$gameVal = intdiv($val , 1000);
|
||||
$jokerVal = intdiv(($val - $gameVal*1000),100);
|
||||
if ($gameVal==0) return 0;
|
||||
return $gameVal * 1000 + $jokerVal * 100;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddReminderfieldToUsers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('gets_reminders')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
<td class="table-bordered" style="width:600px;"><label class="text" href="/games/edit/{{ $game->id }}">{{ $game->team1 }} : {{ $game->team2 }}</label> </td>
|
||||
<td class="table-bordered" style="width:600px;"><label class="text" > {{ App\User::toGermanDate($game->kickoff) }}</label></td>
|
||||
|
||||
<td class="table-bordered" style="width:350px;">{{ $game->hasResult() ? $game->score1 . ' : ' . $game->score2 : ' Tippen ' }}</td>
|
||||
<td class="table-bordered" style="width:350px;">{{ $game->hasResult() ? $game->score1 . ' : ' . $game->score2 : ' ' }}</td>
|
||||
|
||||
<td class="table-bordered" style="width:75px;">
|
||||
@if(App\Round::hasLockedGame($round->id)==true)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@
|
|||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">Rang</span>
|
||||
</div>
|
||||
</th>
|
||||
<!--
|
||||
<th style="height:140px;white-space: nowrap;">
|
||||
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
|
||||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">dayScoreWithRankScore</span>
|
||||
</div>
|
||||
</th>
|
||||
-->
|
||||
<th style="height:140px;white-space: nowrap;">
|
||||
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
|
||||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;width:50px;">Tagessieg</span>
|
||||
|
|
@ -145,9 +152,10 @@
|
|||
|
||||
<tr>
|
||||
<td class="table-bordered"> <span class="text list-unstyled" href="#" > {{ $entry["rank"] }} </span></td>
|
||||
<!-- <td class="table-bordered" align="center"> $entry["dayScoreWithRankScore"] </td> -->
|
||||
<td class="table-bordered"><div style="margin: 0 auto; width: 32px;"><img src="/img/crown.png" style="{{ ($entry["is_dayscorewinner"] ? 'float:left;width:32px;height:32px' : 'display: none;') }}"></div></td>
|
||||
<td class="table-bordered"> <a class="text list-unstyled" href="#" style="vertical-align: middle;">{{ $entry["user_name"] }} </a></td>
|
||||
<td class="table-bordered" align="center"> {{ $entry["rankscore_total"] }} </td>
|
||||
<td class="table-bordered" align="center"> {{ $entry["totalRankScore"] }} </td>
|
||||
<td class="table-bordered" align="center"> {{ $entry["rankscore"] }} </td>
|
||||
<td class="table-bordered" align="center" style="border: 0px"> </td> <!-- Spacer column -->
|
||||
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}"> {{ str_replace("-1","x",$entry["tipp_score1"]) }} </td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue