Esempio n. 1
0
        private void getHandcards()
        {
            handCards.Clear();
            this.anzcards      = 0;
            this.enemyAnzCards = 0;
            List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            list.AddRange(HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.HAND));

            foreach (HRCard item in list)
            {
                HREntity entitiy = item.GetEntity();

                if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard
                {
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(entitiy.GetCardId());
                    //c.cost = entitiy.GetCost();
                    //c.entityID = entitiy.GetEntityId();

                    Handmanager.Handcard hc = new Handmanager.Handcard();
                    hc.card     = c;
                    hc.position = entitiy.GetZonePosition();
                    hc.entity   = entitiy.GetEntityId();
                    hc.manacost = entitiy.GetCost();
                    handCards.Add(hc);
                    this.anzcards++;
                }

                if (entitiy.GetControllerId() != this.ownPlayerController && entitiy.GetZonePosition() >= 1) // enemy handcard
                {
                    this.enemyAnzCards++;
                }
            }
        }
Esempio n. 2
0
        private List <HREntity> GetAllEntitiesOnBoard()
        {
            List <HREntity> ret = new List <HREntity>();

            HREntity HeroFriend = HRPlayer.GetLocalPlayer().GetHero();

            ret.Add(HeroFriend);

            HREntity HeroEnemy = HRPlayer.GetEnemyPlayer().GetHero();

            ret.Add(HeroEnemy);

            HREntity HeroAbility = HRPlayer.GetLocalPlayer().GetHeroPower();

            ret.Add(HeroAbility);

            foreach (HRCard c in HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.PLAY))
            {
                ret.Add(c.GetEntity());
            }
            foreach (HRCard c in HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.PLAY))
            {
                ret.Add(c.GetEntity());
            }
            return(ret);
        }
Esempio n. 3
0
        private List <HREntity> getallEntitys()
        {
            List <HREntity> result         = new List <HREntity>();
            HREntity        ownhero        = HRPlayer.GetLocalPlayer().GetHero();
            HREntity        enemyhero      = HRPlayer.GetEnemyPlayer().GetHero();
            HREntity        ownHeroAbility = HRPlayer.GetLocalPlayer().GetHeroPower();
            List <HRCard>   list2          = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.PLAY);
            List <HRCard>   list3          = HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.PLAY);

            result.Add(ownhero);
            result.Add(enemyhero);
            result.Add(ownHeroAbility);

            foreach (HRCard item in list2)
            {
                result.Add(item.GetEntity());
            }
            foreach (HRCard item in list3)
            {
                result.Add(item.GetEntity());
            }



            return(result);
        }
Esempio n. 4
0
        private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
        {
            HRLog.Write("handle mulligan");
            if (HRMulligan.IsMulliganActive())
            {
                var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

                foreach (var item in list)
                {
                    if (item.GetEntity().GetCost() >= 4)
                    {
                        HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4.");
                        HRMulligan.ToggleCard(item);
                    }
                    if (item.GetEntity().GetCardId() == "EX1_308" || item.GetEntity().GetCardId() == "EX1_622" || item.GetEntity().GetCardId() == "EX1_005")
                    {
                        HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it is soulfire or shadow word: death");
                        HRMulligan.ToggleCard(item);
                    }
                }

                sf.setnewLoggFile();
                return(null);
                //HRMulligan.EndMulligan();
            }
            return(null);
        }
Esempio n. 5
0
      protected override API.HRCard GetMinionByPriority(HRCard lastMinion)
      {
         var result = HRBattle.GetNextMinionByPriority(MinionPriority.LowestHealth);
         if (result != null && (lastMinion == null || lastMinion != null && lastMinion.GetEntity().GetCardId() != result.GetCardId()))
            return result.GetCard();

         return null;
      }
Esempio n. 6
0
        protected virtual ActionBase PlayCardsToField()
        {
            // Get all available cards...
            List <HRCard> availableCards =
                HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            if (availableCards.Count > 0)
            {
                HRCard coin = null;
                foreach (var item in availableCards)
                {
                    #region Skip The Coin
                    string cardID = item.GetEntity().GetCardId();
                    if (cardID == "GAME_005" || cardID == "GAME_005e")
                    {
                        coin = item;
                        continue;
                    }
                    #endregion

                    if (item.GetEntity().GetCost() <= HRPlayer.GetLocalPlayer().GetNumAvailableResources())
                    {
                        if (HRBattle.CanUseCard(item.GetEntity()) && HRCardManager.IsCardAllowedByRule(item))
                        {
                            return(new PlayCardAction(item));
                        }
                    }
                }

                #region The Coin Feature
                // Feature: The Coin
                // https://github.com/juce-mmocrawlerbots/HREngine/issues/13
                if (coin != null)
                {
                    foreach (var card in availableCards)
                    {
                        if (card.GetEntity().GetCardId() != coin.GetEntity().GetCardId())
                        {
                            if (card.GetEntity().IsMinion() || card.GetEntity().IsSpell() || (!HRPlayer.GetLocalPlayer().HasWeapon() && card.GetEntity().IsWeapon()))
                            {
                                if (card.GetEntity().GetCost() <= (HRPlayer.GetLocalPlayer().GetNumAvailableResources() + 1))
                                {
                                    HRLog.Write(
                                        String.Format("Spawn [{0}] and then [{1}]",
                                                      coin.GetEntity().GetName(), card.GetEntity().GetName()));

                                    NextFixedAction = new PlayCardAction(card);
                                    return(new PlayCardAction(coin));
                                }
                            }
                        }
                    }
                }
                #endregion
            }

            return(null);
        }
Esempio n. 7
0
        protected override API.HRCard GetMinionByPriority(HRCard lastMinion)
        {
            var result = HRBattle.GetNextMinionByPriority(MinionPriority.LowestHealth);

            if (result != null && (lastMinion == null || lastMinion != null && lastMinion.GetEntity().GetCardId() != result.GetCardId()))
            {
                return(result.GetCard());
            }

            return(null);
        }
Esempio n. 8
0
        private List <HREntity> GetMinionsOnField()
        {
            List <HREntity> result = new List <HREntity>();
            List <HRCard>   list   = HRCard.GetCards(Player, HRCardZone.PLAY);

            foreach (var item in list)
            {
                result.Add(item.GetEntity());
            }
            return(result);
        }
Esempio n. 9
0
        private List <HREntity> GetFriendEntitiesOnBoard()
        {
            List <HREntity> ret = new List <HREntity>();

            foreach (HRCard c in HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.PLAY))
            {
                ret.Add(c.GetEntity());
            }

            return(ret);
        }
Esempio n. 10
0
        private List <HREntity> GetTauntMinions()
        {
            List <HREntity> result = new List <HREntity>();
            List <HRCard>   list   = HRCard.GetCards(Player, HRCardZone.PLAY);

            foreach (var item in list)
            {
                if (item.GetEntity().HasTaunt())
                {
                    result.Add(item.GetEntity());
                }
            }
            return(result);
        }
Esempio n. 11
0
        private List <HREntity> GetAttackableMinions()
        {
            List <HREntity> result = new List <HREntity>();
            List <HRCard>   list   = HRCard.GetCards(Player, HRCardZone.PLAY);

            foreach (var item in list)
            {
                if (item.GetEntity().CanBeAttacked())
                {
                    result.Add(item.GetEntity());
                }
            }
            return(result);
        }
Esempio n. 12
0
        private void PerList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (perList.SelectedCells.Count > 0)
            {
                var cellInfo    = perList.SelectedCells[0];
                var selectedEmp = (EMP_LIST)(cellInfo.Column.GetCellContent(cellInfo.Item).DataContext);

                if (selectedEmp.ID > 0)
                {
                    HRCard hc = new HRCard();
                    hc.personID = selectedEmp.ID.ToString();
                    hc.ShowDialog();
                }
            }
        }
Esempio n. 13
0
 protected HREngine.API.Actions.ActionBase UpdateMulliganState()
 {
     if (HRMulligan.IsMulliganActive())
     {
         var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
         foreach (var item in list)
         {
             if (!RejectedCardList.ContainsKey(item.GetEntity().GetEntityId()) && item.GetEntity().GetCost() >= 4)
             {
                 RejectedCardList.Add(item.GetEntity().GetEntityId(), item);
                 return(new RejectCardsAction(item));
             }
         }
     }
     return(null);
 }
Esempio n. 14
0
      protected override HRCard GetMinionByPriority(HRCard lastMinion)
      {
         HREntity result = null;
         if (HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() <
            HRPlayer.GetLocalPlayer().GetNumFriendlyMinionsInPlay() ||
            HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() < 4)
         {
            result = HRBattle.GetNextMinionByPriority(MinionPriority.Hero);
         }
         else
            result = HRBattle.GetNextMinionByPriority(MinionPriority.LowestHealth);

         if (result != null && (lastMinion == null || lastMinion != null && lastMinion.GetEntity().GetCardId() != result.GetCardId()))
            return result.GetCard();

         return null;
      }
Esempio n. 15
0
        private bool CanHandleCard(
            HRCard item, PlayerState EnemyState, PlayerState LocalState, ref HREntity Target)
        {
            string cardID = item.GetEntity().GetCardId().ToUpper();

            switch (cardID)
            {
            case "CS2_122": // "Raid Leader"
                return(LocalState.Minions > 0);

            case "EX1_066": // "Acidic Swamp Ooze"
                return(EnemyState.Player.HasWeapon() || LocalState.Minions < EnemyState.Minions);

            default:
                break;
            }
            return(true);
        }
Esempio n. 16
0
        private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
        {
            SmartCc = new Simulation();


            SmartCc.CreateLogFolder();
            SmartCc.TurnCount = 0;

            if (HRMulligan.IsMulliganActive())
            {
                List <HRCard> Choices       = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
                List <Card>   ParsedChoices = new List <Card>();
                foreach (HRCard card in Choices)
                {
                    HREntity entity = card.GetEntity();
                    Card     c      = Card.Create(entity.GetCardId(), true, entity.GetEntityId());
                    c.CurrentCost = entity.GetCost();
                    ParsedChoices.Add(c);
                }

                List <HRCard> CardsToKeep = new List <HRCard>();
                foreach (Card c in ProfileInterface.Behavior.HandleMulligan(ParsedChoices))
                {
                    foreach (HRCard card in Choices)
                    {
                        if (c.Id == card.GetEntity().GetEntityId())
                        {
                            CardsToKeep.Add(card);
                        }
                    }
                }

                foreach (HRCard card in Choices)
                {
                    if (!CardsToKeep.Contains(card))
                    {
                        HRMulligan.ToggleCard(card);
                    }
                }
                return(null);
            }
            return(null);
        }
Esempio n. 17
0
        private void getHandcards()
        {
            handCards.Clear();
            this.anzcards      = 0;
            this.enemyAnzCards = 0;
            List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            foreach (HRCard item in list)
            {
                HREntity entitiy = item.GetEntity();

                if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard
                {
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.GetCardId()));
                    //c.cost = entitiy.GetCost();
                    //c.entityID = entitiy.GetEntityId();

                    Handmanager.Handcard hc = new Handmanager.Handcard();
                    hc.card      = c;
                    hc.position  = entitiy.GetZonePosition();
                    hc.entity    = entitiy.GetEntityId();
                    hc.manacost  = entitiy.GetCost();
                    hc.addattack = 0;
                    if (c.name == CardDB.cardName.bolvarfordragon)
                    {
                        hc.addattack = entitiy.GetATK() - 1; // -1 because it starts with 1, we count only the additional attackvalue
                    }
                    handCards.Add(hc);
                    this.anzcards++;
                }
                //maybe check if it has BRM_028e on it?
            }

            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetControllerId() != this.ownPlayerController && ent.GetZonePosition() >= 1 && ent.GetZone() == HRCardZone.HAND) // enemy handcard
                {
                    this.enemyAnzCards++;
                }
            }
        }
Esempio n. 18
0
        private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
        {
            HRLog.Write("handle mulligan");
            if (HRMulligan.IsMulliganActive())
            {
                var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

                foreach (var item in list)
                {
                    if (item.GetEntity().GetCost() >= 4)
                    {
                        HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4.");
                        HRMulligan.ToggleCard(item);
                    }
                }

                return(null);
                //HRMulligan.EndMulligan();
            }
            return(null);
        }
Esempio n. 19
0
        protected override HRCard GetMinionByPriority(HRCard lastMinion)
        {
            HREntity result = null;

            if (HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() <
                HRPlayer.GetLocalPlayer().GetNumFriendlyMinionsInPlay() ||
                HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() < 4)
            {
                result = HRBattle.GetNextMinionByPriority(MinionPriority.Hero);
            }
            else
            {
                result = HRBattle.GetNextMinionByPriority(MinionPriority.LowestHealth);
            }

            if (result != null && (lastMinion == null || lastMinion != null && lastMinion.GetEntity().GetCardId() != result.GetCardId()))
            {
                return(result.GetCard());
            }

            return(null);
        }
