Working on gshirt score calculation

This commit is contained in:
Torsten 2017-12-08 08:42:05 +01:00
parent 1c0dceb278
commit 86803fa23a
3 changed files with 43 additions and 15 deletions

View file

@ -271,6 +271,7 @@ class UsersController extends Controller
$rankingDisplay[$user_id]["user_name"] = $roundtipps[$key]["user_name"];
$rankingDisplay[$user_id]["is_dayscorewinner"] = $roundtipps[$key]["is_dayscorewinner"];
$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"];

View file

@ -305,6 +305,7 @@ class Tipp extends Model
$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;
@ -363,14 +364,6 @@ class Tipp extends Model
$totalRankScore += $roundtipps[$key]["rankscore"];
$roundtipps[$key]['totalRankScore'] = $totalRankScore;
//
// ADD-ON: Foul-Detection for GreenShirt(grünes Trikot)
//
$isFoul = ( $roundtipps[$key]["rankscore"] == 0 );
if ( $isFoul ) { $foulCount += 1; }
$roundtipps[$key]['gshirt_foulcount'] = $foulCount;
if ($foulCount==3) $foulCount=0;
}
}
@ -451,22 +444,56 @@ class Tipp extends Model
$rank= $roundtipps[$key]["rank"];
if ($rank<=5) {
$roundtipps[$key]["gshirt_score"] = $scoreGain[$rank] / $members[$rank];
} else {
$roundtipps[$key]["gshirt_score"]=0;
}
}
}
// B) SET GSCORE TOTAL EVERY ROUND ( and take fouls into consideration )
foreach ($round_ids as $round_id) {
foreach($user_ids as $user_id) {
$key = $round_id . "_" . $user_id;
$roundtipps[$key]['gshirt_totalscore']=0;
$roundtipps[$key]['gshirt_foulcount']=0;
foreach($user_ids as $user_id) {
foreach($round_ids as $round_id) {
$key=$round_id."_".$user_id;
$roundtipps[$key]['gshirt_totalscore']=-1;
$roundtipps[$key]['gshirt_foulcount']=-1;
}
}
/* FIND BUG !
foreach($user_ids as $user_id) {
$foulCount=0;
$totalScore=0;
foreach ($round_ids as $round_id) {
$key = $round_id . "_" . $user_id;
$score = $roundtipps[$key]['gshirt_score'];
$isFoul = ( $roundtipps[$key]["rankscore"] == 0 );
if ($isFoul) {
$foulCount+=1;
if ($foulCount==3) {
$foulCount=0;
$totalScore=0;
}
}
$totalScore+=$score;
$roundtipps[$key]['gshirt_totalscore']=$totalScore;
$roundtipps[$key]['gshirt_foulcount']=$foulCount;
if ($user_id==14) {
error_log("round_id=" . $round_id .",gshirt_score=".$roundtipps[$key]['gshirt_score'].", score=" . $score.", totalScore=".$totalScore);
}
error_log("Test: key=".$key.", ".$roundtipps[$key]['gshirt_score']);
}
}
//dd("stop");
*/
//////////////////////////////
// START OF HURTFUL 6 PLACE RESTRICTION IF DAYSCORE WIN (exception: completely even scores)

View file

@ -169,7 +169,7 @@
<td class="table-bordered" align="center">&nbsp;{{ $entry["totalRankScore"] }}&nbsp;</td>
<td class="table-bordered" align="center">&nbsp;{{ $entry["rankscore"] }}&nbsp;</td>
<td class="table-bordered" align="center" style="border: 0px">&nbsp;&nbsp;&nbsp;</td> <!-- Spacer column -->
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}">&nbsp;{{ $entry["gshirt_totalscore"]." (".$entry["gshirt_foulcount"].")" }}&nbsp;</td>
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}">&nbsp;{{ $entry["gshirt_score"]." / ".$entry["gshirt_totalscore"]." (".$entry["gshirt_foulcount"].")" }}&nbsp;</td>
<td class="table-bordered" align="center" style="border: 0px">&nbsp;&nbsp;&nbsp;</td> <!-- Spacer column -->
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}">&nbsp;{{ str_replace("-1","x",$entry["tipp_score1"]) }}&nbsp;</td>
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}">&nbsp;{{ str_replace("-1","x",$entry["tipp_score2"]) }}&nbsp;</td>