Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * HI-LO games use the correct card order
- * values of 1 - 12.
- *
- * Blackjack games use the card order values,
- * of 2 - 13, where the 13th card of each suit
- * is the ace.
- *
- * This function sorts the blackjack card values
- * to comply with the correct order values of 1 - 12.
- *
- * @param $cards
- * @return
- */
- public static function fixCardValues($cards = array())
- {
- return $cards;
- $fixed = [];
- foreach ($cards as $card) {
- if ($card % 13 === 0) {
- array_push($fixed, ($card - 12 <= 0) ? 0 : $card - 12);
- } else {
- array_push($fixed, (int) $card);
- }
- }
- return $fixed;
- }
- /**
- * Retrieve the symbol for the specified suit.
- *
- * @param $suit
- * @return
- */
- public static function retrieveSuitSymbol($suit)
- {
- $suit = strtoupper($suit);
- switch ($suit) {
- case 'CLUBS':
- return "♣";
- case 'SPADES':
- return "♠";
- case 'HEARTS':
- return "♥";
- case 'DIAMONDS':
- return "♦";
- default:
- return null;
- }
- }
- /**
- * Retrieve the face card value.
- *
- * @param $cardNo
- * @return String
- */
- public static function retrieveCardFace($cardNo)
- {
- $face = [
- 'ACE', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'JACK', 'QUEEN', 'KING'
- ];
- return $face[$cardNo % 13];
- }
- /**
- * Retrieve the suit from the card number.
- *
- * @param $cardNo
- * @return String
- */
- public static function retrieveCardSuit($cardNo)
- {
- $suit = floor($cardNo / 13);
- switch ($suit) {
- case 0:
- return 'SPADES';
- case 1:
- return 'CLUBS';
- case 2:
- return 'HEARTS';
- case 3:
- return 'DIAMONDS';
- default:
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement