Working on League Matchings (Qualification)
This commit is contained in:
parent
82e60df35f
commit
9c0f94758d
4 changed files with 8552 additions and 9 deletions
8493
d0274241_2017-09-15_0812.sql
Normal file
8493
d0274241_2017-09-15_0812.sql
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -413,7 +413,10 @@ class Tipp extends Model
|
|||
$count = 0;
|
||||
$cutOffScore = 0;
|
||||
$dayScoreWinnersIds = array();
|
||||
|
||||
foreach ($usersWithHighestDayScore as $user) { // Feld0: user_id, dayScoreWithRankScore
|
||||
//ALT
|
||||
/*
|
||||
$count += 1;
|
||||
if ($count > 6) {
|
||||
if ($user[1] < $cutOffScore) {
|
||||
|
|
@ -423,8 +426,20 @@ class Tipp extends Model
|
|||
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];
|
||||
*/
|
||||
|
||||
// NEU
|
||||
$key = $max_round_id . "_" . $user[0]; // Hier: $user[0] = user_id, $user[1] = dayScore WithRankScore
|
||||
$rankscore = $roundtipps[$key]['rankscore'];
|
||||
$count += 1;
|
||||
|
||||
if ($count==1) {$cutOffScore=$rankscore;}
|
||||
if ($rankscore < $cutOffScore) { break; }
|
||||
|
||||
array_push($dayScoreWinnersIds, $user[0]);
|
||||
$key = $round_id . "_" . $user[0];
|
||||
$roundtipps[$key]['is_dayscorewinner'] = true;
|
||||
}
|
||||
|
||||
// Compute Dayscorewin payout (Tagessieg)
|
||||
|
|
|
|||
|
|
@ -24,4 +24,9 @@ class League extends Model
|
|||
}
|
||||
return $neededLeagues;
|
||||
}
|
||||
|
||||
public static function getMemberCount($league_id) {
|
||||
$members = DB::table('leagues_matches')->where('league_id','=',$league_id)->get();
|
||||
return sizeof($members);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Match extends Model
|
|||
{
|
||||
protected $table ='leagues_matches';
|
||||
protected $fillable = [
|
||||
'id','league_id','user1_id','user2_idsubrank','start_round_id','name'
|
||||
'id','league_id','round_id','user1_id','user2_id'
|
||||
];
|
||||
|
||||
public static function createMissingMatchups() {
|
||||
|
|
@ -50,7 +50,6 @@ class Match extends Model
|
|||
// add Match
|
||||
array_push($matches, [$user1, $user2]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,17 +71,48 @@ class Match extends Model
|
|||
*/
|
||||
|
||||
|
||||
// SOOOO
|
||||
// VIEL
|
||||
// SPASS !!!
|
||||
|
||||
|
||||
// In der Runde darf es nicht schon ein bestehendes Match mit dem User geben
|
||||
// $round = Match::getFreeRound($user_id, $league_id)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Wieviele Spiele finden pro Runde statt ? => Jeder Spieler spielt, also GruppenGröße/2, bei ungerader Gruppengröße gibt es spielfreie Tage.
|
||||
|
||||
public static function getFreeRound($user_id, $league_id) {
|
||||
$round_matches = Match::where('league_id','=',$league_id)->orderBy('round_id')->get();
|
||||
|
||||
$membercount = League::getMemberCount($league_id);
|
||||
$max_size = divint($membercount,2);
|
||||
|
||||
$current_round_id=-1;
|
||||
$current_member_count=0;
|
||||
$is_round_usable=true;
|
||||
|
||||
foreach($round_matches as $round_match) {
|
||||
$current_member_count+=1;
|
||||
|
||||
// 1.) Runde darf nicht schon Gruppengröße/2 Matches enthalten (siehe $max_size)
|
||||
// 2.) Spieler darf in der Runde nicht schon spielen (als user1_id enthalten sein)
|
||||
if ($current_member_count>$max_size) { $is_round_usable=false; continue; }
|
||||
if ($round_match->user1_id == $user_id) { $is_round_usable=false; continue; }
|
||||
|
||||
if ($round_match->round_id != $current_round_id) {
|
||||
if ($is_round_usable && $current_round_id!=-1) { return $round_match->round_id; }
|
||||
|
||||
$current_round_id=$round_match->match_id;
|
||||
$current_member_count=0;
|
||||
$is_round_usable = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return -1; // No suitable/free round found for Player Match.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue