public static function setGameDetails(Game $game) { self::$logItem->setTurn($game->getTurn()); self::$logItem->setPhase($game->getPhase()->getName()); if ($game->getCurrentAction()) { $action = $game->getCurrentAction(); self::$logItem->setActionDetails($action->getDetails()); if ($action->getActionDie()) { self::$logItem->setActionDie($action->getActionDie()->getDetails()); } } }
/** * Advance game, actioning Phase related actions and decisions * @param Game $game * @return Decision */ protected function advanceGame(Game $game) { $em = $this->getDoctrine()->getManager(); // Loop until we have a decision point to go back to the user with while (!$game->getDecision()) { $a = $game->getCurrentAction(); if ($a) { if ($a->getSubAction()) { LogFactory::startLog($game); if ($a->hasDecision($game)) { $game->setDecision(); } else { // Execute also advances subAction $a->execute($game, $this); } LogFactory::completeLog($game->getLog()); } else { $a->setNextSubAction($game); } } else { // No action so advance Phase to get one $game->advancePhase(); } $em->flush(); } return $game->getDecision(); }