Esempio n. 20
0
        private void getHandcards()
        {
            handCards.Clear();
            this.anzcards      = 0;
            this.enemyAnzCards = 0;
            List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            foreach (HRCard item in list)
            {
                HREntity entitiy = item.GetEntity();

                if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard
                {
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.GetCardId()));
                    //c.cost = entitiy.GetCost();
                    //c.entityID = entitiy.GetEntityId();

                    Handmanager.Handcard hc = new Handmanager.Handcard();
                    hc.card     = c;
                    hc.position = entitiy.GetZonePosition();
                    hc.entity   = entitiy.GetEntityId();
                    hc.manacost = entitiy.GetCost();
                    handCards.Add(hc);
                    this.anzcards++;
                }
            }

            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetControllerId() != this.ownPlayerController && ent.GetZonePosition() >= 1 && ent.GetZone() == HRCardZone.HAND) // enemy handcard
                {
                    this.enemyAnzCards++;
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// [EN]
        /// This handler is executed when the local player turn is active.
        ///
        /// [DE]
        /// Dieses Event wird ausgelöst wenn der Spieler am Zug ist.
        /// </summary>
        private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate()
        {
            try
            {
                if (this.isgoingtoconcede)
                {
                    if (HREngine.API.Utilities.HRSettings.Get.SelectedGameMode == HRGameMode.ARENA)
                    {
                        this.isgoingtoconcede = false;
                    }
                    else
                    {
                        return(new HREngine.API.Actions.ConcedeAction());
                    }
                }

                if (Settings.Instance.passiveWaiting && sf.waitingForSilver)
                {
                    if (!this.sf.readActionFile(true))
                    {
                        return(new HREngine.API.Actions.MakeNothingAction());
                    }
                }

                if (Settings.Instance.learnmode && (HRBattle.IsInTargetMode() || HRChoice.IsChoiceActive()))
                {
                    return(new HREngine.API.Actions.MakeNothingAction());
                }

                if (HRBattle.IsInTargetMode() && dirtytarget >= 0)
                {
                    Helpfunctions.Instance.ErrorLog("dirty targeting...");
                    HREntity target = getEntityWithNumber(dirtytarget);

                    dirtytarget = -1;

                    return(new HREngine.API.Actions.TargetAction(target));
                }
                if (HRChoice.IsChoiceActive())
                {
                    if (this.dirtychoice >= 1)
                    {
                        List <HREntity> choices = HRChoice.GetChoiceCards();
                        int             choice  = this.dirtychoice;
                        this.dirtychoice = -1;
                        string ccId = this.choiceCardId;
                        this.choiceCardId = "";
                        HREntity target = choices[choice - 1];
                        if (ccId == "EX1_160")
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_160b")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_160a")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "NEW1_008")
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "NEW1_008a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "NEW1_008b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_178")
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_178a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_178b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_573")
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_573a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_573b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_165")//druid of the claw
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_165t1")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_165t2")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_166")//keeper of the grove
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_166a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_166b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_155")
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_155a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_155b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_164")
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_164a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_164b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "New1_007")//starfall
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "New1_007b")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "New1_007a")
                                {
                                    target = hre;
                                }
                            }
                        }
                        if (ccId == "EX1_154")//warth
                        {
                            foreach (HREntity hre in choices)
                            {
                                if (choice == 1 && hre.GetCardId() == "EX1_154a")
                                {
                                    target = hre;
                                }
                                if (choice == 2 && hre.GetCardId() == "EX1_154b")
                                {
                                    target = hre;
                                }
                            }
                        }
                        Helpfunctions.Instance.logg("chooses the card: " + target.GetCardId());
                        return(new HREngine.API.Actions.ChoiceAction(target));
                    }
                    else
                    {
                        //Todo: ultimate tracking-simulation!
                        List <HREntity> choices = HRChoice.GetChoiceCards();
                        Random          r       = new Random();
                        int             choice  = r.Next(0, choices.Count);
                        Helpfunctions.Instance.logg("chooses a random card");
                        return(new HREngine.API.Actions.ChoiceAction(choices[choice]));
                    }
                }

                bool templearn = sf.updateEverything(behave, Settings.Instance.useExternalProcess, Settings.Instance.passiveWaiting);
                if (templearn == true)
                {
                    Settings.Instance.printlearnmode = true;
                }

                if (Settings.Instance.passiveWaiting && sf.waitingForSilver)
                {
                    return(new HREngine.API.Actions.MakeNothingAction());
                }

                if (Settings.Instance.learnmode)
                {
                    if (Settings.Instance.printlearnmode)
                    {
                        Ai.Instance.simmulateWholeTurnandPrint();
                    }
                    Settings.Instance.printlearnmode = false;
                    return(new HREngine.API.Actions.MakeNothingAction());
                }



                if (Ai.Instance.bestmoveValue <= -900 && Settings.Instance.enemyConcede)
                {
                    return(new HREngine.API.Actions.ConcedeAction());
                }

                Action moveTodo = Ai.Instance.bestmove;

                if (moveTodo == null || moveTodo.actionType == actionEnum.endturn)
                {
                    Helpfunctions.Instance.ErrorLog("end turn");
                    return(null);
                }
                Helpfunctions.Instance.ErrorLog("play action");
                moveTodo.print();
                if (moveTodo.actionType == actionEnum.playcard)
                {
                    HRCard cardtoplay = getCardWithNumber(moveTodo.card.entity);
                    if (moveTodo.target != null)
                    {
                        HREntity target = getEntityWithNumber(moveTodo.target.entitiyID);
                        Helpfunctions.Instance.ErrorLog("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName());
                        Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName() + " choice: " + moveTodo.druidchoice);
                        if (moveTodo.druidchoice >= 1)
                        {
                            this.dirtytarget  = moveTodo.target.entitiyID;
                            this.dirtychoice  = moveTodo.druidchoice; //1=leftcard, 2= rightcard
                            this.choiceCardId = moveTodo.card.card.cardIDenum.ToString();
                        }
                        if (moveTodo.card.card.type == CardDB.cardtype.MOB)
                        {
                            return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target, moveTodo.place));
                        }

                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target));
                    }
                    else
                    {
                        Helpfunctions.Instance.ErrorLog("play: " + cardtoplay.GetEntity().GetName() + " target nothing");
                        Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " choice: " + moveTodo.druidchoice);
                        if (moveTodo.druidchoice >= 1)
                        {
                            this.dirtychoice  = moveTodo.druidchoice; //1=leftcard, 2= rightcard
                            this.choiceCardId = moveTodo.card.card.cardIDenum.ToString();
                        }
                        if (moveTodo.card.card.type == CardDB.cardtype.MOB)
                        {
                            return(new HREngine.API.Actions.PlayCardAction(cardtoplay, null, moveTodo.place));
                        }
                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay));
                    }
                }

                if (moveTodo.actionType == actionEnum.attackWithMinion)
                {
                    HREntity attacker = getEntityWithNumber(moveTodo.own.entitiyID);
                    HREntity target   = getEntityWithNumber(moveTodo.target.entitiyID);
                    Helpfunctions.Instance.ErrorLog("minion attack: " + attacker.GetName() + " target: " + target.GetName());
                    Helpfunctions.Instance.logg("minion attack: " + attacker.GetName() + " target: " + target.GetName());
                    return(new HREngine.API.Actions.AttackAction(attacker, target));
                }

                if (moveTodo.actionType == actionEnum.attackWithHero)
                {
                    HREntity attacker = getEntityWithNumber(moveTodo.own.entitiyID);
                    HREntity target   = getEntityWithNumber(moveTodo.target.entitiyID);
                    this.dirtytarget = moveTodo.target.entitiyID;
                    Helpfunctions.Instance.ErrorLog("heroattack: " + attacker.GetName() + " target: " + target.GetName());
                    Helpfunctions.Instance.logg("heroattack: " + attacker.GetName() + " target: " + target.GetName());
                    if (HRPlayer.GetLocalPlayer().HasWeapon())
                    {
                        Helpfunctions.Instance.ErrorLog("hero attack with weapon");
                        return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), target));
                    }
                    Helpfunctions.Instance.ErrorLog("hero attack without weapon");
                    //Helpfunctions.Instance.ErrorLog("attacker entity: " + HRPlayer.GetLocalPlayer().GetHero().GetEntityId());
                    //return new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), target);
                    return(new HREngine.API.Actions.PlayCardAction(HRPlayer.GetLocalPlayer().GetHeroCard(), target));
                }

                if (moveTodo.actionType == actionEnum.useHeroPower)
                {
                    HRCard cardtoplay = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard();

                    if (moveTodo.target != null)
                    {
                        HREntity target = getEntityWithNumber(moveTodo.target.entitiyID);
                        Helpfunctions.Instance.ErrorLog("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName());
                        Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName());
                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target));
                    }
                    else
                    {
                        Helpfunctions.Instance.ErrorLog("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing");
                        Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing");
                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay));
                    }
                }
            }
            catch (Exception Exception)
            {
                Helpfunctions.Instance.ErrorLog(Exception.Message);
                Helpfunctions.Instance.ErrorLog(Environment.StackTrace);
                if (Settings.Instance.learnmode)
                {
                    return(new HREngine.API.Actions.MakeNothingAction());
                }
            }
            return(null);
            //HRBattle.FinishRound();
        }
