Start Algorithm for Match creation (incremental version)
This commit is contained in:
parent
7c9d5eef1e
commit
82e60df35f
6 changed files with 8619 additions and 3 deletions
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\leagues;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\leagues\League;
|
||||
use App\User;
|
||||
|
||||
class Match extends Model
|
||||
{
|
||||
|
|
@ -10,5 +12,77 @@ class Match extends Model
|
|||
protected $fillable = [
|
||||
'id','league_id','user1_id','user2_idsubrank','start_round_id','name'
|
||||
];
|
||||
//
|
||||
|
||||
public static function createMissingMatchups() {
|
||||
$currentSeason = Season::getCurrent();
|
||||
$leagues = League::where('season_id','=',$currentSeason->id);
|
||||
|
||||
// TODO: Differentiate Matchup selection by League Type
|
||||
|
||||
// Liga 1
|
||||
// Liga 2
|
||||
// Ligen 3 1,2,3,...n
|
||||
|
||||
// Liga 4 (Qualifikation)
|
||||
|
||||
|
||||
// Liga 5: Champions League
|
||||
|
||||
// Liga 7: Achtelfinale
|
||||
// Liga 8: Viertelfinale
|
||||
// Liga 9: Halbfinale
|
||||
// Liga 10: Finale
|
||||
|
||||
foreach($leagues as $league) {
|
||||
|
||||
// Qualifikation
|
||||
if ($league->rank == 4) {
|
||||
$matches = array();
|
||||
// Bereits bestehende Matches laden
|
||||
DB::table('leagues_matches')->where('league_id','=',$league->id)->get();
|
||||
$users = User::getActives();
|
||||
foreach($users as $user1) {
|
||||
$counter_users=getActives();
|
||||
foreach($counter_users as $user2) {
|
||||
if ($user1->id == $user2->id) continue;
|
||||
|
||||
if (!User::hasMatched($user1->id, $user2->id, $league->id)) {
|
||||
// add Match
|
||||
array_push($matches, [$user1, $user2]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Log::info("Open Matches:");
|
||||
foreach ($matches as $match) {
|
||||
// Oh je, jetzt noch die Runde festlegen
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Bestimmen, in welcher Runde das Spiel stattfinden soll.
|
||||
* Es darf kein Heim & Rückspiel in der gleichen Runde sein,
|
||||
* d.h. ein Spieler kommt in einer Runde nur einmal zu einem Match
|
||||
*
|
||||
* Stehen keine Runden mehr zur Verfügung (der Standardfall)
|
||||
* muss die Vergabe beendet werden. Neue Runden kommen dann
|
||||
* später im Verlauf der Halbsaison ins System.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// SOOOO
|
||||
// VIEL
|
||||
// SPASS !!!
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue