示例#1
0
        /// <summary>
        /// If me dropped card on table while defending then check if action is possible
        /// </summary>
        protected bool CanCoverThisCardWith(CardRoot cardOnTable, CardRoot heldCard)
        {
            //if table is empty
            if (TableIsEmpty || AllCardsCovered)
            {
                // say 'you are defending'
                GameplayMessageManager.Instance.ShowFullScreenText("На вас ходят");
                return(false);
            }

            //if i passed
            if (DefenderPassedPriority)
            {
                // say 'you passed'
                GameplayMessageManager.Instance.ShowFullScreenText("Вы решили брать");
                return(false);
            }

            bool cardOnTableIsTrump = cardOnTable.IsTrump();
            bool droppedCardIsTrump = heldCard.IsTrump();

            if (!cardOnTableIsTrump && droppedCardIsTrump)
            {
                return(true);
            }

            if (cardOnTableIsTrump && droppedCardIsTrump &&
                cardOnTable.Value < heldCard.Value)
            {
                return(true);
            }

            if (!cardOnTableIsTrump && !droppedCardIsTrump &&
                cardOnTable.Suit == heldCard.Suit &&
                cardOnTable.Value < heldCard.Value)
            {
                return(true);
            }

            // else
            {
                // say 'you can not defend with this card'
                GameplayMessageManager.Instance.ShowFullScreenText("Вы не можете побиться этой картой");
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// Find cards which can be targeted (has lower value and same suit)
        /// </summary>
        protected List <CardRoot> GetCardsCanBeTargetedBy(CardRoot heldCard)
        {
            //find cards that wasn't covered already
            var cardsCanBeTargeted = cardsOnTable.Where(card => !card.IsCoveredByACard);

            //held card is a trump?
            if (heldCard.IsTrump())
            {
                //find cards that ...
                return(cardsCanBeTargeted.Where(
                           card => !card.IsTrump() || //.. are not trump
                           (card.IsTrump() && card.Value < heldCard.Value)) //.. or cheaper trump
                       .ToList());                                          // return as list
            }
            else //held card is not a trump
            {
                //find cards that ...
                return(cardsCanBeTargeted.Where(
                           card => card.Value < heldCard.Value && //.. cheaper than held card
                           card.Suit == heldCard.Suit) //.. and has same suit
                       .ToList());                     // return as list
            }
        }