diff --git a/pfosten/app/Http/Controllers/Leagues/LeaguesController.php b/pfosten/app/Http/Controllers/Leagues/LeaguesController.php index 59b51a59..4c44fefe 100644 --- a/pfosten/app/Http/Controllers/Leagues/LeaguesController.php +++ b/pfosten/app/Http/Controllers/Leagues/LeaguesController.php @@ -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, diff --git a/pfosten/app/leagues/League.php b/pfosten/app/leagues/League.php index cccf91a2..c574f15c 100644 --- a/pfosten/app/leagues/League.php +++ b/pfosten/app/leagues/League.php @@ -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() {