League Quali Spielplan berechnen & anzeigen

This commit is contained in:
Torsten 2017-09-26 07:57:39 +02:00
parent e0d38fac38
commit 93d7670b48
5 changed files with 58 additions and 10 deletions

View file

@ -171,9 +171,11 @@ class LeaguesController extends Controller
return redirect("/seasons");
}
public function showLeagueRounds($league_rank, $round_id) { // $round_id = $max_round_id
public function showLeagueRounds($league_rank, $maxRoundId) {
if (Auth::guest()) { return redirect("/"); }
$maxRoundId = min(Round::getLastCompleteRoundId(),$maxRoundId);
$season=Season::getCurrent();
$roundNames = Round::getNames();
$leagueNames = League::getNames();
@ -182,9 +184,9 @@ class LeaguesController extends Controller
$matchesTotal = array();
foreach ($leagues as $league) {
$matches = Match::getLeagueMatches($league->id);
$matches = Match::getMatchResults($league->id, $maxRoundId);
foreach ($matches as $match) {
if ($match->round_id <= $round_id) {
if ($match->round_id <= $maxRoundId) {
if (!key_exists($match->round_id, $matchesTotal)) {
$matchesTotal[$match->round_id]=array();
}

View file

@ -53,4 +53,10 @@ class League extends Model
return $leagueNames;
}
public static function getStartRoundId($leagueId)
{
$league = League::where('id','=',$leagueId)->first();
return $league->start_round_id;
}
}

View file

@ -9,6 +9,7 @@ use App\Leagues\LeagueMember;
use App\User;
use App\Round;
use App\Season;
use App\Tipp;
use Log;
use DB;
@ -82,7 +83,6 @@ class Match extends Model
}
public static function getLeagueMatches($league_id) {
//$matches = Match::where('league_id','=',$league_id)->orderBy('round_id')->get();
$matches = DB::table('leagues_matches')->where('league_id','=',$league_id)->orderBy('round_id')->get();
@ -94,12 +94,12 @@ class Match extends Model
$match->round_name = $roundnames[$match->round_id];
$match->user1_name = $usernames[$match->user1_id];
$match->user2_name = $usernames[$match->user2_id];
// Hier könnte man die Punkte auswerten.
// Punktauswertung in Match::getResults($leagueId, $maxRoundId);
}
return $matches;
}
public static function getPairings($leagueId, $roundNr) {
$members = LeagueMember::getMembers($leagueId);
shuffle($members);
@ -151,4 +151,44 @@ class Match extends Model
$members = LeagueMember::getMembers($leagueId);
return sizeof($members)-1;
}
public static function getMatchResults($leagueId, $maxRoundId=-1) {
$roundtipps = Tipp::getRoundTipps($maxRoundId);
$roundtipps = $roundtipps["roundtipps"];
$startRoundId = League::getStartRoundId($leagueId);
$matches = Match::getLeagueMatches($leagueId, $maxRoundId);
if ($maxRoundId==-1) {$maxRoundId=Round::getLastLockedRoundId();}
$matchResults=array();
$members = LeagueMember::getMembers($leagueId);
foreach($matches as $key => $match) {
if (!Round::isCompleted($match->round_id)) continue;
$user1_key = $match->round_id."_".$match->user1_id;
$user2_key = $match->round_id."_".$match->user2_id;
$user1_score = $roundtipps[$user1_key]["rankscore"];
$user2_score = $roundtipps[$user2_key]["rankscore"];
$matches[$key]->user1_rankscore = $user1_score;
$matches[$key]->user2_rankscore = $user2_score;
if ($user1_score > $user2_score) {
$matches[$key]->user1_league_score = 3;
$matches[$key]->user2_league_score = 0;
}
else if ($user1_score < $user2_score){
$matches[$key]->user1_league_score = 0;
$matches[$key]->user2_league_score = 3;
} else {
$matches[$key]->user1_league_score = 1;
$matches[$key]->user2_league_score = 1;
}
// error_log($match->user1_id." vs ".$match->user2_id. " =>" . $user1_score.":".$user2_score);
}
return $matches;
}
}

View file

@ -25,9 +25,9 @@
<!-- Start Matchgruppen-Loop-->
@foreach($matchesTotal[$round_id][$league_id] as $match)
<tr class="table-bordered">
<td>&nbsp;{{$match->user1_id}}-{{$match->user1_name}}&nbsp;</td>
<td>&nbsp;{{$match->user2_id}}-{{$match->user2_name}}&nbsp;</td>
<td>0:0</td>
<td>&nbsp;{{$match->user1_name}}&nbsp;</td>
<td>&nbsp;{{$match->user2_name}}&nbsp;</td>
<td> {{$match->user1_rankscore}}:{{$match->user2_rankscore}}</td>
</tr>
@endforeach

View file

@ -14,7 +14,7 @@
<div><p class="blink_text" style="font-size:21px;">{{ $message_text_joker }}</p></div>
@endif
@if (strlen($nextRoundLockTime)>0)
<div><p class="blink_text" style="font-size:21px;">{{ $nextRoundName }} sperrt sich: {{ $nextRoundLockTime }} ( noch {{ $hourDiffToLock }} Stunden )</p></div>
<div><p class="blink_text" style="font-size:21px;">{{ $nextRoundName }} sperrt sich: {{ $nextRoundLockTime }} ( noch {{ $hourDiffToLock }} )</p></div>
@endif
@endif
@endif