/** * 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; }