Esempio n. 22
0
        private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
        {
            if (Settings.Instance.learnmode)
            {
                return(new HREngine.API.Actions.MakeNothingAction());
            }
            //Helpfunctions.Instance.ErrorLog("handle mulligan");


            if (HRMulligan.IsMulliganActive())
            {
                var      list        = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
                HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();
                HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
                string   enemName    = Hrtprozis.Instance.heroIDtoName(enemyPlayer.GetHeroCard().GetEntity().GetCardId());
                string   ownName     = Hrtprozis.Instance.heroIDtoName(ownPlayer.GetHeroCard().GetEntity().GetCardId());
                if (Mulligan.Instance.hasmulliganrules(ownName, enemName))
                {
                    List <Mulligan.CardIDEntity> celist = new List <Mulligan.CardIDEntity>();
                    foreach (var item in list)
                    {
                        if (item.GetEntity().GetCardId() != "GAME_005")// dont mulligan coin
                        {
                            celist.Add(new Mulligan.CardIDEntity(item.GetEntity().GetCardId(), item.GetEntity().GetEntityId()));
                        }
                    }
                    List <int> mullientitys = Mulligan.Instance.whatShouldIMulligan(celist, ownName, enemName);
                    foreach (var item in list)
                    {
                        if (mullientitys.Contains(item.GetEntity().GetEntityId()))
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because of your rules");
                            HRMulligan.ToggleCard(item);
                        }
                    }
                }
                else
                {
                    foreach (var item in list)
                    {
                        if (item.GetEntity().GetCost() >= 4)
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4.");
                            HRMulligan.ToggleCard(item);
                        }
                        if (item.GetEntity().GetCardId() == "EX1_308" || item.GetEntity().GetCardId() == "EX1_622" || item.GetEntity().GetCardId() == "EX1_005")
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it is soulfire or shadow word: death");
                            HRMulligan.ToggleCard(item);
                        }
                    }
                }


                sf.setnewLoggFile();

                //writeSettings();

                if (Mulligan.Instance.loserLoserLoser)
                {
                    if (!autoconcede())
                    {
                        concedeVSenemy(ownName, enemName);
                    }
                }

                return(null);
                //HRMulligan.EndMulligan();
            }
            return(null);
        }
Esempio n. 23
0
        protected override ActionBase PlayCardsToField()
        {
            var EnemyState = new PlayerState(HRPlayer.GetEnemyPlayer());
            var LocalState = new PlayerState(HRPlayer.GetLocalPlayer());
            var Sorting    = new Sorting();

            // Retreive cards that can be played.
            List <HRCard> playableList =
                GetPlayableCards(HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND));

            // Update list with conditions matching this custom class.
            GetConditionalCards(playableList, EnemyState, LocalState);

            // Sort by cost (ascending)
            Sorting.SortByCost(ref playableList);

            // Finally sort by custom priority
            playableList = SortByPriority(playableList);

            // Taunts
            if (LocalState.TauntMinions.Count == 0)
            {
                foreach (var minion in playableList)
                {
                    HREntity Target = null;
                    if (minion.GetEntity().HasTaunt() &&
                        CanHandleCard(minion, EnemyState, LocalState, ref Target))
                    {
                        return(new PlayCardAction(minion, Target));
                    }
                }
            }

            // Charges
            foreach (var minion in playableList)
            {
                HREntity Target = null;
                if (minion.GetEntity().HasCharge() &&
                    CanHandleCard(minion, EnemyState, LocalState, ref Target))
                {
                    return(new PlayCardAction(minion, Target));
                }
            }

            // All other available
            foreach (var minion in playableList)
            {
                HREntity Target = null;
                if (CanHandleCard(minion, EnemyState, LocalState, ref Target))
                {
                    return(new PlayCardAction(minion, Target));
                }
            }

            // Use Hero Power that make sense at last...
            if (LocalState.Player.GetHeroPower().GetCost() <= LocalState.Mana)
            {
                if (LocalState.Player.GetHero().GetClass() == HRClass.HUNTER)
                {
                    if (HRBattle.CanUseCard(LocalState.Player.GetHeroPower()))
                    {
                        return(new PlayCardAction(LocalState.Player.GetHeroPower().GetCard()));
                    }
                }
            }

            if (LocalState.Player.HasWeapon())
            {
                if (HRBattle.CanUseCard(LocalState.Player.GetHeroCard().GetEntity()))
                {
                    return(new AttackAction(LocalState.Player.GetWeaponCard().GetEntity(), GetNextAttackToAttack()));
                }
            }

            return(null);
        }
