Пример #1
0
        /// <summary>
        /// Updates the player cards With the given cards
        /// </summary>
        /// <param name="wrapper">The player to update</param>
        /// <param name="cards">The player new cards</param>
        protected override void UpdatePlayerCards(GuiPlayerWrapper wrapper, IEnumerable <Card> cards)
        {
            // clear old cards
            wrapper.Cards.Clear();
            if (cards != null)
            {
                // try getting the player hand
                Hand hand = Client.GetBestHand(cards);
                if (hand != null)
                {
                    // found a hand, upadte the player
                    wrapper.CurrentHand = hand;
                }

                // create a wrapper and add it to the cards collection. Add the cards in a sorted order.
                foreach (Card card in cards.OrderBy((c) => c.CardValue))
                {
                    CardWrapper addition = new CardWrapper(card);
                    wrapper.Cards.Add(addition);
                    if (hand != null && hand.Contains(card))
                    {
                        addition.IsSelected = true;
                    }
                }
            }
        }
        public void AddCardToList(CardWrapper card)
        {
            bool existsInOtherZone = false;

            // Check if card is in any other zone, if so do not add it
            for (int i = 0; i < this.CardsCompare.Count(); ++i)
            {
                if(i != (int)this.ZoneList && i != (int)GameCards.Zones.HAND)
                {
                    List<CardWrapper> cards = this.CardsCompare[i];
                    if (cards.FirstOrDefault(c => c.Id == card.Id) != null)
                    {
                        existsInOtherZone = true;
                        break;
                    }
                }
            }

            CardWrapper inPlayInZonePosCard = this.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos);
            if(inPlayInZonePosCard != null && this.ZoneList == GameCards.Zones.PLAY)
            {
                this.CardsInList.Remove(inPlayInZonePosCard);
            }

            if(existsInOtherZone == false)
            {
                // Check if it exists in our hand
                CardWrapper inHandCard = this.CardsInList.FirstOrDefault(c => c.Id == card.Id);
                if(inHandCard != null)
                {
                    this.CardsInList.Remove(inHandCard);
                }
                this.CardsInList.Add(card);
            }
        }
Пример #3
0
        private void RemoveDuplicateIds()
        {
            foreach (List <CardWrapper> cards in this.PlayerZonedCards)
            {
                List <CardWrapper> toRemove = new List <CardWrapper>();
                for (int i = cards.Count - 1; i >= 0; --i)
                {
                    CardWrapper card = cards[i];

                    if (toRemove.Contains(card))
                    {
                        continue; // Already removing this guy, ignore
                    }

                    CardWrapper duplicate = cards.FirstOrDefault(c => c.Id == card.Id && c != card);

                    if (duplicate != null)
                    {
                        toRemove.Add(card);
                    }
                }
                foreach (CardWrapper card in toRemove)
                {
                    cards.Remove(card);
                }
            }
        }
Пример #4
0
        public void OnCardDrag(CardWrapper PlayerCard, PointerEventData eventData)
        {
            if (!IsActive)
            {
                return;
            }

            CardsControlStrategy.OnCardDrag(PlayerCard, eventData);
        }
Пример #5
0
        public CardVM(IEventAggregator eventAggregator, CardWrapper card)
        {
            _eventAggregator = eventAggregator;

            Card = card;

            AddCardCommand    = new DelegateCommand(OnAddCard, OnAddCanExecute);
            RemoveCardCommand = new DelegateCommand(OnRemoveCard, OnRemoveCanExecute);
        }
Пример #6
0
        //Ger en lista med motsvarande kort från en lista med kortnamn
        public List <CardWrapper> GetCardsByNames(IEnumerable <string> cardNames)
        {
            List <CardWrapper> returnDeck = new List <CardWrapper>();

            foreach (string name in cardNames)
            {
                CardWrapper card = Cards.Single(c => c.Name == name);
                returnDeck.Add(card);
            }
            return(returnDeck);
        }
        public override void OnCardPointerUp(CardWrapper PlayerCard, PointerEventData eventData)
        {
            AlliedCharacterTimelineView alliedTimeline = BoardCached.AlliedTimeline;

            if (!alliedTimeline.IsPositionInsideBounds(eventData.pointerCurrentRaycast.worldPosition) ||
                !alliedTimeline.TryInsertVisibleCard(PlayerCard))
            {
                alliedTimeline.DestroyInvisibleCard();
                HandCached.AddCard(PlayerCard);
            }
        }
