Example #1
  * @Route("/api/newgame")
  * @Method("POST")
 public function newGameAction()
     $game_logic = $this->get("game_logic");
     $word = $game_logic->get_random_word();
     if ($word) {
         //now that we have a word. Generate a unique id for the user
         $user_id = uniqid();
         //and save the user unique id in the DB:TB session
         $session = new Session();
         $session->setTs(new \DateTime("now"));
         $entity = $this->getDoctrine()->getManager();
         if ($entity) {
             //saved into DB? return the game info
             $new_game_info = $game_logic->get_session_raport($session, $game_logic->word_progress($session->getWord()));
             return new JsonResponse($new_game_info);
     return false;
Example #2
 public function reGenerateSession()
     $newSession = new Session();
     $_SESSION["ECommSessionId"] = $newSession->getId();
     return $newSession->getId();
Example #3
  * Attempts to form a group with all the members of the group from the previous round.
  * If a group can be formed, sets it as the current group for all of its members,
  * then returns that group.
  * Otherwise, sets the current status of this session to Session::group_request_pending,
  * then returns FALSE.
  * A group is considered "ready to be formed" when the status of each of its members
  * is Session::group_request_pending.
  * @param Session $session
  * @return Group if the group is formed, FALSE otherwise 
 public static function getOldGroup(Session $session)
     // set given group's satus as "request pending". this is for internal state checks.
     // get the group for the previous round
     $previous_group = $session->getGroup($session->currentRound()->previousRound());
     // are all members ready?
     $ready = array_reduce($previous_group->members, function ($v, $w) {
         return $v && $w->getStatus() == Session::group_request_pending;
     }, TRUE);
     if ($ready) {
         // let the group members know they're in a group
         self::setSessionsGroup($previous_group->members, $previous_group);
         return $previous_group;
     } else {
         return FALSE;