Esempio n. 24
0
        public static PlayerPossibleAttack GetPossibleAttack(HRPlayer Player, int RequiredAttack, int Limit = -1)
        {
            var result      = new PlayerPossibleAttack();
            var playerState = new PlayerState(Player);

            var minions = playerState.ReadyMinions;

            // FIX: Only use cards to attack that are really needed to defeat somone.
            // (sorted by attack)
            var sorting = new Sorting();

            sorting.SortByAttack(ref minions, Sorting.SortMode.Descending);

            // Loop through all minions that can attack..
            foreach (var item in minions)
            {
                if (HRCardManager.CanAttackWithCard(item.GetCard()))
                {
                    if (Limit == -1)
                    {
                        result.Attack += item.GetATK();
                        result.Cards.Add(item);
                    }
                    else if (result.Cards.Count + 1 == Limit)
                    {
                        // Try to find a combination that matches...
                        if (result.Attack + item.GetATK() >= RequiredAttack)
                        {
                            result.Attack += item.GetATK();
                            result.Cards.Add(item);
                        }
                    }
                    else
                    {
                        result.Attack += item.GetATK();
                        result.Cards.Add(item);
                    }
                }
            }

            if (result.Attack < RequiredAttack)
            {
                int remainingMana = Player.GetNumAvailableResources();

                // Check other resources that can deal damage.

                // Deal damage with hero power?
                if (Player.GetHeroPower().GetATK() > 0)
                {
                    if (Player.GetHeroPower().GetCost() <= remainingMana)
                    {
                        result.Attack += Player.GetHeroPower().GetATK();
                        result.Cost   += Player.GetHeroPower().GetCost();
                        result.Cards.Add(Player.GetHeroPower());
                        remainingMana -= Player.GetHeroPower().GetCost();
                    }
                }

                // Hero Card most times: Weapons and other special stuff.
                if (Player.HasWeapon() && Player.GetWeaponCard().GetEntity().GetATK() > 0 &&
                    Player.GetWeaponCard().GetEntity().CanAttack() &&
                    Player.GetWeaponCard().GetEntity().GetCost() <= remainingMana)
                {
                    if (HRCardManager.CanAttackWithCard(Player.GetHero().GetCard()))
                    {
                        result.Attack += Player.GetWeaponCard().GetEntity().GetATK();
                        result.Cost   += Player.GetWeaponCard().GetEntity().GetCost();
                        result.Cards.Add(Player.GetWeaponCard().GetEntity());

                        remainingMana -= Player.GetHero().GetCost();
                    }
                }

                // Remaining cards on hand?
                List <HRCard> playerHand = HRCard.GetCards(Player, HRCardZone.HAND);
                foreach (var item in playerHand)
                {
                    if ((item.GetEntity().IsSpell() ||
                         (item.GetEntity().IsMinion() && item.GetEntity().HasCharge())) &&
                        item.GetEntity().GetATK() > 0)
                    {
                        int cost = item.GetEntity().GetCost();
                        if (cost <= remainingMana)
                        {
                            result.Attack += item.GetEntity().GetATK();
                            result.Cost   += cost;
                            result.Cards.Add(item.GetEntity());
                            remainingMana -= cost;
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 25
0
        private void getHerostuff()
        {
            HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
            HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();

            HREntity ownhero        = ownPlayer.GetHero();
            HREntity enemyhero      = enemyPlayer.GetHero();
            HREntity ownHeroAbility = ownPlayer.GetHeroPower();

            //player stuff#########################
            //this.currentMana =ownPlayer.GetTag(HRGameTag.RESOURCES) - ownPlayer.GetTag(HRGameTag.RESOURCES_USED) + ownPlayer.GetTag(HRGameTag.TEMP_RESOURCES);
            this.currentMana = ownPlayer.GetNumAvailableResources();
            this.ownMaxMana  = ownPlayer.GetTag(HRGameTag.RESOURCES);//ownPlayer.GetRealTimeTempMana();
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss"));
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana);
            Helpfunctions.Instance.logg("own secretsCount: " + ownPlayer.GetSecretDefinitions().Count);
            enemySecretCount = HRCard.GetCards(enemyPlayer, HRCardZone.SECRET).Count;
            enemySecretCount = 0;
            Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount);
            this.ownSecretList            = ownPlayer.GetSecretDefinitions();
            this.numMinionsPlayedThisTurn = ownPlayer.GetTag(HRGameTag.NUM_MINIONS_PLAYED_THIS_TURN);
            this.cardsPlayedThisTurn      = ownPlayer.GetTag(HRGameTag.NUM_CARDS_PLAYED_THIS_TURN);
            //if (ownPlayer.HasCombo()) this.cardsPlayedThisTurn = 1;
            this.ueberladung = ownPlayer.GetTag(HRGameTag.RECALL_OWED);


            //get weapon stuff
            this.ownHeroWeapon        = "";
            this.heroWeaponAttack     = 0;
            this.heroWeaponDurability = 0;

            this.ownHeroFatigue   = ownhero.GetFatigue();
            this.enemyHeroFatigue = enemyhero.GetFatigue();
            //this.ownDecksize = HRCard.GetCards(ownPlayer, HRCardZone.DECK).Count;

            //this.enemyDecksize = HRCard.GetCards(enemyPlayer, HRCardZone.DECK).Count;



            this.enemyHeroWeapon       = "";
            this.enemyWeaponAttack     = 0;
            this.enemyWeaponDurability = 0;
            if (enemyPlayer.HasWeapon())
            {
                HREntity weapon = enemyPlayer.GetWeaponCard().GetEntity();
                this.enemyHeroWeapon       = CardDB.Instance.getCardDataFromID(weapon.GetCardId()).name;
                this.enemyWeaponAttack     = weapon.GetATK();
                this.enemyWeaponDurability = weapon.GetDurability();
            }


            //own hero stuff###########################
            this.heroAtk     = ownhero.GetATK();
            this.heroHp      = ownhero.GetHealth() - ownhero.GetDamage();
            this.heroDefence = ownhero.GetArmor();
            this.heroname    = Hrtprozis.Instance.heroIDtoName(ownhero.GetCardId());
            bool exausted = false;

            exausted           = ownhero.IsExhausted();
            this.ownheroisread = true;

            this.heroImmuneToDamageWhileAttacking = (ownhero.IsImmune()) ? true : false;
            this.herofrozen             = ownhero.IsFrozen();
            this.heroNumAttacksThisTurn = ownhero.GetNumAttacksThisTurn();
            this.heroHasWindfury        = ownhero.HasWindfury();
            //int numberofattacks = ownhero.GetNumAttacksThisTurn();

            //HRLog.Write(ownhero.GetName() + " ready params ex: " + exausted + " " + heroAtk + " " + numberofattacks + " " + herofrozen);

            if (exausted == true)
            {
                this.ownheroisread = false;
            }
            if (exausted == false && this.heroAtk == 0)
            {
                this.ownheroisread = false;
            }
            if (herofrozen)
            {
                ownheroisread = false;
            }


            if (ownPlayer.HasWeapon())
            {
                HREntity weapon = ownPlayer.GetWeaponCard().GetEntity();
                this.ownHeroWeapon                    = CardDB.Instance.getCardDataFromID(weapon.GetCardId()).name;
                this.heroWeaponAttack                 = weapon.GetATK();
                this.heroWeaponDurability             = weapon.GetTag(HRGameTag.DURABILITY) - weapon.GetTag(HRGameTag.DAMAGE);//weapon.GetDurability();
                this.heroImmuneToDamageWhileAttacking = false;
                if (this.ownHeroWeapon == "gladiatorslongbow")
                {
                    this.heroImmuneToDamageWhileAttacking = true;
                }

                //HRLog.Write("weapon: " + ownHeroWeapon + " " + heroWeaponAttack + " " + heroWeaponDurability);
            }

            //enemy hero stuff###############################################################
            this.enemyAtk = enemyhero.GetATK();

            this.enemyHp = enemyhero.GetHealth() - enemyhero.GetDamage();

            this.enemyHeroname = Hrtprozis.Instance.heroIDtoName(enemyhero.GetCardId());

            this.enemyDefence = enemyhero.GetArmor();

            this.enemyfrozen = enemyhero.IsFrozen();



            //own hero ablity stuff###########################################################

            this.heroAbility       = CardDB.Instance.getCardDataFromID(ownHeroAbility.GetCardId());
            this.ownAbilityisReady = (ownHeroAbility.IsExhausted()) ? false : true; // if exhausted, ability is NOT ready
        }
Esempio n. 26
0
        private void getMinions()
        {
            ownMinions.Clear();
            enemyMinions.Clear();
            HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
            HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();

            // ALL minions on Playfield:
            List <HRCard> list = HRCard.GetCards(ownPlayer, HRCardZone.PLAY);

            list.AddRange(HRCard.GetCards(enemyPlayer, HRCardZone.PLAY));

            List <HREntity> enchantments = new List <HREntity>();


            foreach (HRCard item in list)
            {
                HREntity entitiy = item.GetEntity();
                int      zp      = entitiy.GetZonePosition();

                if (entitiy.GetCardType() == HRCardType.MINION && zp >= 1)
                {
                    //HRLog.Write("zonepos " + zp);
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(entitiy.GetCardId());
                    Minion      m = new Minion();
                    m.name          = c.name;
                    m.handcard.card = c;
                    m.Angr          = entitiy.GetATK();
                    m.maxHp         = entitiy.GetHealth();
                    m.Hp            = m.maxHp - entitiy.GetDamage();
                    m.wounded       = false;
                    if (m.maxHp > m.Hp)
                    {
                        m.wounded = true;
                    }


                    m.exhausted = entitiy.IsExhausted();

                    m.taunt = (entitiy.HasTaunt()) ? true : false;

                    m.charge = (entitiy.HasCharge()) ? true : false;

                    m.numAttacksThisTurn = entitiy.GetNumAttacksThisTurn();

                    int temp = entitiy.GetNumTurnsInPlay();
                    m.playedThisTurn = (temp == 0) ? true : false;

                    m.windfury = (entitiy.HasWindfury()) ? true : false;

                    m.frozen = (entitiy.IsFrozen()) ? true : false;

                    m.divineshild = (entitiy.HasDivineShield()) ? true : false;

                    m.stealth = (entitiy.IsStealthed()) ? true : false;

                    m.poisonous = (entitiy.IsPoisonous()) ? true : false;

                    m.immune = (entitiy.IsImmune()) ? true : false;

                    m.silenced = (entitiy.GetTag(HRGameTag.SILENCED) >= 1) ? true:false;


                    m.zonepos = zp;
                    m.id      = m.zonepos - 1;

                    m.entitiyID = entitiy.GetEntityId();

                    m.enchantments.Clear();

                    //HRLog.Write(  m.name + " ready params ex: " + m.exhausted + " charge: " +m.charge + " attcksthisturn: " + m.numAttacksThisTurn + " playedthisturn " + m.playedThisTurn );

                    m.Ready = false; // if exhausted, he is NOT ready

                    if (!m.playedThisTurn && !m.exhausted && !m.frozen && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury)))
                    {
                        m.Ready = true;
                    }

                    if (m.playedThisTurn && m.charge && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury)))
                    {
                        //m.exhausted = false;
                        m.Ready = true;
                    }

                    if (!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord"))
                    {
                        m.Ready = false;
                    }


                    if (entitiy.GetControllerId() == this.ownPlayerController) // OWN minion
                    {
                        this.ownMinions.Add(m);
                    }
                    else
                    {
                        this.enemyMinions.Add(m);
                    }
                }
                // minions added

                if (entitiy.GetCardType() == HRCardType.WEAPON)
                {
                    //HRLog.Write("found weapon!");
                    if (entitiy.GetControllerId() == this.ownPlayerController) // OWN weapon
                    {
                        this.ownHeroWeapon        = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()).name;
                        this.heroWeaponAttack     = entitiy.GetATK();
                        this.heroWeaponDurability = entitiy.GetDurability();
                        //this.heroImmuneToDamageWhileAttacking = false;
                    }
                    else
                    {
                        this.enemyHeroWeapon       = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()).name;
                        this.enemyWeaponAttack     = entitiy.GetATK();
                        this.enemyWeaponDurability = entitiy.GetDurability();
                    }
                }

                if (entitiy.GetCardType() == HRCardType.ENCHANTMENT)
                {
                    enchantments.Add(entitiy);
                }
            }

            foreach (HRCard item in list)
            {
                foreach (HREntity e in item.GetEntity().GetEnchantments())
                {
                    enchantments.Add(e);
                }
            }


            // add enchantments to minions
            setEnchantments(enchantments);
        }
