League creation, Auf & Abstieg - preparation

This commit is contained in:
Torsten 2017-10-12 11:40:25 +02:00
parent 444ce18f63
commit 8edec26147
2 changed files with 21 additions and 4 deletions

View file

@ -121,6 +121,8 @@ class LeaguesController extends Controller
} else {
// ToDo: Achtel-, Viertel-, Halb-, Finale require additional leagues; Same with Pokal, so createMissingLeagues method will be needed in the future
## !! ##
$league_size1= min(22,$active_member_count);
$league1 = League::create([
'is_qualification' => false,

View file

@ -92,11 +92,11 @@ class League extends Model
foreach ($matches as $match) {
if (Round::isCompleted($match->round_id)) {
$memberScores[$match->user1_id][1] += $match->user1_league_score;
$memberScores[$match->user1_id][2] += $match->user1_rankscore;
$memberScores[$match->user1_id][3] += $match->user2_rankscore;
$memberScores[$match->user1_id][2] += $match->user1_rankscore; // goals
$memberScores[$match->user1_id][3] += $match->user2_rankscore; // countergoals
$memberScores[$match->user2_id][1] += $match->user2_league_score;
$memberScores[$match->user2_id][2] += $match->user2_rankscore;
$memberScores[$match->user2_id][3] += $match->user1_rankscore;
$memberScores[$match->user2_id][2] += $match->user2_rankscore; // goals
$memberScores[$match->user2_id][3] += $match->user1_rankscore; // countergoals
}
}
usort($memberScores, array('App\Leagues\League','cmpScore'));
@ -109,6 +109,21 @@ class League extends Model
// Für Auf/Abstiegsberechnung
public static function getUnifiedRanking($rank, $seasonId=-1) {
$leagueScores = League::getRanking($rank, $seasonId);
$unifiedScores = array();
foreach($leagueScores as $leagueId => $singleLeagueScores) {
foreach ($singleLeagueScores as $placeNr => $singleLeagueScore) {
$userId=$singleLeagueScores[$placeNr][0];
$unifiedScores[$userId]=$singleLeagueScores[$placeNr];
}
}
usort($unifiedScores,array('App\Leagues\League','cmpScore'));
return $unifiedScores;
}
// Aktuelle Liga-Zuordnung auf Basis des Rangs in der letzten Liga
public static function getNewLeagueForPlayers()
{