Пример #8
0
        private void OnOpenSelectionClick(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_selectionWindow == null)
            {
                List <DataGridCardItem> lstSelection = m_account.AccountPreferences.CardSelection.ConvertAll(c =>
                {
                    CardWrapper wrapper = new CardWrapper(new HearthMirror.Objects.Card(c.Id, c.Count, c.IsGolden));

                    return(DataGridCardItem.FromCardWrapper(wrapper));
                });

                m_selectionWindow = new CardSelectionWindow(lstSelection)
                {
                    Owner = this
                };

                m_selectionWindow.Closed += (s, args) =>
                {
                    m_account.AccountPreferences.CardSelection.Clear();

                    if (m_selectionWindow.SaveSelection)
                    {
                        m_account.AccountPreferences.CardSelection = m_selectionWindow.CurrentItems.ConvertAll(i =>
                        {
                            return(new CachedCard
                            {
                                Id = i.Tag.Card.Id,
                                Count = i.Tag.Card.Count,
                                IsGolden = i.Tag.Card.Premium
                            });
                        });

                        m_account.SavePreferenes();
                    }
                    else
                    {
                    }

                    openSelectionButton.IsEnabled = true;

                    m_selectionWindow = null;
                };

                m_selectionWindow.Show();

                openSelectionButton.IsEnabled = false;
            }
            else
            {
                DustUtilityPlugin.BringWindowToFront(m_selectionWindow);
            }
        }
        private SearchResultContainer CreateSearchResult(CardWrapper[] vCards)
        {
            SearchResultContainer retVal = new SearchResultContainer();

            Log.WriteLine("Creating search result...", LogType.Debug);

            DataGridCardItem[] vItems = new DataGridCardItem[vCards.Length];

            for (int i = 0; i < vCards.Length; i++)
            {
                CardWrapper wrapper = vCards[i];

                switch (wrapper.DbCard.Rarity)
                {
                case HearthDb.Enums.Rarity.COMMON:
                    retVal.CommonsCount += wrapper.Count;
                    break;

                case HearthDb.Enums.Rarity.RARE:
                    retVal.RaresCount += wrapper.Count;
                    break;

                case HearthDb.Enums.Rarity.EPIC:
                    retVal.EpicsCount += wrapper.Count;
                    break;

                case HearthDb.Enums.Rarity.LEGENDARY:
                    retVal.LegendariesCount += wrapper.Count;
                    break;
                }

                DataGridCardItem item = DataGridCardItem.FromCardWrapper(wrapper);

                retVal.TotalCount += item.Count;
                retVal.Dust       += item.Dust;

                vItems[i] = item;
            }

            //Sort
            vItems = OrderItems(vItems).ToArray();

            for (int i = 0; i < vItems.Length; i++)
            {
                retVal.GridItems.Add(vItems[i]);
            }

            return(retVal);
        }
        public override void OnCardDrag(CardWrapper PlayerCard, PointerEventData eventData)
        {
            PlayerCard.WorldCenterPosition = eventData.pointerCurrentRaycast.worldPosition;

            AlliedCharacterTimelineView alliedTimeline = BoardCached.AlliedTimeline;

            if (alliedTimeline.IsPositionInsideBounds(eventData.pointerCurrentRaycast.worldPosition))
            {
                alliedTimeline.TryInsertInvisibleCard(PlayerCard);
            }
            else
            {
                alliedTimeline.RemoveInvisibleCard();
            }
        }
