示例#1
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);
        }
示例#2
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++;
                }
            }
        }
示例#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);
        }
示例#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);
        }
示例#5
0
        protected override HREntity GetNextAttackToAttack()
        {
            var enemyState = new PlayerState(HRPlayer.GetEnemyPlayer());

            if (enemyState.Minions > 0)
            {
                var list = enemyState.TauntMinions;
                if (list.Count == 0)
                {
                    list = enemyState.AttackableMinions;
                }

                var sorting = new Sorting();
                sorting.SortByHealth(ref list);

                foreach (var minion in list)
                {
                    if (minion.CanBeAttacked())
                    {
                        return(minion);
                    }
                }
            }

            return(enemyState.Player.GetHero());
        }
示例#6
0
        public void updateEverything(BotBase botbase)
        {
            HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
            HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();

            ownPlayerController = ownPlayer.GetHero().GetControllerId();    //ownPlayer.GetHero().GetControllerId()


            // create hero + minion data
            getHerostuff();
            getMinions();
            getHandcards();

            // send ai the data:
            Hrtprozis.Instance.setOwnPlayer(ownPlayerController);
            Handmanager.Instance.setOwnPlayer(ownPlayerController);

            Hrtprozis.Instance.updatePlayer(this.ownMaxMana, this.currentMana, this.cardsPlayedThisTurn, this.numMinionsPlayedThisTurn, this.ueberladung, ownPlayer.GetHero().GetEntityId(), enemyPlayer.GetHero().GetEntityId());

            Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability, this.heroImmuneToDamageWhileAttacking, this.heroAtk, this.heroHp, this.heroDefence, this.heroname, this.ownheroisread, this.ownheroAlreadyAttacked, this.herofrozen, this.heroAbility, this.ownAbilityisReady);
            Hrtprozis.Instance.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability, this.enemyAtk, this.enemyHp, this.enemyDefence, this.enemyHeroname, this.enemyfrozen);

            Hrtprozis.Instance.updateMinions(this.ownMinions, this.enemyMinions);
            Handmanager.Instance.setHandcards(this.handCards, this.anzcards, this.enemyAnzCards);

            // print data
            Hrtprozis.Instance.printHero();
            Hrtprozis.Instance.printOwnMinions();
            Hrtprozis.Instance.printEnemyMinions();
            Handmanager.Instance.printcards();

            // calculate stuff
            HRLog.Write("calculating stuff...");
            Ai.Instance.dosomethingclever(botbase);
        }
示例#7
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);
        }
示例#8
0
        private bool autoconcede()
        {
            if (HREngine.API.Utilities.HRSettings.Get.SelectedGameMode == HRGameMode.ARENA)
            {
                return(false);
            }
            if (HREngine.API.Utilities.HRSettings.Get.SelectedGameMode != HRGameMode.RANKED_PLAY)
            {
                return(false);
            }
            int totalwin  = this.wins;
            int totallose = this.loses;

            /*if ((totalwin + totallose - KeepConcede) != 0)
             * {
             *  Helpfunctions.Instance.ErrorLog("#info: win:" + totalwin + " concede:" + KeepConcede + " lose:" + (totallose - KeepConcede) + " real winrate:" + (totalwin * 100 / (totalwin + totallose - KeepConcede)));
             * }*/



            int curlvl = HRPlayer.GetLocalPlayer().GetRank();

            if (curlvl > this.concedeLvl)
            {
                this.lossedtodo = 0;
                return(false);
            }

            if (this.oldwin != totalwin)
            {
                this.oldwin = totalwin;
                if (this.lossedtodo > 0)
                {
                    this.lossedtodo--;
                }
                Helpfunctions.Instance.ErrorLog("not today!! (you won a game)");
                this.isgoingtoconcede = true;
                return(true);
            }

            if (this.lossedtodo > 0)
            {
                this.lossedtodo--;
                Helpfunctions.Instance.ErrorLog("not today!");
                this.isgoingtoconcede = true;
                return(true);
            }

            if (curlvl < this.concedeLvl)
            {
                this.lossedtodo = 3;
                Helpfunctions.Instance.ErrorLog("your rank is " + curlvl + " targeted rank is " + this.concedeLvl + " -> concede!");
                Helpfunctions.Instance.ErrorLog("not today!!!");
                this.isgoingtoconcede = true;
                return(true);
            }
            return(false);
        }
示例#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);
        }
示例#10
0
        public PlayerState(HRPlayer Player)
        {
            this.Player       = Player;
            TauntMinions      = GetTauntMinions();
            AttackableMinions = GetAttackableMinions();
            ReadyMinions      = GetReadyMinions();
            ChargeMinions     = GetChargeMinions();

            Minions = Player.GetNumFriendlyMinionsInPlay();
            Health  = Player.GetHero().GetRemainingHP() + Player.GetHero().GetArmor();
            Mana    = Player.GetNumAvailableResources();
        }
示例#11
0
        private void printstuff()
        {
            HRPlayer ownPlayer = HRPlayer.GetLocalPlayer();

            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss") + " V" + this.versionnumber + " " + this.botbehave);
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana);
            Helpfunctions.Instance.logg("emana " + enemyMaxMana);
            Helpfunctions.Instance.logg("own secretsCount: " + ownPlayer.GetSecretDefinitions().Count);
            Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount);
        }
