Working on gshirt scoring

This commit is contained in:
Torsten 2017-12-07 09:07:38 +01:00
parent 7a951320a6
commit 1c0dceb278

View file

@ -384,7 +384,7 @@ class Tipp extends Model
}
usort($userRankings, array('App\Tipp','cmpRank'));
// Ranknr identifizieren, inkl, geteilter Rankplatzierungen nur für max_round_id notwendig, da der Rest ja gar nicht angezeigt wird
// Ranknr identifizieren, inkl, geteilter Rankplatzierungen
$lastScore=-1;
$lastrank=0;
$current_list_position=0;
@ -392,14 +392,16 @@ class Tipp extends Model
$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;
foreach($round_ids as $round_id) {
$key = $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;
}
}
}
@ -415,23 +417,55 @@ class Tipp extends Model
// c.) Determine ranks 1-5 and number of points to distribute
// d.) Mark Rank1 as is_gshirt_owner
// e.) Distribute points, set roundtipps[$key]['gshirt_score'], every other to zero
// (B) SET TOTAL GSCORE EVERY ROUND
// (B) SET GSCORE_TOTAL EVERY ROUND
// 2.) Loop over roundtipps and: a.) add gshirt_score to gshirt_score_total --OR-- zero gshirt_score_total if foulCount==3
/*
* foreach($round_ids as $round_id) {
$users=array();
$gShirtScoreTotal=0;
foreach($user_ids as $user_id) {
// add gshirt_score to $roundtipps[$key]
// A) SET GSCORE EVERY ROUND
foreach($round_ids as $round_id) {
// A-1 fill members with numbers of users per rank
$members=array();
foreach($user_ids as $user_id) {
$key=$round_id."_".$user_id;
$rank=$roundtipps[$key]["rank"];
if(!array_key_exists($rank, $members)) {
$members[$rank]=0;
}
$members[$rank]+=1;
}
// A-2 compute gain
$scoreGain=[0,10,5,3,2,1]; // Rank 0 existiert nicht
// Move gain out of empty ranks into the upper ones.
foreach ([5,4,3,2,1] as $rank) {
if (!array_key_exists($rank,$members)) {
$scoreGain[$rank-1]+= $scoreGain[$rank];
$scoreGain[$rank]=0; // Shouldnt be needed, but makes movement of gain explicit
}
}
// Distribute gain
foreach($user_ids as $user_id) {
$key = $round_id . "_" . $user_id;
$rank= $roundtipps[$key]["rank"];
if ($rank<=5) {
$roundtipps[$key]["gshirt_score"] = $scoreGain[$rank] / $members[$rank];
}
}
}
// 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;
}
}
*/
//////////////////////////////