Пример #11
0
 public static GridItem FromCardWrapper(CardWrapper wrapper)
 {
     return(new GridItem()
     {
         Count = wrapper.Count,
         Dust = wrapper.GetDustValue(),
         Golden = wrapper.Card.Premium,
         Name = wrapper.DbCard.Name,
         Rarity = wrapper.DbCard.Rarity,
         RarityString = wrapper.DbCard.Rarity.GetString(),
         CardClass = wrapper.DbCard.Class.GetString(),
         CardSet = wrapper.DbCard.Set.GetString(),
         ManaCost = wrapper.DbCard.Cost,
         Tag = wrapper
     });;
 }
Пример #12
0
        protected override Card Parse(IDataRecord record)
        {
            var id      = record.ToInt("Id");
            var typeId  = record.ToInt("CardTypeId");
            var imageId = record.ToNullableInt("PrimaryImageId");

            var card = new CardWrapper(CardTypeDataAccess, ImageDataAccess, HardLinkDataAccess, PropertyDataAccess, id, typeId, imageId);

            card.Id          = id;
            card.Title       = record.ToString("Title");
            card.Subtitle    = record.ToString("Subtitle");
            card.Description = record.ToString("Description");
            card.RawText     = record.ToString("RawText");

            return(card);
        }
Пример #13
0
        public override void OnCardPointerDown(CardWrapper PlayerCard, PointerEventData eventData)
        {
            PlayerCard.DOStop();

            PlayerCard.SetParent(HandCached.transform.parent);

            if (PlayerCard.State == CardState.Hand)
            {
                HandCached.RemoveCard(PlayerCard);
                DiscardSectionCached.AddCard(PlayerCard);
            }
            else if (PlayerCard.State == CardState.Discard)
            {
                DiscardSectionCached.RemoveCard(PlayerCard);
                HandCached.AddCard(PlayerCard);
            }
        }
Пример #14
0
        private void OnAddCard()
        {
            CardWrapper card = new CardWrapper(new Card());

            card.Name            = CardName;
            card.ImageURL        = CardImage;
            card.Side            = CardSide;
            card.Set             = CardSet.Name;
            card.MaxNumberOfUses = (int)CardNumberOfUses;
            _cardService.AddCardToDB(card);
            CardName         = "";
            CardImage        = "";
            CardSide         = null;
            CardSet          = null;
            CardNumberOfUses = null;
            Cards.Add(card);
            ((DelegateCommand)AddCardCommand).RaiseCanExecuteChanged();
        }
Пример #15
0
        private void DrawCards(List <Skill> DrawnSkills)
        {
            List <CardWrapper> cards = new List <CardWrapper>();

            foreach (Skill skill in DrawnSkills)
            {
                CardWrapper cardWrapper = MonoBehaviour.Instantiate(BattlePrefabsConfig.Get().CardWrapperPrefab);
                cardWrapper.WorldPosition = new Vector2(20, 2);
                cardWrapper.SetState(CardState.Hand, skill);

                cardWrapper.OnPointerDownEvent += OnCardPointerDown;
                cardWrapper.OnPointerUpEvent   += OnCardPointerUp;
                cardWrapper.OnDragEvent        += OnCardDrag;

                cards.Add(cardWrapper);
            }

            HandCached.StartCoroutine(DrawCardsCoroutine(cards, GameInstance.Get().DelayBetweenCardAnimationsInSeconds));
        }
Пример #16
0
        private void OnImportPackClick(object sender, RoutedEventArgs e)
        {
            List <HearthMirror.Objects.Card> lstLatestPack = Reflection.GetPackCards();

            if (lstLatestPack?.Count > 0)
            {
                for (int i = 0; i < lstLatestPack.Count; i++)
                {
                    CardWrapper wrapper = new CardWrapper(lstLatestPack[i]);

                    DataGridCardItem item = DataGridCardItem.FromCardWrapper(wrapper);

                    AddItem(item);
                }
            }
            else
            {
            }
        }
