/** * CREATED BY: Peter Downie of peterdownie.com * Card class for making card programs! * Seperated into 4 catagories * CARDS are the deck! * Pile is for piles * Hands are for players hands, they are basically piles but allow for better distinction. * Counter is use for keeping track of scores or tricks. */ class card_game_kit{ /** Connects to the webservice @var soapClient */ public $ws; public $serverId; /** This is to call hidden functions */ public function __call($name,$arguments){ return $this->ws->__soapCall($name, $arguments); } /** This is to call functions using old code */ public function __soapCall($name,$arguments){ return $this->ws->__soapCall($name, $arguments); } /** This is to set cookie values functions */ public function setCookies($cookies_csv){ if($cookies_csv != null){ $splitCookies = explode(",",$cookies_csv); foreach($splitCookies as $currentCookie){ $subSplit= explode("=",$currentCookie); $this->ws->__setCookie($subSplit[0], $subSplit[1]); } } } public function __construct($cookies_csv){ $this->serverId="http://soap.peterdownie.com/webServices/card_game_kit/server.php"; $this->ws = new SoapClient(null,array("uri"=>"$this->serverId","location"=>"$this->serverId")); $this->setCookies($cookies_csv); } /** Save the data for later use in function restoreData */ public function saveData(){ return $this->ws->__soapCall("saveData",array()); } /** Restore Saved Data Produced by function saveData */ public function restoreData($savedData){ return $this->ws->__soapCall("restoreData",array($savedData)); } /** Generates standard playing cards with X number of decks. */ public function generateCards_standard($number_of_decks){ return $this->ws->__soapCall("generateCards_standard",array($number_of_decks)); } /** Generate a custom deck, for example a euchre deck which only uses 9,10,J,Q,K,A */ public function generateCards_special($number_of_decks,$cardValues,){ return $this->ws->__soapCall("generateCards_special",array($number_of_decks,$cardValues,$suits)); } /** Shuffle the cards */ public function shuffleCards(){ return $this->ws->__soapCall("shuffleCards",array()); } /** * See how many cards are left in the deck in the current order. */ public function seeRemainingCards(){ return $this->ws->__soapCall("seeRemainingCards",array()); } public function dealCard($number_of_cards=1){ return $this->ws->__soapCall("dealCard",array($number_of_cards)); } /** * Puts cards on the top of the deck * Does not return errors, must have suit and value in array. */ public function put_cards_on_top_of_deck($cards){ return $this->ws->__soapCall("put_cards_on_top_of_deck",array($cards)); } /** Puts cards onto the bottom of the deck. Does not return errors, must have suit and value in array. */ public function put_cards_on_bottom_of_deck($cards){ return $this->ws->__soapCall("put_cards_on_bottom_of_deck",array($cards)); } /** Buries cards into the deck. The cards stay together. */ public function bury_cards_into_random_part_of_deck($cards){ return $this->ws->__soapCall("bury_cards_into_random_part_of_deck",array($cards)); } /** Create a new pile. */ public function makePile($pileName){ return $this->ws->__soapCall("makePile",array($pileName)); } /** Create a new Hand. */ public function makeHand($handName){ return $this->ws->__soapCall("makeHand",array($handName)); } /** Adds cards to a players hand! */ public function addCardsToHand($handName,$cards){ return $this->ws->__soapCall("addCardsToHand",array($handName,$cards)); } /** * Add cards to a pile, based on add to a hand with better coding. */ public function addCardsToPile($pileName,$cards){ return $this->ws->__soapCall("addCardsToPile",array($pileName,$cards)); } /** Removes a card from a users hand. Removes multiple of same card only if specified. */ public function removeCardsFromHand($handName,$cards){ return $this->ws->__soapCall("removeCardsFromHand",array($handName,$cards)); } /** * Remove cards by suit and value from a specific pile. */ public function removeCardsFromPile($pileName,$cards){ return $this->ws->__soapCall("removeCardsFromPile",array($pileName,$cards)); } /** Get all cards in a users hand. */ public function getAllCardsInHand($handName){ return $this->ws->__soapCall("getAllCardsInHand",array($handName)); } /** Gets all of the cards from a pile. */ public function getAllCardsInPile($pileName){ return $this->ws->__soapCall("getAllCardsInPile",array($pileName)); } public function get_top_card($grouping,$groupName=FALSE){ return $this->ws->__soapCall("get_top_card",array($grouping,$groupName)); } /** Creates a counter and gives it a default value. */ public function make_counter($counterName,$default_value=0){ return $this->ws->__soapCall("make_counter",array($counterName,$default_value)); } /** Sets a counter to a value */ public function set_counter($counterName,$value){ return $this->ws->__soapCall("set_counter",array($counterName,$value)); } /** Adds or subtracts values from a counter. */ public function modify_counter($counterName,$modifier=1){ return $this->ws->__soapCall("modify_counter",array($counterName,$modifier)); } /** Gets the current value of a counter. */ public function get_counterValue($counterName){ return $this->ws->__soapCall("get_counterValue",array($counterName)); } }