Esempio n. 27
0
 private List <HRCard> GetAllCardsInHand()
 {
     return(HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND));
 }
Esempio n. 28
0
        /// <summary>
        /// [EN]
        /// This handler is executed when the local player turn is active.
        ///
        /// [DE]
        /// Dieses Event wird ausgelöst wenn der Spieler am Zug ist.
        /// </summary>
        private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate()
        {
            try
            {
                if (HRBattle.IsInTargetMode() && dirtytarget >= 0)
                {
                    HRLog.Write("dirty targeting...");
                    HREntity target = getEntityWithNumber(dirtytarget);
                    dirtytarget = -1;
                    return(new HREngine.API.Actions.TargetAction(target));
                }


                //SafeHandleBattleLocalPlayerTurnHandler();


                sf.updateEverything(this);
                Action moveTodo = Ai.Instance.bestmove;
                if (moveTodo == null)
                {
                    HRLog.Write("end turn");
                    return(null);
                }
                HRLog.Write("play action");
                moveTodo.print();
                if (moveTodo.cardplay)
                {
                    HRCard cardtoplay = getCardWithNumber(moveTodo.cardEntitiy);
                    if (moveTodo.enemytarget >= 0)
                    {
                        HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy);
                        HRLog.Write("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName());
                        Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName());
                        if (moveTodo.handcard.card.type == CardDB.cardtype.MOB)
                        {
                            return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target, moveTodo.owntarget + 1));
                        }

                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target));
                    }
                    else
                    {
                        HRLog.Write("play: " + cardtoplay.GetEntity().GetName() + " target nothing");
                        if (moveTodo.handcard.card.type == CardDB.cardtype.MOB)
                        {
                            return(new HREngine.API.Actions.PlayCardAction(cardtoplay, null, moveTodo.owntarget + 1));
                        }
                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay));
                    }
                }

                if (moveTodo.minionplay)
                {
                    HREntity attacker = getEntityWithNumber(moveTodo.ownEntitiy);
                    HREntity target   = getEntityWithNumber(moveTodo.enemyEntitiy);
                    HRLog.Write("minion attack: " + attacker.GetName() + " target: " + target.GetName());
                    Helpfunctions.Instance.logg("minion attack: " + attacker.GetName() + " target: " + target.GetName());
                    return(new HREngine.API.Actions.AttackAction(attacker, target));
                }

                if (moveTodo.heroattack)
                {
                    HREntity attacker = getEntityWithNumber(moveTodo.ownEntitiy);
                    HREntity target   = getEntityWithNumber(moveTodo.enemyEntitiy);
                    this.dirtytarget = moveTodo.enemyEntitiy;
                    //HRLog.Write("heroattack: attkr:" + moveTodo.ownEntitiy + " defender: " + moveTodo.enemyEntitiy);
                    HRLog.Write("heroattack: " + attacker.GetName() + " target: " + target.GetName());
                    Helpfunctions.Instance.logg("heroattack: " + attacker.GetName() + " target: " + target.GetName());
                    if (HRPlayer.GetLocalPlayer().HasWeapon())
                    {
                        HRLog.Write("hero attack with weapon");
                        return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), target));
                    }
                    HRLog.Write("hero attack without weapon");
                    //HRLog.Write("attacker entity: " + HRPlayer.GetLocalPlayer().GetHero().GetEntityId());
                    return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), target));
                }

                if (moveTodo.useability)
                {
                    HRCard cardtoplay = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard();

                    if (moveTodo.enemytarget >= 0)
                    {
                        HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy);
                        HRLog.Write("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName());
                        Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName());
                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target));
                    }
                    else
                    {
                        HRLog.Write("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing");
                        Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing");
                        return(new HREngine.API.Actions.PlayCardAction(cardtoplay));
                    }
                }
            }
            catch (Exception Exception)
            {
                HRLog.Write(Exception.Message);
                HRLog.Write(Environment.StackTrace);
            }
            return(null);
            //HRBattle.FinishRound();
        }
