GreenShirt Display in Ranking

This commit is contained in:
Torsten 2018-01-12 08:40:42 +01:00
parent 8595808fd2
commit 08ffdf5609
4 changed files with 29 additions and 14 deletions

View file

@ -279,6 +279,7 @@ class UsersController extends Controller
$rankingDisplay[$user_id]["gshirt_score"] = $roundtipps[$key]["gshirt_score"];
$rankingDisplay[$user_id]["gshirt_totalscore"] = $roundtipps[$key]["gshirt_totalscore"];
$rankingDisplay[$user_id]["gshirt_foulcount"] = $roundtipps[$key]["gshirt_foulcount"];
$rankingDisplay[$user_id]["gshirt_leader"] = $roundtipps[$key]["gshirt_leader"];

View file

@ -507,6 +507,7 @@ class Tipp extends Model
}
// B) SET GSCORE TOTAL EVERY ROUND ( and take fouls into consideration )
$maxScorePerRound=array();
foreach($user_ids as $user_id) {
$foulCount=0;
$totalScore=0;
@ -514,6 +515,8 @@ class Tipp extends Model
foreach ($round_ids as $round_id) {
$key = $round_id . "_" . $user_id;
if (!array_key_exists($round_id, $maxScorePerRound)) { $maxScorePerRound[$round_id]=0; }
$score = $roundtipps[$key]['gshirt_score'];
$isFoul = ( $roundtipps[$key]['rankscore'] == 0 && $totalScore > 0 );
if ($isFoul) {
@ -522,10 +525,14 @@ class Tipp extends Model
if ($foulCount==3) {
$foulCount=0;
$totalScore=0;
$roundtipps[$key]['gshirt_foul_reset']=1;
} else {
$roundtipps[$key]['gshirt_foul_reset']=0;
}
}
$lastTotalRankScore=
$totalScore += $score;
if ($totalScore > $maxScorePerRound[$round_id]) { $maxScorePerRound[$round_id]=$totalScore; }
$roundtipps[$key]['gshirt_totalscore']=$totalScore;
$roundtipps[$key]['gshirt_foulcount']=$foulCount;
@ -534,6 +541,19 @@ class Tipp extends Model
}
}
// C) Set gscore_leader
foreach ($round_ids as $round_id) {
foreach($user_ids as $user_id) {
$key = $round_id . "_" . $user_id;
if ($roundtipps[$key]['gshirt_totalscore'] == $maxScorePerRound[$round_id] && $maxScorePerRound[$round_id]>0 ) {
$roundtipps[$key]['gshirt_leader'] =1;
} else {
$roundtipps[$key]['gshirt_leader'] =0;
}
}
}
//dd("User 11 Round 1 gshirt_score =".$roundtipps['1_11']['gshirt_score'].", totalscore=".$roundtipps['1_11']['gshirt_totalscore']);