Beispiel #1
0
    public override void PlayCard(Common.Card cardToPlay)
    {
        Card playedCard = null;

        if (uiDeck.playedCard != null)
        {
            playedCard = uiDeck.playedCard.GetCard();
        }

        if (playedCard == null || playedCard.GetCardType() != cardToPlay.GetCardType() || playedCard.GetCardValue() != cardToPlay.GetCardValue())
        {
            CardSlot[] cardSlots = uiDeck.GetCardSlots();
            int        i         = 0;
            bool       found     = false;
            while (!found)
            {
                if (cardSlots[i].Card.GetCardType() == cardToPlay.GetCardType() && cardSlots[i].Card.GetCardValue() == cardToPlay.GetCardValue())
                {
                    uiDeck.playedCard = cardSlots[i].CardObject.transform.GetComponent <UICard>();
                    PlayedCardsController.PlaceCard(cardSlots[i].CardObject.transform);
                    UserInteraction.InputActive = false;

                    // FINALLY ACTUALLY PLAY THE CARD
                    base.PlayCard(cardToPlay);
                    found = true;
                }
                i++;
            }
        }
        else
        {
            base.PlayCard(cardToPlay);
        }
    }
 public int GetCardPriority(Card card)
 {
     switch (card.Type)
     {
         case CardType.Nine:
             return 0;
         case CardType.Jack:
             return 0;
         case CardType.Queen:
             return 1;
         case CardType.King:
             return 1;
         case CardType.Ace:
             return 2;
         case CardType.Ten:
             return 2;
         default:
             return 0;
     }
 }
Beispiel #3
0
        public ResponseModel AddCard(CardModel cardModel)
        {
            var response = new ResponseModel();

            if (!cardModel.Valid())
            {
                return new ResponseModel("Add card model is not valid.");
            }

            User user = _db.Get<User>(cardModel.UserId);

            Card card = new Card();
            card.Title = cardModel.Title;
            card.Description = cardModel.Description;
            card.PeopleCount = cardModel.PeopleCount;
            card.Language = cardModel.Language;
            card._User = new User()
            {
                ID = user.ID,
                FirstName = user.FirstName,
                LastName = user.LastName
            };

            card.Location = new LocationModel()
            {
                Country = cardModel.Country,
                City = cardModel.City
            };

            card.History = new List<History>();
            History history = _history.GetCardHistory(user, CardHistoryType.NewCardAdded);
            card.History.Add(history);

            _db.Add(card);

            return response;
        }
        public Card CheckForAnounce(CardSuit trumpSuit, int cardsLeftInDeck, string state, ICollection<Card> playerCards)
        {
            if (state == GameStates.StartRoundState)
            {
                return null;
            }

            IList<Card> announcePairs = new List<Card>();

            foreach (var card in playerCards)
            {
                if (card.Type == CardType.King || card.Type == CardType.Queen)
                {
                    var otherTypeForAnnounce = card.Type == CardType.King ? CardType.Queen : CardType.King;
                    var otherCardForAnnounce = new Card(card.Suit, otherTypeForAnnounce);

                    if (this.cardHolder.AllCards[card.Suit][otherTypeForAnnounce] == CardStatus.InStalker)
                    {
                        announcePairs.Add(card);
                        announcePairs.Add(otherCardForAnnounce);
                    }
                }
            }

            if (announcePairs.Count == 0)
            {
                return null;
            }

            // Check if it's forty.
            if (announcePairs.Any(c => c.Suit == trumpSuit))
            {
                CardStatus cardStatusForTen = this.cardHolder.AllCards[trumpSuit][CardType.Ten];
                CardStatus cardStatusForAce = this.cardHolder.AllCards[trumpSuit][CardType.Ace];

                if ((cardStatusForTen == CardStatus.Passed || cardStatusForTen == CardStatus.InStalker) &&
                        (cardStatusForAce == CardStatus.Passed || cardStatusForAce == CardStatus.InStalker))
                {
                    return new Card(trumpSuit, CardType.King);
                }

                return new Card(trumpSuit, CardType.Queen);
            }

            var cardToReturn = new Card(announcePairs[0].Suit, announcePairs[0].Type);

            // They will be ordered in this way: [Q♦ K♦; K♠ Q♠; К♣ Q♣] by pairs: two diamonds, two clubs e.t.c. so incrementation will be i+=2.
            for (int i = 0; i < announcePairs.Count; i += 2)
            {
                var currentSuit = announcePairs[i].Suit;
                var cardStatusForTen = this.cardHolder.AllCards[currentSuit][CardType.Ten];
                var cardStatusForAce = this.cardHolder.AllCards[currentSuit][CardType.Ace];

                // Return bigger if 10 and A of current Suit is passed or is in us.
                if ((cardStatusForTen == CardStatus.Passed || cardStatusForTen == CardStatus.InStalker) &&
                    (cardStatusForAce == CardStatus.Passed || cardStatusForAce == CardStatus.InStalker))
                {
                    return new Card(currentSuit, CardType.King);
                }

                cardToReturn = new Card(currentSuit, CardType.Queen);
            }

            return cardToReturn;
        }
 public bool ContainsLowerCardThan(Card card, CardStatus status)
 {
     return this.cardHolder.AllCards[card.Suit].Any(c => c.Value == status && new Card(card.Suit, c.Key).GetValue() < card.GetValue());
 }
Beispiel #6
0
 private History GetCompleteHistory(Card card)
 {
     return _history.GetCardHistory(card._User, CardHistoryType.CardCompleted);
 }
Beispiel #7
0
        private UserCardState GetUserCardState(Card card, string userId)
        {
            if (string.IsNullOrEmpty(userId))
                return UserCardState.NoAuth;
            else if (card._User.IDInternal == userId)
                return UserCardState.Owner;

            var subscribers = card.Subscribers;
            if (subscribers == null)
                return UserCardState.NeverSubscribed;

            var subscriber = subscribers.SingleOrDefault(x => x.IDInternal == userId);
            if (subscriber == null)
                return UserCardState.NeverSubscribed;
            else if (subscriber.IsUnsubscribed)
                return UserCardState.Unsubscribed;
            else
                return UserCardState.Subscribed;
        }
Beispiel #8
0
 public ABnoteSAM(Card card)
     : base(card)
 {
 }
Beispiel #9
0
 void AddCard(Card card)
 {
     _cards.Add(card);
 }
Beispiel #10
0
 public void EndPlayCard(Common.Card cardToPlay)
 {
     base.PlayCard(cardToPlay);
 }
Beispiel #11
0
 public override void PlayCard(Common.Card cardToPlay)
 {
     PlayedCardsController.PlayCard(cardToPlay, UIPlayer.GetRelativePlayerSeat(GetPlayersSeat()), this);
 }
 public override void EndPlayCard(Common.Card cardToPlay)
 {
     base.EndPlayCard(cardToPlay);
 }