示例#12
0
        public PlayerState(HRPlayer Player)
        {
            this.Player       = Player;
            TauntMinions      = GetTauntMinions();
            AttackableMinions = GetAttackableMinions();
            ReadyMinions      = GetReadyMinions();
            ChargeMinions     = GetChargeMinions();
            MinionList        = GetMinionsOnField();

            Minions = MinionList.Count;
            Health  = Player.GetHero().GetRemainingHP() + Player.GetHero().GetArmor();
            Mana    = Player.GetNumAvailableResources();
        }
示例#13
0
        private List <HRCard> GetPlayableCards(List <HRCard> list)
        {
            int           manaLeft = HRPlayer.GetLocalPlayer().GetNumAvailableResources();
            List <HRCard> result   = new List <HRCard>();

            foreach (var item in list)
            {
                if (item.GetEntity().GetCost() <= manaLeft && HRBattle.CanUseCard(item.GetEntity()))
                {
                    result.Add(item);
                }
            }
            return(result);
        }
示例#14
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);
 }
示例#15
0
文件: Silverfish.cs 项目: tnd34/e
        private void printstuff(bool runEx)
        {
            HRPlayer ownPlayer      = HRPlayer.GetLocalPlayer();
            int      ownsecretcount = ownPlayer.GetSecretDefinitions().Count;
            string   dtimes         = DateTime.Now.ToString("HH:mm:ss:ffff");
            string   enemysecretIds = "";

            enemysecretIds = Probabilitymaker.Instance.getEnemySecretData();
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss") + " V" + this.versionnumber + " " + this.botbehave);
            Helpfunctions.Instance.logg("#######################################################################");
            Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana);
            Helpfunctions.Instance.logg("emana " + enemyMaxMana);
            Helpfunctions.Instance.logg("own secretsCount: " + ownsecretcount);

            Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount + " ;" + enemysecretIds);

            Ai.Instance.currentCalculatedBoard = dtimes;

            if (runEx)
            {
                Helpfunctions.Instance.resetBuffer();
                Helpfunctions.Instance.writeBufferToActionFile();
                Helpfunctions.Instance.resetBuffer();

                Helpfunctions.Instance.writeToBuffer("#######################################################################");
                Helpfunctions.Instance.writeToBuffer("#######################################################################");
                Helpfunctions.Instance.writeToBuffer("start calculations, current time: " + dtimes + " V" + this.versionnumber + " " + this.botbehave);
                Helpfunctions.Instance.writeToBuffer("#######################################################################");
                Helpfunctions.Instance.writeToBuffer("mana " + currentMana + "/" + ownMaxMana);
                Helpfunctions.Instance.writeToBuffer("emana " + enemyMaxMana);
                Helpfunctions.Instance.writeToBuffer("own secretsCount: " + ownsecretcount);
                Helpfunctions.Instance.writeToBuffer("enemy secretsCount: " + enemySecretCount + " ;" + enemysecretIds);
            }
            Hrtprozis.Instance.printHero(runEx);
            Hrtprozis.Instance.printOwnMinions(runEx);
            Hrtprozis.Instance.printEnemyMinions(runEx);
            Handmanager.Instance.printcards(runEx);
            Probabilitymaker.Instance.printTurnGraveYard(runEx);
            Probabilitymaker.Instance.printGraveyards(runEx);

            if (runEx)
            {
                Helpfunctions.Instance.writeBufferToFile();
            }
        }
示例#16
0
        protected virtual ActionBase Attack()
        {
            HREntity target = GetNextAttackToAttack();

            if (target != null)
            {
                var current = PlayerState.GetPossibleAttack(
                    HRPlayer.GetLocalPlayer(),
                    target.GetRemainingHP() + target.GetArmor());

                if (current.Cards.Count > 0)
                {
                    return(new AttackAction(current.Cards[0], target));
                }
            }

            return(null);
        }
示例#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++;
                }
            }
        }
示例#18
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);
        }
示例#19
0
        protected virtual ActionBase AttackTauntMinions(PlayerState EnemyState)
        {
            // TODO: Sort list by ATK, descending.
            if (EnemyState.TauntMinions.Count == 0)
            {
                return(null);
            }

            foreach (var item in EnemyState.TauntMinions)
            {
                if (!item.IsStealthed())
                {
                    var power = PlayerState.GetPossibleAttack(
                        HRPlayer.GetLocalPlayer(), item.GetRemainingHP());

                    if (power.Attack >= item.GetRemainingHP())
                    {
                        if (power.Cards.Count > 0)
                        {
                            return(new AttackAction(power.Cards[0], item));
                        }
                    }
                }
            }

            // There are enemy Taunts but we cannot kill at least one
            // of them. :/
            //
            // Just attack it...
            var nextTaunt = EnemyState.TauntMinions[0];

            // No taunts found that can be killed, attack first one.
            var current = PlayerState.GetPossibleAttack(
                HRPlayer.GetLocalPlayer(), nextTaunt.GetRemainingHP());

            if (current.Cards.Count > 0)
            {
                return(new AttackAction(current.Cards[0], nextTaunt));
            }
            return(null);
        }
