Show green short, correction of player matchups, randomization of new player league assignments

This commit is contained in:
Torsten 2018-01-15 08:58:52 +01:00
parent 08ffdf5609
commit 4f6116fc5b
5 changed files with 88 additions and 22 deletions

View file

@ -254,8 +254,8 @@ class Tipp extends Model
$currentSeason = Season::where('id', '=', $seasonId)->first();
};
if (Round::getLastCompleteRoundId($seasonId)==-1) {
error_log("Tipp::getRoundTipps returns null, because there is no completeRoundId");
if (Round::getLastLockedRoundId($seasonId)==-1) {
error_log("Tipp::getRoundTipps returns null, because there is no LastLockedRoundId");
return null;
}
@ -281,8 +281,9 @@ class Tipp extends Model
// Write sql result to roundtipps (score per round & user)
if ($max_round_id == -1) {
$max_round_id = Round::getLastCompleteRoundId($currentSeason->id);
$max_round_id = Round::getLastLockedRoundId($currentSeason->id);
}
foreach ($result as $entry) {
$round_id = $entry->round_id;
if ($max_round_id > -1 && $round_id > $max_round_id) break;

View file

@ -195,8 +195,6 @@ class User extends Authenticatable
$season=Season::getCurrent();
if (!$season) return array();
if ($seasonId != -1) { $season = Season::where('id','=',$seasonId)->first(); }
$seasonId = $season->id;

View file

@ -286,6 +286,18 @@ class League extends Model
$previousSeason=Season::getPrevious($seasonId);
$old_users=User::getActives($previousSeason->id);
// Structure of unified list entry
/*
$tpl = array();
$tpl[0] = $rankEntry[0]; // userId
$tpl[1] = $rankEntry[1]; // league_score
$tpl[2] = $rankEntry[2]; // goals
$tpl[3] = $rankEntry[3]; // countergoals
$tpl[4] = $rank; // league_rank (1,2,3, 4=quali)
$tpl[5] = $rankEntry[4]; // league_pos (for multiple leagues per rank, usually ranks 3 and 4)
*/
$new_users=array();
foreach($users as $user) {
$exists=0;
@ -294,7 +306,7 @@ class League extends Model
}
if (!$exists) {
if (User::payment_date($user->id, $seasonId)) {
$entry = [$user->id];
$entry = [$user->id,0,0,0,3,0];
array_push($new_users, $entry);
}
}
@ -328,8 +340,8 @@ class League extends Model
$active_member_count=sizeof(User::getActives());
Log::info("Aktive Spieler: ".$active_member_count);
$neededLeagues = League::neededLeagues($active_member_count, $round_count);
Log::info("Benötigte Liga-Gruppen: ".$neededLeagues);
$neededLeagues3 = League::neededLeagues($active_member_count, $round_count);
Log::info("Benötigte Liga-Gruppen: ".$neededLeagues3);
$league_ids=array();
@ -341,7 +353,7 @@ class League extends Model
// Dieser Modus wird gewählt, wenn es keine Vorsaison gibt, es also
// die erste Saison im System ist.
Log::info("League::createLeagues => No previous season detected.");
for ($league_nr=1; $league_nr<=$neededLeagues; $league_nr+=1) {
for ($league_nr=1; $league_nr<=$neededLeagues3; $league_nr+=1) {
$league = League::create([
'is_qualification' => true,
'name' => 'Qualifikationsgruppe '.$league_nr,
@ -383,7 +395,7 @@ class League extends Model
// Erzeugung der Ligen
$createdLeagues=array();
$neededLeagues=0;
$neededLeagues3=0;
$league_size1= min(22,$active_member_count);
$league1 = League::create([
@ -411,9 +423,18 @@ class League extends Model
array_push($createdLeagues, $league2);
$league_size3 = $active_member_count - $league_size1 - $league_size2;
// Make neededLeagues3 visible outside of scope
$neededLeagues3=-1;
if ($league_size3>0) {
$neededLeagues = League::neededLeagues($league_size3, $round_count);
for ($league_nr=1; $league_nr<=$neededLeagues; $league_nr+=1) {
$neededLeagues3 = League::neededLeagues($league_size3, $round_count);
// Wenn es mehr als eine Gruppe ist, mpssen
if ($neededLeagues3>1) {
}
for ($league_nr=1; $league_nr<=$neededLeagues3; $league_nr+=1) {
$league = League::create([
'is_qualification' => false,
'name' => 'Spielerliga 3, Gruppe '.$league_nr,
@ -451,13 +472,60 @@ class League extends Model
// Jetzt neue Spieler hinzufügen, die letzte Saison noch nicht dabei waren, und deshalb in getTotalRankingOverall nicht enthalten sind.
Log::info("League::createLeagues Adding new users not within previous season");
foreach( League::getNewUsers() as $entry) {
array_push($unifiedList, $entry);
$userId=$entry[0];
Log::info("( [".$userId."] ".$userNames[$userId]." )");
Log::info("adding new user not in previous season: ( [".$userId."] ".$userNames[$userId]." )");
}
// Wenn es für Liga 3 mehr als eine Gruppe gibt, dann die Reihenfolge der Members randomisieren.
if ($neededLeagues3>1) {
$numberOfSwaps=50;
// Structure of unified list entry
/*
$tpl = array();
$tpl[0] = $rankEntry[0]; // userId
$tpl[1] = $rankEntry[1]; // league_score
$tpl[2] = $rankEntry[2]; // goals
$tpl[3] = $rankEntry[3]; // countergoals
$tpl[4] = $rank; // league_rank (1,2,3, 4=quali)
$tpl[5] = $rankEntry[4]; // league_pos (for multiple leagues per rank, usually ranks 3 and 4)
*/
Log::info("League 3 entries before shuffling:");
foreach($unifiedList as $entry) {
if ($entry[4]==3) {
Log::info ("(".$entry[0].") ".$userNames[$entry[0]]);
}
}
$league3entries=array();
foreach($unifiedList as $pos => $entry) {
if ($entry[4]==3) {
array_push($league3entries, $entry);
}
}
shuffle($league3entries);
$pos=0;
foreach ( $unifiedList as $key => $entry) {
if ($entry[4]==3) {
$unifiedList[$key] = $league3entries[$pos];
$pos += 1;
}
}
Log::info("League 3 entries after shuffling:");
foreach($unifiedList as $entry) {
if ($entry[4]==3) { Log::info ("(".$entry[0].") ".$userNames[$entry[0]]); }
}
}
$currentCount = 1;
@ -475,7 +543,7 @@ class League extends Model
if ($nr==23) { $leagueNr=2; $leagueCount=1; $leagueIndex=1; }
if ($nr==45) {
$leagueNr=3; $leagueCount=1; $leagueIndex=2;
$neededSize3=intdiv(($active_member_count-44),$neededLeagues); // $neededLeagues = needed Groups for rank 3 leagues
$neededSize3=intdiv(($active_member_count-44),$neededLeagues3); // $neededLeagues = needed Groups for rank 3 leagues
if ( ($active_member_count-44) % 2) {
$neededSize3+=1;
@ -496,6 +564,7 @@ class League extends Model
'user_id' => $entry[0],
'league_id' => $league->id
]);
Log::Info("(".$entry[0].") ".$userNames[$entry[0]]." => leagueIndex=".$leagueIndex);
$leagueMember->save();
@ -503,7 +572,6 @@ class League extends Model
$nr++;
}
}
}
}

View file

@ -24,10 +24,8 @@
<label class="dropdown" id="dropdown2">
<a href="#" id="btn_league" onclick="toggleSelect('dropdown_league'); return false;" style="font-weight:normal; font-color: blue; font-size: 22px;">Spieler-Liga</a>
<div id="dropdown_league" class="dropdown-content">
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league_show_rounds">Spielplan</a> &nbsp;
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league/show#playerid_{{Auth::user()->id}}">Tabellen</a> &nbsp;
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league_show_rounds">Spielplan</a> &nbsp;<!-- /league_show_rounds -->
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league/show#playerid_ {{ Auth::user()->id }}">Tabellen</a> &nbsp; <!-- /league/show#playerid_ (( Auth::user()->id )) -->
</div>
</label>
&nbsp;

View file

@ -165,7 +165,7 @@
<!-- <td class="table-bordered" align="center">&nbsp; $entry["dayScoreWithRankScore"] &nbsp;</td> -->
<td class="table-bordered"><div style="margin: 0 auto; width: 32px;"><img src="/img/crown.png" style="{{ ($entry["is_dayscorewinner"] ? 'float:left;width:32px;height:32px' : 'display: none;') }}"></div></td>
<!-- <td class="table-bordered" align="center" style="">&nbsp;<img src="/img/green_shirt.png"/>&nbsp;</td>-->
<td class="table-bordered" align="center">&nbsp; <img src="/img/green_shirt.png" style="{{ ($entry["gshirt_leader"] ? 'width:32px;height:32px' : 'display: none;') }}"/> &nbsp;</td>
<td class="table-bordered" align="center">&nbsp; <img src="/img/green_shirt.png" style="{{ ($entry["gshirt_leader"]==1 ? 'width:32px;height:32px' : 'display: none;') }}"/> &nbsp;</td>
<td class="table-bordered">&nbsp;<a class="text list-unstyled {{ $entry['user_id']==Auth::user()->id ? 'blink_text' : '' }}" name="playerid_{{$entry['user_id']}}" href="#" style="vertical-align: middle;">{{ $entry["user_name"] }} &nbsp;</a></td>
<td class="table-bordered" align="center">&nbsp;{{ $entry["totalRankScore"] }}&nbsp;</td>
<td class="table-bordered" align="center">&nbsp;{{ $entry["rankscore"] }}&nbsp;</td>
@ -198,6 +198,7 @@
<td>Spiel-Ergebnis</td>
<td></td>
<td></td>
<td></td>
<td>&nbsp;</td> <!-- Spacer Column -->
<td align="center">{{ ($game_results[0]==-1? "" : $game_results[0]) }}</td>
<td align="center">{{ ($game_results[1]==-1? "" : $game_results[1]) }}</td>