private void SelectCard(int creatureId, CardDirection direction)
        {
            if (!Hands.ContainsKey(creatureId))
            {
                return;
            }
            StreamlootsHand hand = Hands[creatureId];

            if (hand.Cards.Count == 0)
            {
                return;
            }

            if (!hand.IsShown)
            {
                hand.IsShown = true;
            }

            UpdateLastInteraction(creatureId);

            int selectedCardIndex = hand.GetSelectedCardIndex();

            if (selectedCardIndex == -1)
            {
                hand.SelectedCard = null;
                StreamlootsCard firstCard;
                if (direction == CardDirection.Next)
                {
                    firstCard = hand.Cards.First();
                    SelectFirstAvailableCard(hand);
                }
                else
                {
                    firstCard = hand.Cards.Last();
                    SelectLastAvailableCard(hand);
                }

                if (hand.SelectedCard == null)                  // Only secret cards in the hand.
                {
                    hand.SelectedCard = firstCard;
                }
            }
            else
            {
                if (direction == CardDirection.Next)
                {
                    selectedCardIndex = GetNextCardIndex(hand, selectedCardIndex);
                }
                else
                {
                    selectedCardIndex = SelectPreviousCardIndex(hand, selectedCardIndex);
                }

                hand.SelectedCard = hand.Cards[selectedCardIndex];
            }
            StateHasChanged();
        }
Example #2
0
        public void SelectPreviousCard(int creatureId)
        {
            if (!Hands.ContainsKey(creatureId))
            {
                return;
            }
            StreamlootsHand hand = Hands[creatureId];

            if (hand.Cards.Count == 0)
            {
                return;
            }

            int selectedCardIndex = hand.GetSelectedCardIndex();

            if (selectedCardIndex == -1)
            {
                hand.SelectedCard = null;
                for (int i = hand.Cards.Count - 1; i >= 0; i--)
                {
                    StreamlootsCard card = hand.Cards[i];
                    if (!card.IsSecret)
                    {
                        hand.SelectedCard = card;
                        break;
                    }
                }
                if (hand.SelectedCard == null)
                {
                    hand.SelectedCard = hand.Cards[hand.Cards.Count - 1];
                }
            }
            else
            {
                if (selectedCardIndex > 0)
                {
                    selectedCardIndex--;
                }
                else
                {
                    selectedCardIndex = hand.Count - 1;
                }
                hand.SelectedCard = hand.Cards[selectedCardIndex];
            }
            StateHasChanged();
        }
Example #3
0
        public void SelectNextCard(int creatureId)
        {
            if (!Hands.ContainsKey(creatureId))
            {
                return;
            }
            StreamlootsHand hand = Hands[creatureId];

            if (hand.Cards.Count == 0)
            {
                return;
            }

            int selectedCardIndex = hand.GetSelectedCardIndex();

            if (selectedCardIndex == -1)
            {
                hand.SelectedCard = null;
                foreach (StreamlootsCard card in hand.Cards)
                {
                    if (!card.IsSecret)
                    {
                        hand.SelectedCard = card;
                        break;
                    }
                }
                if (hand.SelectedCard == null)
                {
                    hand.SelectedCard = hand.Cards[0];
                }
            }
            else
            {
                if (selectedCardIndex < hand.Count - 1)
                {
                    selectedCardIndex++;
                }
                else
                {
                    selectedCardIndex = 0;
                }
                hand.SelectedCard = hand.Cards[selectedCardIndex];
            }
            StateHasChanged();
        }