示例#20
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);
        }
示例#21
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);
        }
示例#22
0
        private void getDecks()
        {
            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            int owncontroler   = HRPlayer.GetLocalPlayer().GetControllerId();
            int enemycontroler = HRPlayer.GetEnemyPlayer().GetControllerId();
            List <CardDB.cardIDEnum> ownCards   = new List <CardDB.cardIDEnum>();
            List <CardDB.cardIDEnum> enemyCards = new List <CardDB.cardIDEnum>();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetZone() == HRCardZone.SECRET && ent.GetControllerId() == enemycontroler)
                {
                    continue;                                                                                // cant know enemy secrets :D
                }
                if (ent.GetCardType() == HRCardType.MINION || ent.GetCardType() == HRCardType.WEAPON || ent.GetCardType() == HRCardType.ABILITY)
                {
                    CardDB.cardIDEnum cardid = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    //string owner = "own";
                    //if (ent.GetControllerId() == enemycontroler) owner = "enemy";
                    //if (ent.GetControllerId() == enemycontroler && ent.GetZone() == HRCardZone.HAND) Helpfunctions.Instance.logg("enemy card in hand: " + "cardindeck: " + cardid + " " + ent.GetName());
                    //if (cardid != CardDB.cardIDEnum.None) Helpfunctions.Instance.logg("cardindeck: " + cardid + " " + ent.GetName() + " " + ent.GetZone() + " " + owner + " " + ent.GetCardType());
                    if (cardid != CardDB.cardIDEnum.None)
                    {
                        if (ent.GetControllerId() == owncontroler)
                        {
                            ownCards.Add(cardid);
                        }
                        else
                        {
                            enemyCards.Add(cardid);
                        }
                    }
                }
            }

            Probabilitymaker.Instance.setOwnCards(ownCards);
            Probabilitymaker.Instance.setEnemyCards(enemyCards);
        }
示例#23
0
        private HREngine.API.Actions.ActionBase UpdateBattleState()
        {
            HREngine.API.Actions.ActionBase result = NextFixedAction;

            if (result != null)
            {
                NextFixedAction = null;
                return(result);
            }
            HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
            HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();

            ownPlayerController = ownPlayer.GetControllerId();//ownPlayer.GetHero().GetControllerId()

            // create hero + minion data
            getHerostuff();
            getMinions();
            getHandcards();

            // send ai the data:
            Hrtprozis.Instance.setOwnPlayer(ownPlayerController);
            Handmanager.Instance.setOwnPlayer(ownPlayerController);
            Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability, this.heroImmuneToDamageWhileAttacking, this.heroAtk, this.heroHp, this.heroDefence, this.heroname, this.ownheroisread, this.ownheroAlreadyAttacked, this.herofrozen, this.heroAbility, this.ownAbilityisReady);
            Hrtprozis.Instance.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability, this.enemyAtk, this.enemyHp, this.enemyDefence, this.enemyHeroname, this.enemyfrozen);
            Hrtprozis.Instance.updateMinions(this.ownMinions, this.enemyMinions);
            Handmanager.Instance.setHandcards(this.handCards, this.anzcards, this.enemyAnzCards);

            // print data
            Hrtprozis.Instance.printHero();
            Hrtprozis.Instance.printOwnMinions();
            Hrtprozis.Instance.printEnemyMinions();

            Handmanager.Instance.printcards();

            // Next cards to push...
            //result = PlayCardsToField();

            return(null);
        }
示例#24
0
        protected virtual HREntity GetNextAttackToAttack()
        {
            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)
            {
                return(HRPlayer.GetEnemyPlayer().GetHero());
            }

            return(result);
        }
示例#25
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++;
                }
            }
        }
示例#26
0
        private List <HRCard> getallHandCards()
        {
            List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            return(list);
        }
示例#27
0
        public PlayerState(HRPlayer Player)
        {
            this.Player = Player;
             TauntMinions = GetTauntMinions();
             AttackableMinions = GetAttackableMinions();
             ReadyMinions = GetReadyMinions();
             ChargeMinions = GetChargeMinions();
             MinionList = GetMinionsOnField();

             Minions = MinionList.Count;
             Health = Player.GetHero().GetRemainingHP() + Player.GetHero().GetArmor();
             Mana = Player.GetNumAvailableResources();
        }
示例#28
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;
        }
示例#29
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();
        }
示例#30
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);
        }
示例#31
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);
        }
示例#32
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();
        }
示例#33
0
      public PlayerState(HRPlayer Player)
      {
         this.Player = Player;
         TauntMinions = GetTauntMinions();
         AttackableMinions = GetAttackableMinions();
         ReadyMinions = GetReadyMinions();
         ChargeMinions = GetChargeMinions();

         Minions = Player.GetNumFriendlyMinionsInPlay();
         Health = Player.GetHero().GetRemainingHP() + Player.GetHero().GetArmor();
         Mana = Player.GetNumAvailableResources();
      }