/// <summary> /// Method to remove all the touched cards of Player /// deck if they belong to removable rules, /// and add them to discarded deck /// and add top card of discarded deck to Player deck /// </summary> /// <param name="player"></param> /// <param name="tempLongTouchedList"></param> public void MultiCardDiscardedDeckSwap(Player player, Deck tempLongTouchedList) { Debug.Log("Multi Card Discarded Deck Swap Started"); if (HandCombination.IsStraight(player, tempLongTouchedList) == true || HandCombination.isThreeOfKind(player, tempLongTouchedList) == true) { tempLongTouchedList.SortByRankAsc(); Card temp = DiscardedDeck.Deal(); int i = 0; int size = tempLongTouchedList.CardsCount(); while (i < size) { Card removeCard = player.RemoveCard(tempLongTouchedList.GetCardByIndex(i)); DiscardedDeck.Add(removeCard); i++; UnityMainThreadDispatcher.Schedule(SingleSwapAnimationFromDiscardedDeck(PlayerUIMapping.Instance.cardholder[currentPlayerIndex], removeCard, CardDistributionAnimation.instance.playersPosition[currentPlayerIndex], false), 0.1f); } UnityMainThreadDispatcher.Schedule(SingleSwapAnimationFromDiscardedDeck(PlayerUIMapping.Instance.cardholder[currentPlayerIndex], null, CardDistributionAnimation.instance.playersPosition[currentPlayerIndex], true), 0.1f); player.AddToHand(temp); tempLongTouchedList.Clear(); GameView.Instance.isClearMethodCompleted = false; UnityMainThreadDispatcher.Schedule(() => GameView.Instance.LoadClearMethod(), Constants.clearMethodDelay); //UnityMainThreadDispatcher.Instance().Enqueue(SwitchTurnToNextPlayer(false, Constants.turnPlayerDelay)); UnityMainThreadDispatcher.Schedule(() => SwitchTurnToNextPlayer(false, Constants.turnPlayerDelay), 0.5f); } Debug.Log("Multi Card Discarded Deck Swap Completed"); }
/// <summary> /// Method to decide which action to be taken by Player based on call percent calculation /// </summary> private void ChoseActionToPlayAndInformListeners() { int callPercent = GetCallPercent(GameController.Instance.GetPlayers(), this); Debug.Log("Call Percent" + callPercent); if (callPercent >= 85) { listener.SayMinimum(this); } else if (myDeck.CardsCount() < 3) { PickBestCard(myDeck, GameController.Instance.DiscardedDeck.GetTopCard()); } else { int straightResult = HandCombination.IsStraight(this, GameController.Instance.DiscardedDeck.GetTopCard()); Debug.Log("Straight Method result" + straightResult); // int threeOfKindResult = HandCombination.isThreeOfKind(this, GameController.Instance.DealtDeck.GetTopCard()); int threeOfKindResult = HandCombination.isThreeOfKind(this, GameController.Instance.DiscardedDeck.GetTopCard()); Debug.Log("Three of kinds method result" + threeOfKindResult); if (straightResult == 1) //Straight card exist in Player Deck { Debug.Log("Straight Card exist in Player Deck getting it now"); Deck straightCards = HandCombination.GetStraight(this); listener.MultiSwapFromDiscardedDeck(this, straightCards); } else if (straightResult == -1) //Straight card created by deck and discarded deck card combination { Debug.Log("Straight card created by deck and discarded deck card combination"); Card nonStraightCard = HandCombination.CreateStraight(this, GameController.Instance.DiscardedDeck.GetTopCard()); listener.SingleSwapFromDiscardedDeck(this, nonStraightCard); } else if (threeOfKindResult == 1) //Three of kind exist in Player Deck { Debug.Log("Three of kind exist in Player Deck getting it now"); Deck threeOfKind = HandCombination.GetThreeOfKind(this); listener.MultiSwapFromDiscardedDeck(this, threeOfKind); } else if (threeOfKindResult == -1) //Three of kind created using Player deck and Discarded Deck card { Debug.Log("Three of kind created using Player deck and Discarded Deck card"); Card threeOfKindCard = HandCombination.CreateThreeOfKind(this, GameController.Instance.DiscardedDeck.GetTopCard()); listener.SingleSwapFromDiscardedDeck(this, threeOfKindCard); } else { PickBestCard(myDeck, GameController.Instance.DiscardedDeck.GetTopCard()); //IF nothing match, pick AI player deck largest card } } }