Пример #17
0
        public CardService(IEventAggregator eventAggregator, ICardRepo repo) : base(eventAggregator)
        {
            _repo             = repo;
            _cardsWithNumbers = new List <CardWrapper>();

            _eventAggregator.GetEvent <AddCardEvent>().Subscribe(OnAddCard);
            _eventAggregator.GetEvent <RemoveCardEvent>().Subscribe(OnRemoveCard);

            Cards = new List <CardWrapper>();
            foreach (Card DBcard in _repo.GetCards())
            {
                CardWrapper card = new CardWrapper(DBcard);
                card.NumberOfUses = card.MaxNumberOfUses;
                Cards.Add(card);
                for (int j = 0; j < card.MaxNumberOfUses; j++)
                {
                    _cardsWithNumbers.Add(card);
                }
            }
        }
        public override void OnCardPointerDown(CardWrapper PlayerCard, PointerEventData eventData)
        {
            PlayerCard.DOStop();

            PlayerCard.SetParent(HandCached.transform.parent);
            PlayerCard.AnchoredPosition = eventData.position - PlayerCard.Size / 2;

            AlliedCharacterTimelineView alliedTimeline = BoardCached.AlliedTimeline;

            alliedTimeline.CreateInvisibleCard(PlayerCard);

            if (PlayerCard.State == CardState.Hand)
            {
                HandCached.RemoveCard(PlayerCard);
            }
            else if (PlayerCard.State == CardState.BoardPrePlay)
            {
                alliedTimeline.RemoveCard(PlayerCard);
                alliedTimeline.TryInsertInvisibleCard(PlayerCard);
            }
        }
Пример #19
0
        //Slumpar fram de olika "händer" som ska användas under draften
        private ObservableCollection <CardWrapper>[][] GetDraftDecks()
        {
            ObservableCollection <CardWrapper>[][] decks = new ObservableCollection <CardWrapper> [NumberOfRounds][];

            for (int i = 0; i < NumberOfRounds; i++)
            {
                decks[i] = new ObservableCollection <CardWrapper> [NumberOfPlayers];
                for (int j = 0; j < NumberOfPlayers; j++)
                {
                    decks[i][j] = new ObservableCollection <CardWrapper>();
                    for (int k = 0; k < NumberOfCards; k++)
                    {
                        CardWrapper card = CardList[_rnd.Next(0, CardList.Count)];
                        decks[i][j].Add(card);
                        CardList.Remove(card);
                    }
                }
            }

            return(decks);
        }
Пример #20
0
        private void AddCardToZone(Zones zone, CardWrapper card, bool removeDuplicates = true)
        {
            if(card.Id == 4)
            {
                this.PlayerHero = card;
            }
            else if(card.Id == 36)
            {
                this.OpponentHero = card;
            }
            else if(card.ZonePos != 0 || card.Zone == "GRAVEYARD" || card.Zone == "SETASIDE")
            {
                if (card.Id <= 35 || card.Name == "The Coin")
                {
                    //CardWrapper existing = this.PlayerZonedCards[(int)zone].FirstOrDefault(c => c.ZonePos == card.ZonePos);
                    //if (existing != null && zone != Zones.HAND)
                    //{
                    //    this.PlayerZonedCards[(int)zone].Remove(existing);
                    //}
                    this.PlayerZonedCards[(int)zone].Add(card);
                }
                else
                {
                    //CardWrapper existing = this.OpponentZonedCards[(int)zone].FirstOrDefault(c => c.ZonePos == card.ZonePos);
                    //if (existing != null)
                    //{
                    //    this.OpponentZonedCards[(int)zone].Remove(existing);
                    //}
                    this.OpponentZonedCards[(int)zone].Add(card);
                }
            }

            //if (removeDuplicates)
            //{
            //    this.RemoveDuplicateIds();
            //}
        }
