/**
  * @param  \Application\Model\Hand $hand
  * @return array
  */
 protected function getHandData($hand)
 {
     if (null == $hand) {
         return array('cards' => array(), 'scores' => 0);
     }
     return array('cards' => $hand->getCards(), 'scores' => $hand->getScores());
 }
Exemple #2
0
 /**
  * Returns current state of the game
  *
  * @return integer
  */
 public function getState()
 {
     if (!$this->isStarted()) {
         return self::STATE_NOTSTARTED;
     }
     $result = self::STATE_CONTINUES;
     if ($this->game->isFinished()) {
         $pscores = $this->player->getScores();
         $dscores = $this->dealer->getScores();
         $result = self::STATE_LOOSE;
         if ($pscores == self::MAX_SCORES_PLAYER || $pscores < self::MAX_SCORES_PLAYER && ($pscores > $dscores || $dscores > self::MAX_SCORES_PLAYER)) {
             $result = self::STATE_WIN;
         } else {
             if ($dscores == $pscores) {
                 $result = self::STATE_DRAW;
             }
         }
     }
     return $result;
 }