Esempio n. 29
0
 protected virtual HRCard GetMinionByPriority(HRCard lastMinion = null)
 {
     return(null);
 }
Esempio n. 30
0
 private bool CanHandleCard(
  HRCard item, PlayerState EnemyState, PlayerState LocalState, ref HREntity Target)
 {
     string cardID = item.GetEntity().GetCardId().ToUpper();
      switch (cardID)
      {
     case "CS2_122": // "Raid Leader"
        return LocalState.Minions > 0;
     case "EX1_066": // "Acidic Swamp Ooze"
        return EnemyState.Player.HasWeapon() || LocalState.Minions < EnemyState.Minions;
     default:
        break;
      }
      return true;
 }
Esempio n. 31
0
        private List <HRCard> getallHandCards()
        {
            List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            return(list);
        }
Esempio n. 32
0
        private void SeedSmartCc()
        {
            SmartCc.SimuCount++;
            Board root = new Board();

            HREntity HeroEnemy = HRPlayer.GetEnemyPlayer().GetHero();

            Card ce = Card.Create(HeroEnemy.GetCardId(), false, HeroEnemy.GetEntityId());

            root.HeroEnemy = ce;

            HREntity HeroFriend = HRPlayer.GetLocalPlayer().GetHero();

            root.HeroFriend = Card.Create(HeroFriend.GetCardId(), true, HeroFriend.GetEntityId());

            root.HeroEnemy.CurrentHealth = HeroEnemy.GetHealth() - HeroEnemy.GetDamage();
            root.HeroEnemy.MaxHealth     = 30;

            root.HeroEnemy.CurrentArmor   = HeroEnemy.GetArmor();
            root.HeroFriend.CurrentHealth = HeroFriend.GetHealth() - HeroFriend.GetDamage();
            root.HeroFriend.MaxHealth     = 30;
            root.HeroFriend.IsFrozen      = HeroFriend.IsFrozen();

            root.HeroFriend.CurrentArmor = HeroFriend.GetArmor();
            root.HeroFriend.CurrentAtk   = HeroFriend.GetATK();

            if (HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.SECRET).Count > 0)
            {
                root.SecretEnemy = true;
            }

            if (HRPlayer.GetEnemyPlayer().HasWeapon())
            {
                HRCard weaponEnemyCard = HRPlayer.GetEnemyPlayer().GetWeaponCard();
                if (weaponEnemyCard != null)
                {
                    root.WeaponEnemy = Card.Create(weaponEnemyCard.GetEntity().GetCardId(), false, weaponEnemyCard.GetEntity().GetEntityId());
                }
            }

            if (HRPlayer.GetLocalPlayer().HasWeapon())
            {
                HRCard weaponFriendCard = HRPlayer.GetLocalPlayer().GetWeaponCard();
                if (weaponFriendCard != null)
                {
                    root.WeaponFriend         = Card.Create(weaponFriendCard.GetEntity().GetCardId(), true, weaponFriendCard.GetEntity().GetEntityId());
                    root.WeaponFriend.IsTired = (weaponFriendCard.GetEntity().GetNumAttacksThisTurn() > 0 || HeroFriend.GetNumAttacksThisTurn() > 0);
                }
            }

            root.ManaAvailable = HRPlayer.GetLocalPlayer().GetNumAvailableResources();

            foreach (HREntity e in GetEnemyEntitiesOnBoard())
            {
                Card newc = Card.Create(e.GetCardId(), false, e.GetEntityId());
                newc.CurrentAtk    = e.GetATK();
                newc.CurrentHealth = e.GetHealth() - e.GetDamage();
                newc.MaxHealth     = e.GetHealth();
                foreach (HREntity az in e.GetEnchantments())
                {
                    Buff b = Buff.GetBuffById(az.GetCardId());
                    if (b != null)
                    {
                        b.OwnerId = az.GetCreatorId();
                        newc.AddBuff(b);
                        newc.currentAtk    -= b.Atk;
                        newc.CurrentHealth -= b.Hp;
                        newc.maxHealth     -= b.Hp;
                    }
                }

                newc.CurrentCost    = e.GetCost();
                newc.IsCharge       = e.HasCharge();
                newc.IsDivineShield = e.HasDivineShield();
                newc.IsEnraged      = e.IsEnraged();
                newc.IsFrozen       = e.IsFrozen();
                newc.HasFreeze      = e.IsFreeze();
                newc.IsStealth      = e.IsStealthed();
                newc.IsSilenced     = e.IsSilenced();
                newc.HasPoison      = e.IsPoisonous();
                newc.IsWindfury     = e.HasWindfury();
                newc.IsTaunt        = e.HasTaunt();
                newc.Index          = e.GetTag(HRGameTag.ZONE_POSITION) - 1;
                // HRLog.Write(e.GetName() + " at " + newc.Index.ToString());
                root.MinionEnemy.Add(newc);
            }
            foreach (HREntity e in GetFriendEntitiesOnBoard())
            {
                Card newc = Card.Create(e.GetCardId(), true, e.GetEntityId());

                newc.CurrentAtk    = e.GetATK();
                newc.CurrentHealth = e.GetHealth() - e.GetDamage();
                newc.MaxHealth     = e.GetHealth();
                foreach (HREntity az in e.GetEnchantments())
                {
                    Buff b = Buff.GetBuffById(az.GetCardId());
                    if (b != null)
                    {
                        b.OwnerId = az.GetCreatorId();
                        newc.AddBuff(b);
                        newc.currentAtk    -= b.Atk;
                        newc.CurrentHealth -= b.Hp;
                        newc.MaxHealth     -= b.Hp;
                    }
                }
                newc.CurrentCost    = e.GetCost();
                newc.IsCharge       = e.HasCharge();
                newc.IsDivineShield = e.HasDivineShield();
                newc.IsEnraged      = e.IsEnraged();
                newc.IsFrozen       = e.IsFrozen();
                newc.HasFreeze      = e.IsFreeze();
                newc.IsStealth      = e.IsStealthed();
                newc.IsSilenced     = e.IsSilenced();
                newc.HasPoison      = e.IsPoisonous();
                newc.IsWindfury     = e.HasWindfury();
                newc.IsTaunt        = e.HasTaunt();
                newc.IsTired        = e.IsExhausted();
                newc.IsImmune       = e.IsImmune();
                newc.Index          = e.GetTag(HRGameTag.ZONE_POSITION) - 1;
                newc.CountAttack    = e.GetTag(HRGameTag.NUM_ATTACKS_THIS_TURN);

                root.MinionFriend.Add(newc);
            }
            foreach (HRCard c in HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.SECRET))
            {
                Card newc = Card.Create(c.GetEntity().GetCardId(), true, c.GetEntity().GetEntityId());
                root.Secret.Add(newc);
            }
            foreach (HRCard c in GetAllCardsInHand())
            {
                Card newc = Card.Create(c.GetEntity().GetCardId(), true, c.GetEntity().GetEntityId());
                root.Hand.Add(newc);
            }
            if (!HRPlayer.GetLocalPlayer().GetHeroPower().IsExhausted())
            {
                root.Ability = Card.Create(HRPlayer.GetLocalPlayer().GetHeroPower().GetCardId(), true, HRPlayer.GetLocalPlayer().GetHeroPower().GetEntityId());
            }
            if (!HRPlayer.GetEnemyPlayer().GetHeroPower().IsExhausted())
            {
                root.EnemyAbility = Card.Create(HRPlayer.GetEnemyPlayer().GetHeroPower().GetCardId(), false, HRPlayer.GetEnemyPlayer().GetHeroPower().GetEntityId());
            }
            root.TurnCount = SmartCc.TurnCount + 1;
            SmartCc.root   = root;
        }
