/** * Replace match schedule with other matches with same match time * @param PlanningResults $result * @param QMatchPlan $match * @return MatchPlan|null */ private function replanMatch_2run(PlanningResults $result, QMatchPlan $match) { $result->mark(); while ($pa = $result->cycleTimeslot()) { /* Find a candidate for replacement */ $matchlist = $pa->getMatchlist(); /* @var $replan_match QMatchPlan */ foreach ($matchlist as $idx => $replan_match) { /* Both teams must be allowed to play now */ if ($replan_match->getCategory()->getMatchtime() == $match->getCategory()->getMatchtime() && $result->isQScheduleAvailable($match, $replan_match->getSchedule(), $pa->getTimeslot())) { $match->setDate($replan_match->getDate()); $match->setTime($replan_match->getTime()); $match->setPlayground($replan_match->getPlayground()); $matchlist[$idx] = $match; $pa->setMatchlist($matchlist); $result->setQSchedule($match, $replan_match->getSchedule()); $result->resetQSchedule($replan_match); $result->rewind(); return $replan_match; } } } return null; }
private function testQSchedule(QMatchPlan $match, DateTime $schedule, DateTime $slotschedule, Timeslot $timeslot) { if ($slotschedule < $schedule) { return false; } /* @var $diff DateInterval */ $diff = $slotschedule->diff($schedule); if ($diff->d * 24 * 60 + $diff->h * 60 + $diff->i < $match->getCategory()->getMatchtime() + $timeslot->getRestperiod()) { return false; } return true; }
private function buildQMatchPlan(QMatchSchedule $ms, QMatchPlan $match) { $match->setCategory($ms->getCategory()); $match->setClassification($ms->getClassification()); $match->setLitra($ms->getLitra()); /* @var $qrel QMatchScheduleRelation */ foreach ($ms->getQMatchRelations()->getValues() as $qrel) { $group = $qrel->getClassification() == Group::$PRE ? $ms->getCategory()->getNthGroup($qrel->getLitra()) : null; $qrelation = new QRelation($qrel->getClassification(), $qrel->getLitra(), $qrel->getRank(), $qrel->getBranch(), $group); if ($qrel->getAwayteam()) { $match->setRelB($qrelation); } else { $match->setRelA($qrelation); } } }
private function populateQMatches(Category $category, $strategy) { $matchList = array(); uksort($strategy, function ($k1, $k2) { preg_match('/(?<group>\\d+):(?<litra>\\d+[AB]*)/', $k1, $v1); preg_match('/(?<group>\\d+):(?<litra>\\d+[AB]*)/', $k2, $v2); if ($v1["group"] == $v2["group"]) { return $v1["litra"] - $v2["litra"]; } return $v1["group"] - $v2["group"]; }); foreach ($strategy as $key => $matches) { preg_match('/(?<classification>\\d+):(?<litra>\\d+[AB]*)/', $key, $group); foreach ($matches as $match) { if ($category->getTrophys() < 3 && $group['classification'] == Group::$BRONZE) { continue; } $qmp = new QMatchPlan(); $qmp->setClassification($group['classification']); $qmp->setLitra($group['litra']); preg_match('/(?<classification>\\d+):(?<litra>\\d+)(?<branch>[AB]*)r(?<rank>\\d+)/', $match[0], $team); $qmp->setRelA(new QRelation($team['classification'], $team['litra'], $team['rank'], isset($team['branch']) ? $team['branch'] : '')); preg_match('/(?<classification>\\d+):(?<litra>\\d+)(?<branch>[AB]*)r(?<rank>\\d+)/', $match[1], $team); $qmp->setRelB(new QRelation($team['classification'], $team['litra'], $team['rank'], isset($team['branch']) ? $team['branch'] : '')); $qmp->setFixed(false); $matchList[] = $qmp; } } return $matchList; }