private List <byte> GetSelectedCardValues() { List <byte> selectedCardValues = new List <byte>(); List <byte> playerBooks = gameDataManager.PlayerBooks(currentTurnPlayer); List <byte> hiddenBooks = gameDataManager.PlayerHiddenBooks(currentTurnPlayer); if (selectedCards.Count == 0 && currentTurnPlayer.isFinishedHandCards()) { selectedCardValues.AddRange(playerBooks); } if (selectedCards.Count == 0 && playerBooks.Count == 0 && currentTurnPlayer.isFinishedDisplayingBooks()) { List <byte> playerCards = gameDataManager.PlayerCards(currentTurnPlayer); selectedCardValues.AddRange(hiddenBooks); } foreach (Card card in selectedCards) { selectedCardValues.Add(card.Value); } return(selectedCardValues); }
public List <byte> AiDecideCardFromPlayer(Player player, Card topCard, Card previousTopCard) { List <byte> cardsToThrow = new List <byte>(); List <byte> playerCards = protectedData.PlayerCards(player); if (playerCards.Count == 0 && player.isFinishedHandCards()) { playerCards.AddRange(PlayerBooks(player)); } if (playerCards.Count == 0 && player.isFinishedDisplayingBooks()) { playerCards.AddRange(PlayerHiddenBooks(player)); } foreach (byte cardValue in playerCards) { bool doIhaveLuckyCardValue = (Card.GetRank(cardValue) == Ranks.Two || Card.GetRank(cardValue) == Ranks.Three || Card.GetRank(cardValue) == Ranks.Ten); bool isCardsToThrowEmpty = cardsToThrow.Count == 0; bool isCardValueFitsCardsToThrow = (cardsToThrow.Count > 0 && Card.GetRank(cardsToThrow[0]) == Card.GetRank(cardValue)); if (topCard != null && topCard.Value != Card.NO_VALUE && Card.GetRank(cardValue) <= Ranks.Seven && topCard.Rank == Ranks.Seven && Card.GetRank(cardValue) != Ranks.Ace) { if (isCardsToThrowEmpty || isCardValueFitsCardsToThrow) { cardsToThrow.Add(cardValue); } } else if (topCard == null || topCard.Rank == Ranks.Two) { if (isCardsToThrowEmpty || isCardValueFitsCardsToThrow) { cardsToThrow.Add(cardValue); } } else if (topCard != null && topCard.Rank == Ranks.Three) { if (previousTopCard != null) { if (Card.GetRank(cardValue) >= previousTopCard.Rank && previousTopCard.Rank != Ranks.Ace) { if (isCardsToThrowEmpty || isCardValueFitsCardsToThrow) { cardsToThrow.Add(cardValue); } } else if (previousTopCard.Rank == Ranks.Ace && doIhaveLuckyCardValue) { if (isCardsToThrowEmpty || isCardValueFitsCardsToThrow) { cardsToThrow.Add(cardValue); } } } } else if (topCard != null && topCard.Rank == Ranks.Ace && (Card.GetRank(cardValue) == Ranks.Ace || doIhaveLuckyCardValue)) { if (isCardsToThrowEmpty || isCardValueFitsCardsToThrow) { cardsToThrow.Add(cardValue); } } else if (topCard != null && topCard.Value != Card.NO_VALUE && Card.GetRank(cardValue) >= topCard.Rank && topCard.Rank != Ranks.Ace) { if (isCardsToThrowEmpty || isCardValueFitsCardsToThrow) { cardsToThrow.Add(cardValue); } } } return(cardsToThrow); }