Пример #21
0
        private void AddCardToZone(Zones zone, CardWrapper card, bool removeDuplicates = true)
        {
            if (card.Id == 4)
            {
                this.PlayerHero = card;
            }
            else if (card.Id == 36)
            {
                this.OpponentHero = card;
            }
            else if (card.ZonePos != 0 || card.Zone == "GRAVEYARD" || card.Zone == "SETASIDE")
            {
                if (card.Id <= 35 || card.Name == "The Coin")
                {
                    //CardWrapper existing = this.PlayerZonedCards[(int)zone].FirstOrDefault(c => c.ZonePos == card.ZonePos);
                    //if (existing != null && zone != Zones.HAND)
                    //{
                    //    this.PlayerZonedCards[(int)zone].Remove(existing);
                    //}
                    this.PlayerZonedCards[(int)zone].Add(card);
                }
                else
                {
                    //CardWrapper existing = this.OpponentZonedCards[(int)zone].FirstOrDefault(c => c.ZonePos == card.ZonePos);
                    //if (existing != null)
                    //{
                    //    this.OpponentZonedCards[(int)zone].Remove(existing);
                    //}
                    this.OpponentZonedCards[(int)zone].Add(card);
                }
            }

            //if (removeDuplicates)
            //{
            //    this.RemoveDuplicateIds();
            //}
        }
        public void AddCardToList(CardWrapper card)
        {
            bool existsInOtherZone = false;

            // Check if card is in any other zone, if so do not add it
            for (int i = 0; i < this.CardsCompare.Count(); ++i)
            {
                if (i != (int)this.ZoneList && i != (int)GameCards.Zones.HAND)
                {
                    List <CardWrapper> cards = this.CardsCompare[i];
                    if (cards.FirstOrDefault(c => c.Id == card.Id) != null)
                    {
                        existsInOtherZone = true;
                        break;
                    }
                }
            }

            CardWrapper inPlayInZonePosCard = this.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos);

            if (inPlayInZonePosCard != null && this.ZoneList == GameCards.Zones.PLAY)
            {
                this.CardsInList.Remove(inPlayInZonePosCard);
            }

            if (existsInOtherZone == false)
            {
                // Check if it exists in our hand
                CardWrapper inHandCard = this.CardsInList.FirstOrDefault(c => c.Id == card.Id);
                if (inHandCard != null)
                {
                    this.CardsInList.Remove(inHandCard);
                }
                this.CardsInList.Add(card);
            }
        }
        private static void SetRowPopupCardIdCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (Settings.CardImageTooltip && d is DataGridRow)
            {
                CardWrapper cardWrapper = e.NewValue as CardWrapper;

                if (cardWrapper != null)
                {
                    Log.WriteLine($"Setting new card id for popup: Id={cardWrapper.Card.Id} Premium={cardWrapper.Card.Premium}", LogType.Debug);
                }
                else
                {
                }

                Popup popup = GetRowPopup(d);

                CardImageContainer container = popup.Child as CardImageContainer;

                container.CardWrapper = cardWrapper;
            }
            else
            {
            }

            //if (s_container != null)
            //{
            //    s_container.CardWrapper = e.NewValue as CardWrapper;

            //    if (e.NewValue != null)
            //    {
            //        Log.WriteLine($"Setting new card id for popup: Id={s_container.CardWrapper.Card.Id}", LogType.Debug);
            //    }
            //    else { }
            //}
            //else { }
        }
