...
This commit is contained in:
parent
ed0c445bfa
commit
30f6157606
15 changed files with 248 additions and 169 deletions
|
|
@ -65,114 +65,9 @@ class LeaguesController extends Controller
|
||||||
return view('leagues.index', compact('season','rounds','start_round_id','start_round_name','league_mode','round_count'));
|
return view('leagues.index', compact('season','rounds','start_round_id','start_round_name','league_mode','round_count'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createLeagues($start_round_id, $round_count, $league_mode) {
|
public function createLeagues($start_round_id, $round_count) {
|
||||||
$currentSeason=Season::getCurrent();
|
|
||||||
|
|
||||||
// Eventuell vorhandene Ligen loeschen
|
|
||||||
$leagues=League::where('season_id','=',$currentSeason->id)->get();
|
|
||||||
if ($leagues) {
|
|
||||||
foreach ($leagues as $league) {
|
|
||||||
DB::table('leagues_matches')->where('league_id', '=', $league->id)->delete();
|
|
||||||
DB::table('leagues_members')->where('league_id', '=', $league->id)->delete();
|
|
||||||
DB::table('leagues')->where('id', '=', $league->id)->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$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 Quali-Gruppen: ".$neededLeagues);
|
|
||||||
|
|
||||||
$league_ids=array();
|
|
||||||
Log::info("League Mode:".$league_mode);
|
|
||||||
|
|
||||||
if ($league_mode=="Qualifikation") {
|
|
||||||
for ($league_nr=1; $league_nr<=$neededLeagues; $league_nr+=1) {
|
|
||||||
$league = League::create([
|
|
||||||
'is_qualification' => true,
|
|
||||||
'name' => 'Qualifikationsgruppe '.$league_nr,
|
|
||||||
'rank' => '4',
|
|
||||||
'subrank' => $league_nr,
|
|
||||||
'round_count' => $round_count,
|
|
||||||
'season_id' => $currentSeason->id,
|
|
||||||
'start_round_id' => $start_round_id
|
|
||||||
]);
|
|
||||||
$league->save();
|
|
||||||
$league_ids[$league_nr-1] = $league->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Distribute members
|
|
||||||
$users = User::getActives();
|
|
||||||
shuffle($users);
|
|
||||||
$league_index=0;
|
|
||||||
Log::info("Distributing Members between groups");
|
|
||||||
while(sizeof($users)>0) {
|
|
||||||
$user = array_pop($users);
|
|
||||||
|
|
||||||
$leagueMember = LeagueMember::create([
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'league_id' => $league_ids[$league_index]
|
|
||||||
]);
|
|
||||||
$leagueMember->save();
|
|
||||||
|
|
||||||
$league_index+=1;
|
|
||||||
if (sizeof($league_ids)==$league_index) { $league_index=0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// ToDo: Branch Qualifikation/Liga entfällt in Zukunft, da Quali der Fallback für den Fall ist, dass keine vorherige Saison existiert.
|
|
||||||
// Pokal und Play-Off findet hier nicht statt, da diese Wettbewerbe die Matches abgängig von existierenden Vorrunden-Ergebnissen erzeugen,
|
|
||||||
// und daher zwangsläufig inkrementell sein müssen.
|
|
||||||
|
|
||||||
$league_size1= min(22,$active_member_count);
|
|
||||||
$league1 = League::create([
|
|
||||||
'is_qualification' => false,
|
|
||||||
'name' => 'Spielerliga 1',
|
|
||||||
'rank' => '1',
|
|
||||||
'subrank' => '1',
|
|
||||||
'round_count' => $round_count,
|
|
||||||
'season_id' => $currentSeason->id,
|
|
||||||
'start_round_id' => $start_round_id
|
|
||||||
]);
|
|
||||||
|
|
||||||
$league_size2=min(22,$active_member_count - $league_size1);
|
|
||||||
|
|
||||||
if ($league_size2>0) {
|
|
||||||
$league2 = League::create([
|
|
||||||
'is_qualification' => false,
|
|
||||||
'name' => 'Spielerliga 2',
|
|
||||||
'rank' => '2',
|
|
||||||
'subrank' => '1',
|
|
||||||
'round_count' => $round_count,
|
|
||||||
'season_id' => $currentSeason->id,
|
|
||||||
'start_round_id' => $start_round_id
|
|
||||||
]);
|
|
||||||
|
|
||||||
$league_size3 = $active_member_count - $league_size1 - $league_size2;
|
|
||||||
|
|
||||||
if ($league_size3>0) {
|
|
||||||
$neededLeagues = League::neededLeagues($league_size3, $round_count);
|
|
||||||
for ($league_nr=1; $league_nr<=$neededLeagues; $league_nr+=1) {
|
|
||||||
$league = League::create([
|
|
||||||
'is_qualification' => false,
|
|
||||||
'name' => 'Spielerliga 3, Gruppe '.$league_nr,
|
|
||||||
'rank' => '3',
|
|
||||||
'subrank' => $league_nr,
|
|
||||||
'round_count' => $round_count,
|
|
||||||
'season_id' => $currentSeason->id,
|
|
||||||
'start_round_id' => $start_round_id
|
|
||||||
]);
|
|
||||||
$league->save();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: LeagueMembers zu den Leagues hinzufügen, abhängig vom zuzuordnenden Platz
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
League::createLeagues($start_round_id, $round_count);
|
||||||
Match::createMatchups();
|
Match::createMatchups();
|
||||||
|
|
||||||
return redirect("/seasons");
|
return redirect("/seasons");
|
||||||
|
|
|
||||||
|
|
@ -18,24 +18,17 @@ class SeasonsController extends Controller
|
||||||
{
|
{
|
||||||
public function index() {
|
public function index() {
|
||||||
if (Auth::guest()) { return redirect("/"); }
|
if (Auth::guest()) { return redirect("/"); }
|
||||||
if (!Auth::user()->admin) { return redirect("/"); }
|
if (!Auth::user()->admin) { return redirect("/"); }
|
||||||
|
|
||||||
$seasons = DB::table('seasons')->get();
|
$seasons = DB::table('seasons')->get();
|
||||||
|
|
||||||
|
|
||||||
$currentSeason=Season::getCurrent();
|
$currentSeason=Season::getCurrent();
|
||||||
|
|
||||||
|
|
||||||
$quotas = Quota::getQuotas($currentSeason->id);
|
|
||||||
if (!$quotas) {
|
|
||||||
Quota::createDefaultQuota($currentSeason->id);
|
|
||||||
$quotas = Quota::getQuotas($currentSeason->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$active_user_count = sizeof( User::getActives() );
|
$active_user_count = sizeof( User::getActives() );
|
||||||
|
|
||||||
$quotas = Quota::getQuotas($currentSeason->id);
|
$currentSeasonId=-1;
|
||||||
$payouts = Quota::getPayouts($currentSeason->id);
|
if ($currentSeason) {
|
||||||
|
$quotas = Quota::getQuotas($currentSeason->id);
|
||||||
|
$payouts = Quota::getPayouts($currentSeason->id);
|
||||||
|
}
|
||||||
|
|
||||||
return view('seasons.index', compact('seasons','currentSeason','active_user_count','quotas','payouts'));
|
return view('seasons.index', compact('seasons','currentSeason','active_user_count','quotas','payouts'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,10 @@ class UsersController extends Controller
|
||||||
$nextRoundName="";
|
$nextRoundName="";
|
||||||
$nextRound = Round::getFirstTippableRound();
|
$nextRound = Round::getFirstTippableRound();
|
||||||
|
|
||||||
|
$nextRoundName = "";
|
||||||
$nextRoundLockTime = "";
|
$nextRoundLockTime = "";
|
||||||
$diffToLock ="";
|
$diffToLock ="";
|
||||||
|
$hourDiffToLock = 999;
|
||||||
if ($nextRound) {
|
if ($nextRound) {
|
||||||
$nextRoundName = $nextRound->name;
|
$nextRoundName = $nextRound->name;
|
||||||
$nextRoundLockTime = $nextRound->getLockTime();
|
$nextRoundLockTime = $nextRound->getLockTime();
|
||||||
|
|
@ -98,6 +100,7 @@ class UsersController extends Controller
|
||||||
$activeUsers = User::getActives();
|
$activeUsers = User::getActives();
|
||||||
|
|
||||||
$currentSeason=Season::getCurrent();
|
$currentSeason=Season::getCurrent();
|
||||||
|
if (!$currentSeason) { return redirect('/'); }
|
||||||
|
|
||||||
$active_user_count = sizeof( $activeUsers );
|
$active_user_count = sizeof( $activeUsers );
|
||||||
$total_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->get() );
|
$total_user_count = sizeof( DB::table('payments')->where('season_id',$currentSeason->id)->get() );
|
||||||
|
|
@ -121,8 +124,6 @@ class UsersController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return view('users.index', compact('users','active_user_count','total_user_count'));
|
return view('users.index', compact('users','active_user_count','total_user_count'));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -201,8 +202,7 @@ class UsersController extends Controller
|
||||||
if($max_round_id==-1) {
|
if($max_round_id==-1) {
|
||||||
$max_round_id = Round::getLastLockedRoundId();
|
$max_round_id = Round::getLastLockedRoundId();
|
||||||
if ($max_round_id==-1) {
|
if ($max_round_id==-1) {
|
||||||
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$season->id." and games.round_id=rounds.id;";
|
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$seasonId." and games.round_id=rounds.id;";
|
||||||
dd($sql);
|
|
||||||
$date = DB::select($sql);
|
$date = DB::select($sql);
|
||||||
|
|
||||||
if (count($date)>0) {
|
if (count($date)>0) {
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,10 @@ class Round extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFirstIncompleteRound() {
|
public static function getFirstIncompleteRound() {
|
||||||
$season_id = Season::getCurrent()->id;
|
$season = Season::getCurrent();
|
||||||
$rounds = Round::where('season_id','=',$season_id)->orderBy('id')->get();
|
if (!$season) return -1;
|
||||||
|
|
||||||
|
$rounds = Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||||
foreach($rounds as $round) {
|
foreach($rounds as $round) {
|
||||||
if (!Round::isCompleted($round->id)) return $round->id;
|
if (!Round::isCompleted($round->id)) return $round->id;
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +71,8 @@ class Round extends Model
|
||||||
|
|
||||||
public static function getNextRoundId($roundId) {
|
public static function getNextRoundId($roundId) {
|
||||||
$currentSeason = Season::getCurrent();
|
$currentSeason = Season::getCurrent();
|
||||||
|
if (!$currentSeason) return -1;
|
||||||
|
|
||||||
$rounds = Round::where('season_id','=',$currentSeason->id)->where('id','>=',$roundId)->get();
|
$rounds = Round::where('season_id','=',$currentSeason->id)->where('id','>=',$roundId)->get();
|
||||||
foreach($rounds as $round) {
|
foreach($rounds as $round) {
|
||||||
if ($round->id == $roundId) { continue; }
|
if ($round->id == $roundId) { continue; }
|
||||||
|
|
@ -79,6 +83,7 @@ class Round extends Model
|
||||||
|
|
||||||
public static function getLastLockedRoundId() {
|
public static function getLastLockedRoundId() {
|
||||||
$season = Season::getCurrent();
|
$season = Season::getCurrent();
|
||||||
|
if (!$season) return -1;
|
||||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||||
$lastLockedRoundId=-1;
|
$lastLockedRoundId=-1;
|
||||||
foreach ($rounds as $round) {
|
foreach ($rounds as $round) {
|
||||||
|
|
@ -89,8 +94,15 @@ class Round extends Model
|
||||||
return $lastLockedRoundId;
|
return $lastLockedRoundId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getFirstTippableRoundId() {
|
||||||
|
$round = Round::getFirstTippableRound();
|
||||||
|
if (!$round) return -1;
|
||||||
|
return $round->id;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getFirstTippableRound() {
|
public static function getFirstTippableRound() {
|
||||||
$season = Season::getCurrent();
|
$season = Season::getCurrent();
|
||||||
|
if (!$season) return null;
|
||||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||||
$locked = false;
|
$locked = false;
|
||||||
foreach ($rounds as $round) {
|
foreach ($rounds as $round) {
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ class Tipp extends Model
|
||||||
$round_ids=array();
|
$round_ids=array();
|
||||||
|
|
||||||
// Write sql result to roundtipps (score per round & user)
|
// Write sql result to roundtipps (score per round & user)
|
||||||
if ($max_round_id==-1) { $max_round_id=Round::getLastLockedRoundId(); }
|
if ($max_round_id==-1) { $max_round_id=Round::getLastCompleteRoundId(); }
|
||||||
foreach ($result as $entry) {
|
foreach ($result as $entry) {
|
||||||
$round_id = $entry->round_id;
|
$round_id = $entry->round_id;
|
||||||
if ($max_round_id >-1 && $round_id>$max_round_id) break;
|
if ($max_round_id >-1 && $round_id>$max_round_id) break;
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,10 @@ class User extends Authenticatable
|
||||||
|
|
||||||
// aktiv = hat die Saison bezahlt.
|
// aktiv = hat die Saison bezahlt.
|
||||||
public static function getActives($seasonId=-1) {
|
public static function getActives($seasonId=-1) {
|
||||||
|
|
||||||
$currentSeason=Season::getCurrent();
|
$currentSeason=Season::getCurrent();
|
||||||
if ($seasonId != -1) { $currentSeason = Season::where('id','=',$seasonId); }
|
if ($seasonId != -1) { $currentSeason = Season::where('id','=',$seasonId); }
|
||||||
|
if (!$currentSeason) return array();
|
||||||
|
|
||||||
$users = User::all();
|
$users = User::all();
|
||||||
$payments = Payment::where('season_id','=',$currentSeason->id)->get();
|
$payments = Payment::where('season_id','=',$currentSeason->id)->get();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,11 +62,33 @@ class League extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function cmpScore($score1, $score2) {
|
public static function cmpScore($score1, $score2) {
|
||||||
return ($score1[1] < $score2[1]);
|
// [0] = user-id
|
||||||
|
$_score1 = $score1[1];
|
||||||
|
$goals1 = $score1[2];
|
||||||
|
$cGoals1 = $score1[3];
|
||||||
|
|
||||||
|
$_score2 = $score2[1];
|
||||||
|
$goals2 = $score2[2];
|
||||||
|
$cGoals2 = $score2[3];
|
||||||
|
|
||||||
|
$diff1 = $goals1-$cGoals1;
|
||||||
|
$diff2 = $goals2-$cGoals2;
|
||||||
|
|
||||||
|
if ($_score1 == $_score2) {
|
||||||
|
if ($diff1==$diff2) {
|
||||||
|
if ($goals1 == $goals2) {
|
||||||
|
return $cGoals1 > $cGoals2;
|
||||||
|
}
|
||||||
|
return ( $goals1 < $goals2 );
|
||||||
|
}
|
||||||
|
return ($diff1<$diff2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($_score1 < $_score2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getRanking($rank, $seasonId=-1) {
|
public static function getRanking($rank, $seasonId=-1) {
|
||||||
$season = Season::getCurrent();
|
$season = Season::getCurrent();
|
||||||
if ($seasonId > -1) { $season=Season::where('id','=',$seasonId)->first(); };
|
if ($seasonId > -1) { $season=Season::where('id','=',$seasonId)->first(); };
|
||||||
|
|
@ -122,21 +144,155 @@ class League extends Model
|
||||||
return $unifiedScores;
|
return $unifiedScores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ausfaktoriert aus LeaguesController::createLeagues()
|
||||||
|
// TODO: $round_count ist nur im Quali-Modus relevant und steuert, wieviele Quali-Gruppen benötigt werden.
|
||||||
|
// TODO: Sobald es Liga1 und Liga2 gibt, wird der round_count immer 21 sein, da Liga1 und Liga2 auf
|
||||||
|
// TODO: 22 Mitspieler festgelegt sind.
|
||||||
|
|
||||||
|
public static function createLeagues($start_round_id, $round_count) {
|
||||||
|
$currentSeason=Season::getCurrent();
|
||||||
|
|
||||||
|
// Eventuell vorhandene Ligen loeschen
|
||||||
|
$leagues=League::where('season_id','=',$currentSeason->id)->get();
|
||||||
|
if ($leagues) {
|
||||||
|
foreach ($leagues as $league) {
|
||||||
|
DB::table('leagues_matches')->where('league_id', '=', $league->id)->delete();
|
||||||
|
DB::table('leagues_members')->where('league_id', '=', $league->id)->delete();
|
||||||
|
DB::table('leagues')->where('id', '=', $league->id)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 Quali-Gruppen: ".$neededLeagues);
|
||||||
|
|
||||||
|
$league_ids=array();
|
||||||
|
|
||||||
|
//TODO: Den Leaguemode kann die Methode selbst rausfinden.
|
||||||
|
//TODO: Wenn es keine Vorsaison gibt -> Qualifikation
|
||||||
|
//TODO: Ansonsten: Ligen erzeugen.
|
||||||
|
$league_mode="Qualifikation";
|
||||||
|
|
||||||
|
if ($league_mode=="Qualifikation") {
|
||||||
|
for ($league_nr=1; $league_nr<=$neededLeagues; $league_nr+=1) {
|
||||||
|
$league = League::create([
|
||||||
|
'is_qualification' => true,
|
||||||
|
'name' => 'Qualifikationsgruppe '.$league_nr,
|
||||||
|
'rank' => '4',
|
||||||
|
'subrank' => $league_nr,
|
||||||
|
'round_count' => $round_count,
|
||||||
|
'season_id' => $currentSeason->id,
|
||||||
|
'start_round_id' => $start_round_id
|
||||||
|
]);
|
||||||
|
$league->save();
|
||||||
|
$league_ids[$league_nr-1] = $league->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Distribute members
|
||||||
|
$users = User::getActives();
|
||||||
|
shuffle($users);
|
||||||
|
$league_index=0;
|
||||||
|
Log::info("Distributing Members between groups");
|
||||||
|
while(sizeof($users)>0) {
|
||||||
|
$user = array_pop($users);
|
||||||
|
|
||||||
|
$leagueMember = LeagueMember::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'league_id' => $league_ids[$league_index]
|
||||||
|
]);
|
||||||
|
$leagueMember->save();
|
||||||
|
|
||||||
|
$league_index+=1;
|
||||||
|
if (sizeof($league_ids)==$league_index) { $league_index=0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// ToDo: Branch Qualifikation/Liga entfällt in Zukunft, da Quali der Fallback für den Fall ist, dass keine vorherige Saison existiert.
|
||||||
|
// Pokal und Play-Off findet hier nicht statt, da diese Wettbewerbe die Matches abgängig von existierenden Vorrunden-Ergebnissen erzeugen,
|
||||||
|
// und daher zwangsläufig inkrementell sein müssen.
|
||||||
|
|
||||||
|
$league_size1= min(22,$active_member_count);
|
||||||
|
$league1 = League::create([
|
||||||
|
'is_qualification' => false,
|
||||||
|
'name' => 'Spielerliga 1',
|
||||||
|
'rank' => '1',
|
||||||
|
'subrank' => '1',
|
||||||
|
'round_count' => $round_count,
|
||||||
|
'season_id' => $currentSeason->id,
|
||||||
|
'start_round_id' => $start_round_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$league_size2=min(22,$active_member_count - $league_size1);
|
||||||
|
|
||||||
|
if ($league_size2>0) {
|
||||||
|
$league2 = League::create([
|
||||||
|
'is_qualification' => false,
|
||||||
|
'name' => 'Spielerliga 2',
|
||||||
|
'rank' => '2',
|
||||||
|
'subrank' => '1',
|
||||||
|
'round_count' => $round_count,
|
||||||
|
'season_id' => $currentSeason->id,
|
||||||
|
'start_round_id' => $start_round_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$league_size3 = $active_member_count - $league_size1 - $league_size2;
|
||||||
|
|
||||||
|
if ($league_size3>0) {
|
||||||
|
$neededLeagues = League::neededLeagues($league_size3, $round_count);
|
||||||
|
for ($league_nr=1; $league_nr<=$neededLeagues; $league_nr+=1) {
|
||||||
|
$league = League::create([
|
||||||
|
'is_qualification' => false,
|
||||||
|
'name' => 'Spielerliga 3, Gruppe '.$league_nr,
|
||||||
|
'rank' => '3',
|
||||||
|
'subrank' => $league_nr,
|
||||||
|
'round_count' => $round_count,
|
||||||
|
'season_id' => $currentSeason->id,
|
||||||
|
'start_round_id' => $start_round_id
|
||||||
|
]);
|
||||||
|
$league->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: LeagueMembers zu den Leagues hinzufügen, abhängig vom zuzuordnenden Platz
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Aktuelle Liga-Zuordnung auf Basis des Rangs in der letzten Liga
|
// Aktuelle Liga-Zuordnung auf Basis des Rangs in der letzten Liga
|
||||||
|
// Oder des Rangs in der Qualifikation
|
||||||
|
// oder erstellung des Quali Rangs wenn es keine previous Season gibt.
|
||||||
|
|
||||||
|
|
||||||
|
// Liga-Zugehörigkeit festlegen. Setzt voraus, dass die Ligen bereits erzeugt wurden.
|
||||||
public static function setLeagueForPlayers()
|
public static function setLeagueForPlayers()
|
||||||
|
/*
|
||||||
|
* setLeagueForPlayers__NEW_QUALIFICATION case1
|
||||||
|
* setLeagueForPlayers__FROM_QUALIFICATION case2
|
||||||
|
* setLeagueForPlayers__FROM_LEAGUES case3
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
$previousSeason = Season::getPrevious();
|
$previousSeason = Season::getPrevious();
|
||||||
$currentSeason = Season::getCurrent();
|
$currentSeason = Season::getCurrent();
|
||||||
|
$users = User::getActives();
|
||||||
|
|
||||||
if (!$previousSeason) {
|
if (!$previousSeason) {
|
||||||
dd("No last season handling implemented. Please fix/implement.");
|
// case 1: first season ever, no previous season exists, qualification (league-rank=4)
|
||||||
//TODO: Implement a qualification round
|
} elseif (Season::hasQualification($previousSeason->id)){
|
||||||
|
// case 2: previous season was qualification season (rank 4)
|
||||||
return;
|
} else { /*case 3 - default: determine league-ranks 1,2,3 from previous Season rank verwenden*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = User::getActives();
|
|
||||||
|
// 2 Möglichkeiten:
|
||||||
|
// 1.) previousSeason hat rank=4 => Qualification Round
|
||||||
|
// 2.) sonst aus .
|
||||||
|
|
||||||
|
|
||||||
$usersLastSeason = User::getActives($previousSeason->id);
|
$usersLastSeason = User::getActives($previousSeason->id);
|
||||||
|
|
||||||
$league1 = League::getUnifiedRanking(1, $previousSeason->id);
|
$league1 = League::getUnifiedRanking(1, $previousSeason->id);
|
||||||
|
|
@ -144,7 +300,14 @@ class League extends Model
|
||||||
$league3 = League::getUnifiedRanking( 3, $previousSeason->id);
|
$league3 = League::getUnifiedRanking( 3, $previousSeason->id);
|
||||||
//$lastLeagues = League::where('season_id','=',$previousSeason->id)->get();
|
//$lastLeagues = League::where('season_id','=',$previousSeason->id)->get();
|
||||||
|
|
||||||
foreach ($users as $key => $user) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
foreach ($users as $index => $user) {
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($usersLastSeason as $userLastSeason) {
|
foreach ($usersLastSeason as $userLastSeason) {
|
||||||
|
|
@ -152,7 +315,12 @@ class League extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$found) {
|
if (!$found) {
|
||||||
$users[$key]['rank']=League::RANK_LEAGUE3; // In der letzten Season unter den Actives nicht gefunden
|
$users[$index]['rank']=League::RANK_LEAGUE3; // In der letzten Season unter den Actives nicht gefunden
|
||||||
|
$leagueMember = LeagueMember::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'league_id' => $league3->id
|
||||||
|
]);
|
||||||
|
$leagueMember->save();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// League1, 1-16: RANK_LEAGUE1
|
// League1, 1-16: RANK_LEAGUE1
|
||||||
|
|
@ -163,6 +331,8 @@ class League extends Model
|
||||||
// League3, best6: RANK_LEAGUE2
|
// League3, best6: RANK_LEAGUE2
|
||||||
// League3, 7-end: RANK_LEAGUE3
|
// League3, 7-end: RANK_LEAGUE3
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//alte Ligen durchsuchen und entsprechend einordnen
|
||||||
foreach($league1 as $index => $entry) {
|
foreach($league1 as $index => $entry) {
|
||||||
$userId = $entry[0];
|
$userId = $entry[0];
|
||||||
$score = $entry[1];
|
$score = $entry[1];
|
||||||
|
|
@ -238,5 +408,7 @@ class League extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,11 @@ class Match extends Model
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Round-robin_tournament
|
// https://en.wikipedia.org/wiki/Round-robin_tournament
|
||||||
public static function createMatchups()
|
public static function createMatchups()
|
||||||
{ Log::info("Match::Creating matchups()");
|
|
||||||
|
{ // should be restricted to league ranks 1,2,3 and 4. All other leagues will have to use some
|
||||||
|
// incremental matchmaking system.
|
||||||
|
|
||||||
|
Log::info("Match::Creating matchups()");
|
||||||
$currentSeason = Season::getCurrent();
|
$currentSeason = Season::getCurrent();
|
||||||
$leagues = League::where('season_id', '=', $currentSeason->id)->get();
|
$leagues = League::where('season_id', '=', $currentSeason->id)->get();
|
||||||
foreach ($leagues as $league) {
|
foreach ($leagues as $league) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
</label>
|
</label>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<a style="font-color: blue; font-size: 22px;" href="/tipps#{{\App\Round::getFirstTippableRound()->id}}">Tipps</a>
|
<a style="font-color: blue; font-size: 22px;" href="/tipps#{{\App\Round::getFirstTippableRoundId()}}">Tipps</a>
|
||||||
|
|
||||||
<a style="font-color: blue; font-size: 22px;" href="/users/ranking/roundid_-1#playerid_{{Auth::user()->id}}" >Rangliste</a>
|
<a style="font-color: blue; font-size: 22px;" href="/users/ranking/roundid_-1#playerid_{{Auth::user()->id}}" >Rangliste</a>
|
||||||
|
|
||||||
|
|
@ -25,10 +25,9 @@
|
||||||
<a href="#" id="btn_league" onclick="toggleSelect('dropdown_league'); return false;" style="font-weight:normal; font-color: blue; font-size: 22px;">Spieler-Liga</a>
|
<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">
|
<div id="dropdown_league" class="dropdown-content">
|
||||||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league_show_rounds/league_rank=4/round_id=30">Spielplan</a>
|
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league_show_rounds/league_rank=4/round_id=30">Spielplan</a>
|
||||||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league/show/rank=4/max_round_id=-1">Tabellen</a>
|
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league/show/rank=4/max_round_id=-1#user_{{Auth::user()->id}}">Tabellen</a>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
||||||
<label class="dropdown" id="dropdown3">
|
<label class="dropdown" id="dropdown3">
|
||||||
<a href="#" id="btn_info" onclick="toggleSelect('dropdown_info'); return false;" style="font-weight:normal; font-color: blue; font-size: 22px;">Info</a>
|
<a href="#" id="btn_info" onclick="toggleSelect('dropdown_info'); return false;" style="font-weight:normal; font-color: blue; font-size: 22px;">Info</a>
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,20 @@
|
||||||
|
|
||||||
<table class="table-bordered col-lg-12">
|
<table class="table-bordered col-lg-12">
|
||||||
<tr class="table-bordered">
|
<tr class="table-bordered">
|
||||||
<td class="table-bordered" style="width:50px;">Punkte</td>
|
<td class="table-bordered" style="width:50px;">Pos</td>
|
||||||
<td class="table-bordered" style="width:150px;">Spieler</td>
|
<td class="table-bordered" style="width:150px;">Spieler</td>
|
||||||
|
<td class="table-bordered" style="width:50px;">Punkte</td>
|
||||||
|
<td class="table-bordered" style="width:150px;">Tordifferenz</td>
|
||||||
<td class="table-bordered" style="width:150px;">Torverhältnis</td>
|
<td class="table-bordered" style="width:150px;">Torverhältnis</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- Start Matchgruppen-Loop-->
|
<!-- Start Matchgruppen-Loop-->
|
||||||
@foreach($playerTuples as $player)
|
@foreach($playerTuples as $pos => $player)
|
||||||
<tr class="table-bordered">
|
<tr class="table-bordered">
|
||||||
|
<td> {{$pos+1}} </td>
|
||||||
|
<td> <a name="user_{{$player[0]}}" class="{{ $player[0]==Auth::user()->id ? 'blink_text' : '' }}" href="/league/showSingleUserMatches/user_id={{$player[0]}}"> {{$userNames[$player[0]]}} </a> </td>
|
||||||
<td> {{$player[1]}} </td>
|
<td> {{$player[1]}} </td>
|
||||||
<td> <a href="/league/showSingleUserMatches/user_id={{$player[0]}}"> {{$userNames[$player[0]]}} </a> </td>
|
<td> {{$player[2]-$player[3]}} </td>
|
||||||
<td> {{$player[2]}}:{{$player[3]}} </td>
|
<td> {{$player[2]}}:{{$player[3]}} </td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
//alert($global_selected_round_id);
|
//alert($global_selected_round_id);
|
||||||
|
|
||||||
var round_count=document.getElementById("input_round_count").value;
|
var round_count=document.getElementById("input_round_count").value;
|
||||||
var link = '/league_settings/create_league/start_round_id='+global_start_round_id+"/round_count="+round_count+"/league_mode="+global_league_mode;
|
var link = '/league_settings/create_league/start_round_id='+global_start_round_id+"/round_count="+round_count;
|
||||||
//alert(link);
|
//alert(link);
|
||||||
window.location=link;
|
window.location=link;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
<span class="col-md-2"></span>
|
<span class="col-md-2"></span>
|
||||||
<span class="text-center col-md-8">
|
<span class="text-center col-md-8">
|
||||||
@if(Auth::check())
|
@if(Auth::check())
|
||||||
|
|
||||||
@if($hourDiffToLock<49)
|
@if($hourDiffToLock<49)
|
||||||
@if (strlen($message_text_tipps)>0)
|
@if (strlen($message_text_tipps)>0)
|
||||||
<div><p class="blink_text" style="font-size:21px;">{{ $message_text_tipps }}</p></div>
|
<div><p class="blink_text" style="font-size:21px;">{{ $message_text_tipps }}</p></div>
|
||||||
|
|
@ -17,17 +18,18 @@
|
||||||
<div><p class="blink_text" style="font-size:21px;">{{ $nextRoundName }} sperrt sich: {{ $nextRoundLockTime }} ( noch {{ $hourDiffToLock }} )</p></div>
|
<div><p class="blink_text" style="font-size:21px;">{{ $nextRoundName }} sperrt sich: {{ $nextRoundLockTime }} ( noch {{ $hourDiffToLock }} )</p></div>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
<h1 class="jumbotron-heading">Hoschis Tippspiel</h1>
|
<h1 class="jumbotron-heading">Hoschis Tippspiel</h1>
|
||||||
<p class="lead text-muted">Eine Tippgemeinschaft unter Freunden.</p>
|
<p class="lead text-muted">Eine Tippgemeinschaft unter Freunden.</p>
|
||||||
<div><p></p><p></p><p></p></div>
|
<div><p></p><p></p><p></p></div>
|
||||||
|
|
||||||
@if (!Auth::check())
|
@if (!Auth::check())
|
||||||
<div>
|
<div>
|
||||||
<a href="/login" class="btn btn-primary">Anmelden</a>
|
<a href="/login" class="btn btn-primary">Anmelden</a>
|
||||||
</div>
|
</div>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<div>
|
<div>
|
||||||
<a href="/register" class="btn btn-primary">Registrieren</a>
|
<a href="/register" class="btn btn-primary">Registrieren</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -35,14 +37,16 @@
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
@if (Auth::check())
|
@if (Auth::check())
|
||||||
@foreach($display_rounds as $round)
|
@if ($display_rounds)
|
||||||
<div class="container-fluid col-md-12">
|
@foreach($display_rounds as $round)
|
||||||
<span class="col-md-2"></span>
|
<div class="container-fluid col-md-12">
|
||||||
<span class="text-center col-md-8">
|
<span class="col-md-2"></span>
|
||||||
<h2> {{ $round['name'] }}</h2>
|
<span class="text-center col-md-8">
|
||||||
<div style="font-size: 18px;"> {!! $round['report'] !!}</div>
|
<h2> {{ $round['name'] }}</h2>
|
||||||
</span>
|
<div style="font-size: 18px;"> {!! $round['report'] !!}</div>
|
||||||
</div>
|
</span>
|
||||||
@endforeach
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@endsection
|
@endsection
|
||||||
|
|
@ -5,11 +5,12 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<label>{{ $activeSeason->name }}</label>
|
<label>{{ $activeSeason->name }}</label>
|
||||||
|
<!--
|
||||||
@if (sizeof($rounds)<$round_count)
|
if (sizeof($rounds)<$round_count)
|
||||||
<div><a href="/rounds/create" class="btn btn-primary" >Runde hinzufügen</a></div>
|
<div><a href="/rounds/create" class="btn btn-primary" >Runde hinzufügen</a></div>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
@endif
|
endif
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
@ -40,10 +41,8 @@
|
||||||
<div class="container-fluid" style="width:800px;">
|
<div class="container-fluid" style="width:800px;">
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
|
|
||||||
<p>Berichterstattung</p>
|
<p>Berichterstattung</p>
|
||||||
|
|
||||||
|
|
||||||
<form method="POST" action="/rounds/store_report" class="text-center">
|
<form method="POST" action="/rounds/store_report" class="text-center">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,11 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($currentSeason)
|
@if ($currentSeason)
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form method="POST" action="/seasons/store_quota">
|
<form method="POST" action="/seasons/store_quota">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
<h3>Anzahl Runden</h3>
|
<h3>Anzahl Runden</h3>
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ Route::get('/users/send_reset_links_from_settings','UsersController@send_reset_l
|
||||||
Route::get('/home', 'UsersController@main')->name('home');
|
Route::get('/home', 'UsersController@main')->name('home');
|
||||||
|
|
||||||
Route::get('/league_settings/season={season_id}','Leagues\LeaguesController@index');
|
Route::get('/league_settings/season={season_id}','Leagues\LeaguesController@index');
|
||||||
Route::get('/league_settings/create_league/start_round_id={start_round_id}/round_count={round_count}/league_mode={league_mode}','Leagues\LeaguesController@createLeagues');
|
Route::get('/league_settings/create_league/start_round_id={start_round_id}/round_count={round_count}','Leagues\LeaguesController@createLeagues');
|
||||||
Route::get('/league_show_rounds/league_rank={league_rank}/round_id={round_id}','Leagues\LeaguesController@showLeagueRounds');
|
Route::get('/league_show_rounds/league_rank={league_rank}/round_id={round_id}','Leagues\LeaguesController@showLeagueRounds');
|
||||||
Route::get('/league/show/rank={rank}/max_round_id={maxRoundId}','Leagues\LeaguesController@showLeagueRanking');
|
Route::get('/league/show/rank={rank}/max_round_id={maxRoundId}','Leagues\LeaguesController@showLeagueRanking');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue