PileLogic PlayHand(HandScript.Play aPlay) { UpdateButton(playButton, playText, false, "Played"); UpdateButton(passButton, passText, false, "Pass"); //Stop our skip timer StopCoroutine(HandScript.Instance.timer); //Reform our hand and pile //Get the gameobjects of the cards we selected in a list List <GameObject> aHand = new List <GameObject>(); for (int i = 0; i < HandScript.Instance.selectedCards.Count; i++) { aHand.Add(HandScript.Instance.selectedCards[i].gameObject); //Make sure we cant touch these cards HandScript.Instance.selectedCards[i].Play(); } //Pass that list into our transform setter SetCardTransform(aHand.ToArray(), aHand.ToArray().Length, transform); //Reset the card objects aHand = new List <GameObject>(); //Get the objects in our hand foreach (Transform child in HandScript.Instance.gameObject.transform) { aHand.Add(child.gameObject); } //Recenter the cards in our hand SetCardTransform(aHand.ToArray(), aHand.ToArray().Length, HandScript.Instance.gameObject.transform); //Update the current play on the pile m_currentPlay.UpdatePlay(aPlay.type, aPlay.highestSuit, aPlay.highestNumber, aPlay.numberOfCards); //Update our hand HandScript.Instance.ClearHand(); HandScript.Instance.SetTurn(false); return(null); }
public bool IsPlayable(HandScript.Play aPlay) { if (aPlay.type == HandScript.Play.PlayType.Invalid) { return(false); } else if (m_currentPlay.type == HandScript.Play.PlayType.Null) { return(true); } else if (aPlay.type == HandScript.Play.PlayType.QuadTwo) { return(true); } else if (aPlay.type == HandScript.Play.PlayType.LionsHead) { return(true); } else { #region Two's //If the highest number is two if (m_currentPlay.highestNumber == CardScript.Number.Two) { //If its a single if (m_currentPlay.type == HandScript.Play.PlayType.Single) { //Do we have a bomb if (aPlay.type == HandScript.Play.PlayType.Bomb && (aPlay.numberOfCards == 6 || aPlay.numberOfCards == 4)) { return(true); } //Do we have a higher two else if (aPlay.type == HandScript.Play.PlayType.Single && aPlay.highestNumber == CardScript.Number.Two && aPlay.highestSuit > m_currentPlay.highestSuit) { return(true); } //Else its not playable else { return(false); } } //If its a double else if (m_currentPlay.type == HandScript.Play.PlayType.Double) { //Do we have a bomb if (aPlay.type == HandScript.Play.PlayType.Bomb && aPlay.numberOfCards == 8) { return(true); } //Do we have a higher pair else if (aPlay.type == HandScript.Play.PlayType.Double && aPlay.highestNumber == CardScript.Number.Two && aPlay.highestSuit > m_currentPlay.highestSuit) { return(true); } //Else its not playable else { return(false); } } //If its a triple else if (m_currentPlay.type == HandScript.Play.PlayType.Triple) { //Do we have a bomb if (aPlay.type == HandScript.Play.PlayType.Bomb && aPlay.numberOfCards == 10) { return(true); } //Else its not playable else { return(false); } } //If its in a straight, we dont allow that, maybe a rule later on else { return(false); } } #endregion else { //If the play types match if (m_currentPlay.type == aPlay.type) { #region Straights //If we are playing straights if (m_currentPlay.type == HandScript.Play.PlayType.Straight) { //Do we have a straight that has the same amount of cards if (m_currentPlay.numberOfCards == aPlay.numberOfCards) { //If we have a higher number if (m_currentPlay.highestNumber < aPlay.highestNumber) { return(true); } //If we have a lower number else if (m_currentPlay.highestNumber > aPlay.highestNumber) { return(false); } //If the highest number is the same else { //Do we have a higher suit if (m_currentPlay.highestSuit > aPlay.highestSuit) { return(false); } else { return(true); } } } //Else its not playable else { return(false); } } #endregion #region Singles //If we are playing singles else if (m_currentPlay.type == HandScript.Play.PlayType.Single) { //If we have a higher number if (m_currentPlay.highestNumber < aPlay.highestNumber) { return(true); } // If we have a lower number else if (m_currentPlay.highestNumber > aPlay.highestNumber) { return(false); } //If the highest number is the same else { //Do we have a higher suit if (m_currentPlay.highestSuit > aPlay.highestSuit) { return(false); } else { return(true); } } } #endregion #region Doubles //If we are playing doubles else if (m_currentPlay.type == HandScript.Play.PlayType.Double) { //If we have a higher number if (m_currentPlay.highestNumber < aPlay.highestNumber) { return(true); } // If we have a lower number else if (m_currentPlay.highestNumber > aPlay.highestNumber) { return(false); } //If the highest number is the same else { //Do we have a higher suit if (m_currentPlay.highestSuit > aPlay.highestSuit) { return(false); } else { return(true); } } } #endregion #region Triples //If we are playing triples else if (m_currentPlay.type == HandScript.Play.PlayType.Triple) { //If we have a higher number if (m_currentPlay.highestNumber < aPlay.highestNumber) { return(true); } // If we have a lower number else { return(false); } } #endregion //If we have some error/not playable else { return(false); } } //If the play types are different else { return(false); } } } }