Пример #24
0
        public void Update()
        {
            List <CardWrapper> cards = searcher.GetCardList();

            this.unfiltered = cards;
            this.Cards      = new GameCards();
            this.Cards.Init(cards);

            // No cards, must be idle
            if (this.Cards.PlayerHero == null)
            {
                this.State = GameState.Idle;
                return;
            }
            else if (this.State == GameState.Idle)
            {
                this.State = GameState.Mulliganing;
            }

            // We make assummptions that we are in the idle start when the app starts
            if (this.State == GameState.NotInitialized)
            {
                throw new Exception("Start Hearthstone-Bot before entering a game!");
            }

            // Game has started, we go from idle state into mulligan state
            // Leave mulligan state once the number of cards in our hand has increased

            if (this.State == GameState.Mulliganing)
            {
                // We drew a card so we aren't in mulligan phase anymore
                if (this.lastTurnHand != null && this.lastTurnHand.Count < this.Cards.PlayerHand.CardsInList.Count)
                {
                    this.State   = GameState.MyTurn;
                    this.MaxMana = 1;
                    this.Mana    = 1;
                }

                this.lastTurnHand = this.Cards.PlayerHand.CardsInList;
            }

            if (this.State == GameState.OpponentTurn)
            {
                bool sameCards = true;
                for (int i = 0; i < this.lastTurnHand.Count && i < this.Cards.PlayerHand.CardsInList.Count; ++i)
                {
                    CardWrapper handCard = this.Cards.PlayerHand.CardsInList[i];
                    if (this.lastTurnHand.FirstOrDefault(c => c.Id == handCard.Id) == null)
                    {
                        sameCards = false;
                        break;
                    }
                }

                if (this.lastTurnHand.Count < this.Cards.PlayerHand.CardsInList.Count || sameCards == false)
                {
                    // Explain WHY it became my turn because I am very confused
                    FileLogger.Global.LogLine("Switching turns");
                    FileLogger.Global.LogLine("------------");
                    FileLogger.Global.LogLine("LastTurnHand");
                    FileLogger.Global.LogLine("------------");
                    foreach (CardWrapper card in this.lastTurnHand)
                    {
                        FileLogger.Global.LogLine(String.Format("{0} | {1}", card.Name, card.Id));
                    }
                    FileLogger.Global.LogLine("------------");
                    FileLogger.Global.LogLine("PlayerHand");
                    FileLogger.Global.LogLine("------------");
                    foreach (CardWrapper card in this.Cards.PlayerHand.CardsInList)
                    {
                        FileLogger.Global.LogLine(String.Format("{0} | {1}", card.Name, card.Id));
                    }
                    FileLogger.Global.LogLine(String.Empty);
                    FileLogger.Global.LogLine(String.Empty);
                    FileLogger.Global.LogLine(String.Empty);

                    this.State = GameState.MyTurn;
                    this.MaxMana++;
                    this.Mana = this.MaxMana;
                }
            }
        }
Пример #25
0
 public override void OnCardDrag(CardWrapper PlayerCard, PointerEventData eventData)
 {
 }
Пример #26
0
 public abstract void OnCardDrag(CardWrapper PlayerCard, PointerEventData eventData);
Пример #27
0
 public void AddCardToDB(CardWrapper card)
 {
     _repo.AddCard(card.Model);
 }
