GetShoe()->PickCard(); //Add the card to the hand player wants. $isMoveSuccessful = $table->player->Hit($handIndex, $card); break; case 'split': //Check if we can split $canSplit = $table->player->CanSplit($handIndex); if($canSplit instanceof \Blackjack\Objects\Error) //Return an error if we got an error from CanSplit function. return $canSplit; elseif (!$canSplit) //Otherwise check the boolean and tell the player that we cannot split. new \Blackjack\Objects\Error(E_BJ_CANNOT_SPLIT); //Get two cards for hits on two hands $card1 = $table->GetShoe()->PickCard(); $card2 = $table->GetShoe()->PickCard(); //Split the hand and update the state of the table $isMoveSuccessful = $table->player->SplitHand($handIndex, $card1, $card2); break; case 'dd': //Get a card from the shoe $card = $table->GetShoe()->PickCard(); //DoubleDown with the card on the hand that user wants. $isMoveSuccessful = $table->player->DoubleDown($handIndex, $card); case 'stand': $isMoveSuccessful = $table->player->GetHand($handIndex)->SetState(BJ_HAND_STAND); $table->SetDealerTurn(); break; default: $isMoveSuccessful = new \Blackjack\Objects\Error(E_BJ_MOVE_UNKNOWN); } if($isMoveSuccessful instanceof \Blackjack\Objects\Error) return $isMoveSuccessful; $table->UpdateTableState($handIndex); return $table; } // end of move evaluator //return the table in the session if nothing else return $_SESSION[BJ_SESSION_KEY_TABLE]; } $responseObject = GetResponse(); $response = new \Blackjack\Objects\Response($responseObject, $responseObject instanceof \Blackjack\Objects\Error, false); header('Content-type: application/json'); $jsonResponse = json_encode($response); if($_SESSION[BJ_SESSION_KEY_TABLE]->GetTableState() == BJ_TABLE_ENDED) { //clear session if(session_id() == '') session_start(); session_unset(); session_destroy(); $response->isSessionEnded = true; } echo $jsonResponse; ?>