Esempio n. 33
0
 public static bool HasRule(HRCard Card)
 {
     return HasRule(Card.GetEntity().GetCardId());
 }
Esempio n. 34
0
        private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate()
        {
            if (SmartCc == null)
            {
                SmartCc = new Simulation();


                SmartCc.CreateLogFolder();
                SmartCc.TurnCount = 0;
            }
            while (true)
            {
                if (SmartCc.NeedCalculation)
                {
                    HRLog.Write("Seed");
                    SeedSmartCc();
                    HRLog.Write("Simulation");
                    StreamReader str = new StreamReader(CardTemplate.DatabasePath + "Bots/SmartCC/Config/useThreading");
                    string       use = str.ReadLine();

                    str.Close();

                    if (use == "true")
                    {
                        SmartCc.Simulate(true);
                    }
                    else
                    {
                        SmartCc.Simulate(false);
                    }
                    HRLog.Write("Simulation Done");
                }

                if (SmartCc.ActionStack.Count <= 0)
                {
                    HRLog.Write("Simulation didnt found any action");
                }
                else
                {
                    HRLog.Write("Actions :");

                    foreach (Action a in SmartCc.ActionStack)
                    {
                        HRLog.Write(a.ToString());
                    }
                }


                ActionToDo = SmartCc.GetNextAction();
                try
                {
                    switch (ActionToDo.Type)
                    {
                    case Action.ActionType.TARGET:
                        HREntity targett = GetEntityById(ActionToDo.Target.Id);
                        return(new HREngine.API.Actions.TargetAction(targett));

                    case Action.ActionType.CHOICE:
                        if (HREngine.API.HRChoice.IsChoiceActive())
                        {
                            List <HREntity> choices = HRChoice.GetChoiceCards();
                            if (SmartCc.ChoiceTarget != null)
                            {
                                SmartCc.InsertTargetAction(SmartCc.ChoiceTarget);
                                SmartCc.ChoiceTarget = null;
                            }
                            return(new HREngine.API.Actions.ChoiceAction(choices[ActionToDo.Choice - 1]));
                        }
                        else
                        {
                            return(null);
                        }

                    case Action.ActionType.CAST_ABILITY:
                        HRCard cardAbility = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard();
                        if (ActionToDo.Target != null)
                        {
                            HREntity target = GetEntityById(ActionToDo.Target.Id);
                            return(new HREngine.API.Actions.PlayCardAction(cardAbility, target, ActionToDo.Index + 1));
                        }
                        else
                        {
                            return(new HREngine.API.Actions.PlayCardAction(cardAbility, null, ActionToDo.Index + 1));
                        }

                    case Action.ActionType.CAST_WEAPON:
                    case Action.ActionType.CAST_MINION:
                    case Action.ActionType.CAST_SPELL:

                        HRCard card = GetCardById(ActionToDo.Actor.Id);
                        if (ActionToDo.Actor.HasChoices)
                        {
                            HRLog.Write("CARD HAS CHOICES");
                            if (ActionToDo.Target != null)
                            {
                                SmartCc.ChoiceTarget = ActionToDo.Target;
                            }
                            SmartCc.InsertChoiceAction(ActionToDo.Choice);
                        }
                        if (ActionToDo.Target != null)
                        {
                            HREntity target = GetEntityById(ActionToDo.Target.Id);
                            return(new HREngine.API.Actions.PlayCardAction(card, target, ActionToDo.Index + 1));
                        }
                        else
                        {
                            return(new HREngine.API.Actions.PlayCardAction(card, null, ActionToDo.Index + 1));
                        }


                    case Action.ActionType.HERO_ATTACK:

                        HREntity attackerAttack = GetEntityById(ActionToDo.Actor.Id);
                        HREntity targetAttack   = GetEntityById(ActionToDo.Target.Id);
                        if (HRPlayer.GetLocalPlayer().HasWeapon())
                        {
                            return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), targetAttack));
                        }
                        return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), targetAttack));

                    case Action.ActionType.MINION_ATTACK:

                        HREntity attackerAttackM = GetEntityById(ActionToDo.Actor.Id);
                        HREntity targetAttackM   = GetEntityById(ActionToDo.Target.Id);
                        return(new HREngine.API.Actions.AttackAction(attackerAttackM, targetAttackM));

                    case Action.ActionType.END_TURN:
                        HRLog.Write("EndTurn");
                        SmartCc.TurnCount++;
                        SmartCc.SimuCount = 0;
                        //HRBattle.FinishRound();
                        return(null);

                    case Action.ActionType.RESIMULATE:
                        HRLog.Write("Resimulate");
                        SmartCc.NeedCalculation = true;
                        continue;
                    }
                }
                catch (Exception Exception)
                {
                    HRLog.Write(Exception.Message);
                    HRLog.Write(Environment.StackTrace);
                    return(null);
                }

                HRLog.Write("Action not handled");
                return(null);
            }

            SmartCc.NeedCalculation = true;
            return(null);
        }
Esempio n. 35
0
 protected virtual HRCard GetMinionByPriority(HRCard lastMinion = null)
 {
     return null;
 }
Esempio n. 36
0
 public static HREngine.Private.HREngineRules GetRulesForCard(HRCard Card)
 {
     return GetRulesForCard(Card.GetEntity().GetCardId());
 }