Пример #28
0
        public void Update()
        {
            Process[] procs = Process.GetProcessesByName("Hearthstone");

            if (procs.Count() > 0)
            {
                Process hsProc = procs[0];

                WindowFocusing.ActivateWindow(hsProc.MainWindowHandle);

                GetWindowRect(hsProc.MainWindowHandle, ref this.GameRect);
            }

            // Click some stuff
            if (PlayTracker.Global.State == PlayTracker.GameState.Mulliganing && PassedMulligan == false)
            {
                Thread.Sleep(15000);

                this.PassMulligan();
                this.PassedMulligan = true;
            }
            else if (PlayTracker.Global.State == PlayTracker.GameState.MyTurn)
            {
                Thread.Sleep(7000);

                int manaToSpend = PlayTracker.Global.Mana;

                // Coin first
                CardWrapper coinCard = PlayTracker.Global.Cards.PlayerHand.CardsInList.FirstOrDefault(c => c.Name == "The Coin");
                if (coinCard != null)
                {
                    this.PlayCard(PlayTracker.Global.Cards.PlayerHand.CardsInList.IndexOf(coinCard));
                    PlayTracker.Global.Update();
                    Program.UpdateDisplay();

                    manaToSpend++;
                    PlayTracker.Global.Mana = manaToSpend;

                    // Attempt to mark the memory so we don't find this 'dead' card again
                    //HearthstoneMemorySearchWrapper.MarkMemory(coinCard);
                }

                // Try to play everything? lolz
                Program.PlayedThisTurn = new List <int>();
                List <CardWrapper> triedToPlay = new List <CardWrapper>();
                while (true)
                {
                    int         mostExpensiveToCast = 0;
                    int         idMostExpensive     = -1;
                    JsonCard    jCardMostExpensive  = null;
                    CardWrapper cardMostExpensive   = null;

                    for (int i = 0; i < PlayTracker.Global.Cards.PlayerHand.CardsInList.Count; ++i)
                    {
                        CardWrapper card  = PlayTracker.Global.Cards.PlayerHand.CardsInList[i];
                        JsonCard    jCard = Program.Cards.GetCardFromCardId(card.CardId);
                        if (jCard.cost <= manaToSpend)
                        {
                            if (jCard.cost > mostExpensiveToCast && triedToPlay.FirstOrDefault(c => c.Id == card.Id) == null)
                            {
                                mostExpensiveToCast = jCard.cost;
                                idMostExpensive     = i;
                                jCardMostExpensive  = jCard;
                                cardMostExpensive   = card;
                            }
                        }
                    }

                    // Play the most expensive card we can first
                    if (idMostExpensive != -1)
                    {
                        this.PlayCard(idMostExpensive);

                        Thread.Sleep(1000);

                        PlayTracker.Global.Update();
                        Program.UpdateDisplay();
                        CardWrapper toPlay = PlayTracker.Global.Cards.PlayerHand.CardsInList.FirstOrDefault(c => c.Id == cardMostExpensive.Id);
                        triedToPlay.Add(cardMostExpensive);
                        if (toPlay == null)
                        {
                            manaToSpend            -= jCardMostExpensive.cost;
                            PlayTracker.Global.Mana = manaToSpend;
                            Program.PlayedThisTurn.Add(cardMostExpensive.Id);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                PlayTracker.Global.Update();
                Program.UpdateDisplay();

                // Attack!
                for (int i = 0; i < PlayTracker.Global.Cards.PlayerPlay.CardsInList.Count; ++i)
                {
                    CardWrapper card  = PlayTracker.Global.Cards.PlayerPlay.CardsInList[i];
                    JsonCard    jCard = Program.Cards.GetCardFromCardId(card.CardId);

                    // If this minion was just played and doesn't have charge then skip it
                    if (Program.PlayedThisTurn.Contains(card.Id))
                    {
                        if (jCard.mechanics == null || jCard.mechanics.Contains("Charge") == false)
                        {
                            continue;
                        }
                    }

                    // Find a target
                    List <JsonCard> enemyCards = new List <JsonCard>();
                    for (int j = 0; j < PlayTracker.Global.Cards.OpponentPlay.CardsInList.Count; ++j)
                    {
                        CardWrapper enemyCard  = PlayTracker.Global.Cards.OpponentPlay.CardsInList[j];
                        JsonCard    jCardEnemy = Program.Cards.GetCardFromCardId(enemyCard.CardId);
                        if (jCardEnemy != null)
                        {
                            enemyCards.Add(jCardEnemy);
                        }
                    }

                    // Look for anyone with taunt that we have to attack
                    bool     didAttack  = false;
                    JsonCard tauntEnemy = enemyCards.FirstOrDefault(c => c != null && c.mechanics != null && c.mechanics.Contains("Taunt"));
                    if (tauntEnemy != null)
                    {
                        this.AttackMinion(i, enemyCards.IndexOf(tauntEnemy));
                        didAttack = true;
                    }
                    else if (enemyCards.Count > 0)
                    {
                        // Look for a value attack
                        // Attack a minion if I can kill it and not die
                        int j = 0;
                        foreach (JsonCard jCardEnemy in enemyCards)
                        {
                            if (jCard.attack >= jCardEnemy.health && jCard.health > jCardEnemy.attack)
                            {
                                this.AttackMinion(i, j);
                                didAttack = true;
                                break;
                            }
                            ++j;
                        }
                    }
                    if (didAttack == false)
                    {
                        // Attack hero
                        this.AttackHero(i);
                        didAttack = true;
                    }
                    PlayTracker.Global.Update();
                    Program.UpdateDisplay();
                }

                // Use hero power
                this.MoveClickWrapper(780, 640, ClickFlags.LongLeftClick);

                Thread.Sleep(1000);

                this.PassTurn();
            }
        }
Пример #29
0
 public void DeleteCardFromDB(CardWrapper card)
 {
     _repo.DeleteCard(card.Name);
 }