...
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'));
|
||||
}
|
||||
|
||||
public function createLeagues($start_round_id, $round_count, $league_mode) {
|
||||
$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
|
||||
|
||||
}
|
||||
}
|
||||
public function createLeagues($start_round_id, $round_count) {
|
||||
|
||||
League::createLeagues($start_round_id, $round_count);
|
||||
Match::createMatchups();
|
||||
|
||||
return redirect("/seasons");
|
||||
|
|
|
|||
|
|
@ -18,24 +18,17 @@ class SeasonsController extends Controller
|
|||
{
|
||||
public function index() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$seasons = DB::table('seasons')->get();
|
||||
|
||||
|
||||
$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() );
|
||||
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
|
||||
$currentSeasonId=-1;
|
||||
if ($currentSeason) {
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
}
|
||||
|
||||
return view('seasons.index', compact('seasons','currentSeason','active_user_count','quotas','payouts'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,8 +52,10 @@ class UsersController extends Controller
|
|||
$nextRoundName="";
|
||||
$nextRound = Round::getFirstTippableRound();
|
||||
|
||||
$nextRoundName = "";
|
||||
$nextRoundLockTime = "";
|
||||
$diffToLock ="";
|
||||
$hourDiffToLock = 999;
|
||||
if ($nextRound) {
|
||||
$nextRoundName = $nextRound->name;
|
||||
$nextRoundLockTime = $nextRound->getLockTime();
|
||||
|
|
@ -98,6 +100,7 @@ class UsersController extends Controller
|
|||
$activeUsers = User::getActives();
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
if (!$currentSeason) { return redirect('/'); }
|
||||
|
||||
$active_user_count = sizeof( $activeUsers );
|
||||
$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'));
|
||||
}
|
||||
/*
|
||||
|
|
@ -201,8 +202,7 @@ class UsersController extends Controller
|
|||
if($max_round_id==-1) {
|
||||
$max_round_id = Round::getLastLockedRoundId();
|
||||
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;";
|
||||
dd($sql);
|
||||
$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;";
|
||||
$date = DB::select($sql);
|
||||
|
||||
if (count($date)>0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue