//public Dictionary<string, int> PlayerIds;

        #endregion

        #region Player

#pragma warning disable 4014
        public async Task <bool> PlayerDraw(string cardId)
        {
            if (string.IsNullOrEmpty(_playingAs))
            {
                //Make sure the value get's cached as early as possible to avoid problems
                //at the end of a game, in case the hero changes - e.g. to Jaraxxus.
                PlayingAs.GetType();
            }
            PlayerHandCount++;

            if (string.IsNullOrEmpty(cardId))
            {
                return(true);
            }

            var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId);

            if (drawnCard != null)
            {
                drawnCard.Count++;
            }
            else
            {
                drawnCard = GetCardFromId(cardId);
                PlayerDrawn.Add(drawnCard);
                PlayerDrawnIdsTotal.Add(cardId);
            }
            drawnCard.InHandCount++;
            drawnCard.JustDrawn();


            var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0 && c.IsStolen)
                           ?? PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0);

            if (deckCard == null)
            {
                return(false);
            }

            deckCard.Count--;
            deckCard.InHandCount++;
            LogDeckChange(false, deckCard, true);
            if (deckCard.Count == 0 && Config.Instance.RemoveCardsFromDeck && !Config.Instance.HighlightCardsInHand)
            {
                //wait for just-drawn highlight to be over, then doublecheck (coule be back in deck after e.g.) -> remove
                await deckCard.JustDrawn();

                if (deckCard.Count == 0)
                {
                    PlayerDeck.Remove(deckCard);
                    Logger.WriteLine("Removed " + deckCard.Name + " from deck (count 0)", "Game");
                }
            }
            else
            {
                deckCard.JustDrawn();
            }

            return(true);
        }
Exemple #2
0
        //public Dictionary<string, int> PlayerIds;

        #endregion

        #region Player

#pragma warning disable 4014
        public async Task <bool> PlayerDraw(string cardId)
        {
            PlayerHandCount++;

            if (string.IsNullOrEmpty(cardId))
            {
                return(true);
            }

            var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId);

            if (drawnCard != null)
            {
                drawnCard.Count++;
            }
            else
            {
                drawnCard = GetCardFromId(cardId);
                PlayerDrawn.Add(drawnCard);
                PlayerDrawnIdsTotal.Add(cardId);
            }
            drawnCard.InHandCount++;
            drawnCard.JustDrawn();


            var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0 && c.IsStolen)
                           ?? PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0);

            if (deckCard == null)
            {
                return(false);
            }

            deckCard.Count--;
            deckCard.InHandCount++;
            LogDeckChange(false, deckCard, true);
            if (deckCard.Count == 0 && Config.Instance.RemoveCardsFromDeck && !Config.Instance.HighlightCardsInHand)
            {
                //wait for just-drawn highlight to be over, then doublecheck (coule be back in deck after e.g.) -> remove
                await deckCard.JustDrawn();

                if (deckCard.Count == 0)
                {
                    PlayerDeck.Remove(deckCard);
                    Logger.WriteLine("Removed " + deckCard.Name + " from deck (count 0)", "Game");
                }
            }
            else
            {
                deckCard.JustDrawn();
            }

            return(true);
        }
Exemple #3
0
        public bool PlayerDeckDiscard(string cardId)
        {
            if (string.IsNullOrEmpty(cardId))
            {
                return(true);
            }

            var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId);

            if (drawnCard == null)
            {
                PlayerDrawn.Add(GetCardFromId(cardId));
                PlayerDrawnIdsTotal.Add(cardId);
            }
            else
            {
                drawnCard.Count++;
            }

            var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0 && c.IsStolen)
                           ?? PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0);

            if (deckCard == null)
            {
                return(false);
            }

            deckCard.Count--;
            LogDeckChange(false, deckCard, true);
            if (CanRemoveCard(deckCard))
            {
                PlayerDeck.Remove(deckCard);
            }

            return(true);
        }