Пример #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
        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());
        }
Пример #3
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);
        }
Пример #4
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++;
                }
            }
        }
Пример #5
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);
        }
Пример #6
0
        private List <HREntity> GetEnemyEntitiesOnBoard()
        {
            List <HREntity> ret = new List <HREntity>();

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

            return(ret);
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
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>();
            List <GraveYardItem>     graveYard  = new List <GraveYardItem>();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetZone() == HRCardZone.SECRET && ent.GetControllerId() == enemycontroler)
                {
                    continue;                                                                                // cant know enemy secrets :D
                }
                if (ent.GetZone() == HRCardZone.DECK)
                {
                    continue;
                }
                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.GetZone() == HRCardZone.GRAVEYARD)
                        {
                            GraveYardItem gyi = new GraveYardItem(cardid, ent.GetEntityId(), ent.GetControllerId() == owncontroler);
                            graveYard.Add(gyi);
                        }

                        int creator = ent.GetTag(HRGameTag.CREATOR);
                        if (creator != 0 && creator != owncontroler && creator != enemycontroler)
                        {
                            continue;                              //if creator is someone else, it was not played
                        }
                        if (ent.GetControllerId() == owncontroler) //or controler?
                        {
                            if (ent.GetZone() == HRCardZone.GRAVEYARD)
                            {
                                ownCards.Add(cardid);
                            }
                        }
                        else
                        {
                            if (ent.GetZone() == HRCardZone.GRAVEYARD)
                            {
                                enemyCards.Add(cardid);
                            }
                        }
                    }
                }
            }

            Probabilitymaker.Instance.setOwnCards(ownCards);
            Probabilitymaker.Instance.setEnemyCards(enemyCards);
            bool isTurnStart = false;

            if (Ai.Instance.nextMoveGuess.mana == -100)
            {
                isTurnStart = true;
                Ai.Instance.updateTwoTurnSim();
            }
            Probabilitymaker.Instance.setGraveYard(graveYard, isTurnStart);
        }
Пример #11
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);
        }
Пример #12
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);
        }
Пример #13
0
        public bool updateEverything(Behavior botbase)
        {
            this.botbehave = "rush";
            if (botbase is BehaviorControl)
            {
                this.botbehave = "control";
            }
            if (Ai.Instance.secondturnsim)
            {
                this.botbehave += " twoturnsim";
            }
            if (Ai.Instance.playaround)
            {
                this.botbehave += " playaround";
            }
            HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
            HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();

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


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

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

            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.updateSecretStuff(this.ownSecretList, this.enemySecretCount);

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

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

            Hrtprozis.Instance.updateFatigueStats(this.ownDecksize, this.ownHeroFatigue, this.enemyDecksize, this.enemyHeroFatigue);


            Playfield p = new Playfield();

            if (lastpf != null)
            {
                if (lastpf.isEqualf(p))
                {
                    return(false);
                }
                lastpf = p;
            }
            else
            {
                lastpf = p;
            }

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

            // calculate stuff



            Helpfunctions.Instance.ErrorLog("calculating stuff... " + DateTime.Now.ToString("HH:mm:ss.ffff"));
            Ai.Instance.dosomethingclever(botbase);
            Helpfunctions.Instance.ErrorLog("calculating ended! " + DateTime.Now.ToString("HH:mm:ss.ffff"));
            return(true);
        }
Пример #14
0
        private void getHerostuff()
        {
            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            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);
            this.enemyMaxMana = enemyPlayer.GetTag(HRGameTag.RESOURCES);

            enemySecretCount = HRCard.GetCards(enemyPlayer, HRCardZone.SECRET).Count;
            enemySecretCount = 0;
            //count enemy secrets
            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.IsSecret() && ent.GetControllerId() == enemyPlayer.GetControllerId() && ent.GetZone() == HRCardZone.SECRET)
                {
                    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   = 0;
            this.enemyDecksize = 0;
            //count decksize
            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetControllerId() == ownPlayer.GetControllerId() && ent.GetZone() == HRCardZone.DECK)
                {
                    ownDecksize++;
                }
                if (ent.GetControllerId() == enemyPlayer.GetControllerId() && ent.GetZone() == HRCardZone.DECK)
                {
                    enemyDecksize++;
                }
            }

            this.heroImmune      = (ownhero.GetTag(HRGameTag.CANT_BE_DAMAGED) == 1) ? true : false;
            this.enemyHeroImmune = (enemyhero.GetTag(HRGameTag.CANT_BE_DAMAGED) == 1) ? true : false;

            this.enemyHeroWeapon       = "";
            this.enemyWeaponAttack     = 0;
            this.enemyWeaponDurability = 0;
            if (enemyPlayer.HasWeapon())
            {
                HREntity weapon = enemyPlayer.GetWeaponCard().GetEntity();
                this.enemyHeroWeapon       = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(weapon.GetCardId())).name.ToString();
                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 = false;
            this.herofrozen             = ownhero.IsFrozen();
            this.heroNumAttacksThisTurn = ownhero.GetNumAttacksThisTurn();
            this.heroHasWindfury        = ownhero.HasWindfury();
            //int numberofattacks = ownhero.GetNumAttacksThisTurn();

            //Helpfunctions.Instance.ErrorLog(ownhero.GetName() + " ready params ex: " + exausted + " " + heroAtk + " " + numberofattacks + " " + herofrozen);


            if (ownPlayer.HasWeapon())
            {
                HREntity weapon = ownPlayer.GetWeaponCard().GetEntity();
                this.ownHeroWeapon                    = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(weapon.GetCardId())).name.ToString();
                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;
                }
                if (this.ownHeroWeapon == "doomhammer")
                {
                    this.heroHasWindfury = true;
                }

                //Helpfunctions.Instance.ErrorLog("weapon: " + ownHeroWeapon + " " + heroWeaponAttack + " " + heroWeaponDurability);
            }
            if (exausted)
            {
                this.ownheroisread = false;
            }

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


            //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(CardDB.Instance.cardIdstringToEnum(ownHeroAbility.GetCardId()));
            this.ownAbilityisReady = (ownHeroAbility.IsExhausted()) ? false : true; // if exhausted, ability is NOT ready

            this.enemyAbility = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(enemyhero.GetHeroPower().GetCardId()));
        }
Пример #15
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;
        }
Пример #16
0
        private void getHerostuff()
        {
            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            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);
            this.enemyMaxMana = enemyPlayer.GetTag(HRGameTag.RESOURCES);
            enemySecretCount  = HRCard.GetCards(enemyPlayer, HRCardZone.SECRET).Count;
            enemySecretCount  = 0;
            //count enemy secrets
            enemySecretList.Clear();
            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.IsSecret() && ent.GetControllerId() == enemyPlayer.GetControllerId() && ent.GetZone() == HRCardZone.SECRET)
                {
                    enemySecretCount++;
                    enemySecretList.Add(ent.GetTag(HRGameTag.ENTITY_ID));
                }
            }



            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;


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

            this.ownHeroFatigue   = ownhero.GetFatigue();
            this.enemyHeroFatigue = enemyhero.GetFatigue();

            this.ownDecksize   = 0;
            this.enemyDecksize = 0;
            //count decksize
            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetControllerId() == ownPlayer.GetControllerId() && ent.GetZone() == HRCardZone.DECK)
                {
                    ownDecksize++;
                }
                if (ent.GetControllerId() == enemyPlayer.GetControllerId() && ent.GetZone() == HRCardZone.DECK)
                {
                    enemyDecksize++;
                }
            }

            //own hero stuff###########################
            int heroAtk     = ownhero.GetATK();
            int heroHp      = ownhero.GetHealth() - ownhero.GetDamage();
            int heroDefence = ownhero.GetArmor();

            this.heroname = Hrtprozis.Instance.heroIDtoName(ownhero.GetCardId());

            bool heroImmuneToDamageWhileAttacking = false;
            bool herofrozen             = ownhero.IsFrozen();
            int  heroNumAttacksThisTurn = ownhero.GetNumAttacksThisTurn();
            bool heroHasWindfury        = ownhero.HasWindfury();
            bool heroImmune             = (ownhero.GetTag(HRGameTag.CANT_BE_DAMAGED) == 1) ? true : false;

            //Helpfunctions.Instance.ErrorLog(ownhero.GetName() + " ready params ex: " + exausted + " " + heroAtk + " " + numberofattacks + " " + herofrozen);


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

                //Helpfunctions.Instance.ErrorLog("weapon: " + ownHeroWeapon + " " + heroWeaponAttack + " " + heroWeaponDurability);
            }



            //enemy hero stuff###############################################################
            this.enemyHeroname = Hrtprozis.Instance.heroIDtoName(enemyhero.GetCardId());

            int  enemyAtk        = enemyhero.GetATK();
            int  enemyHp         = enemyhero.GetHealth() - enemyhero.GetDamage();
            int  enemyDefence    = enemyhero.GetArmor();
            bool enemyfrozen     = enemyhero.IsFrozen();
            bool enemyHeroImmune = (enemyhero.GetTag(HRGameTag.CANT_BE_DAMAGED) == 1) ? true : false;

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


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

            this.heroAbility       = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(ownHeroAbility.GetCardId()));
            this.ownAbilityisReady = (ownHeroAbility.IsExhausted()) ? false : true; // if exhausted, ability is NOT ready
            this.enemyAbility      = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(enemyhero.GetHeroPower().GetCardId()));

            //generate Heros
            this.ownHero             = new Minion();
            this.enemyHero           = new Minion();
            this.ownHero.isHero      = true;
            this.enemyHero.isHero    = true;
            this.ownHero.own         = true;
            this.enemyHero.own       = false;
            this.ownHero.maxHp       = ownhero.GetHealth();
            this.enemyHero.maxHp     = enemyhero.GetHealth();
            this.ownHero.entitiyID   = ownhero.GetEntityId();
            this.enemyHero.entitiyID = enemyhero.GetEntityId();

            this.ownHero.Angr   = heroAtk;
            this.ownHero.Hp     = heroHp;
            this.ownHero.armor  = heroDefence;
            this.ownHero.frozen = herofrozen;
            this.ownHero.immuneWhileAttacking = heroImmuneToDamageWhileAttacking;
            this.ownHero.immune             = heroImmune;
            this.ownHero.numAttacksThisTurn = heroNumAttacksThisTurn;
            this.ownHero.windfury           = heroHasWindfury;

            this.enemyHero.Angr   = enemyAtk;
            this.enemyHero.Hp     = enemyHp;
            this.enemyHero.frozen = enemyfrozen;
            this.enemyHero.armor  = enemyDefence;
            this.enemyHero.immune = enemyHeroImmune;
            this.enemyHero.Ready  = false;

            this.ownHero.updateReadyness();


            //load enchantments of the heros
            List <miniEnch> miniEnchlist = new List <miniEnch>();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetTag(HRGameTag.ATTACHED) == this.ownHero.entitiyID && ent.GetZone() == HRCardZone.PLAY)
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    int controler        = ent.GetTag(HRGameTag.CONTROLLER);
                    int creator          = ent.GetTag(HRGameTag.CREATOR);
                    miniEnchlist.Add(new miniEnch(id, creator, controler));
                }
            }

            this.ownHero.loadEnchantments(miniEnchlist, ownhero.GetTag(HRGameTag.CONTROLLER));

            ueberladung = ownhero.GetTag(HRGameTag.RECALL_OWED);//was at the start, but copied it over here :D , its german for overload :D
            //Reading new values:###################################################################################################
            //ToDo:
            this.numberMinionsDiedThisTurn = 0;// HRGameTag.NUM_MINIONS_KILLED_THIS_TURN;

            //this should work (hope i didnt oversee a value :D)
            this.ownCurrentOverload = ownhero.GetTag(HRGameTag.RECALL);
            this.enemyOverload      = enemyhero.GetTag(HRGameTag.RECALL_OWED);

            //count buffs off !!players!! (players and not heros) (like preparation, kirintor-buff and stuff)
            // hope this works, dont own these cards to test where its attached
            int owncontrollerblubb   = ownhero.GetTag(HRGameTag.CONTROLLER) + 1;   // controller = 1 or 2, but entity with 1 is the board -> +1
            int enemycontrollerblubb = enemyhero.GetTag(HRGameTag.CONTROLLER) + 1; // controller = 1 or 2, but entity with 1 is the board -> +1

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetTag(HRGameTag.ATTACHED) == owncontrollerblubb && ent.GetTag(HRGameTag.ZONE) == 1) //1==play
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    if (id == CardDB.cardIDEnum.NEW1_029t)
                    {
                        this.ownMillhouse++;
                    }
                    if (id == CardDB.cardIDEnum.FP1_030e)
                    {
                        this.ownLoathebs++;
                    }
                    if (id == CardDB.cardIDEnum.BRM_018e)
                    {
                        this.ownDragonConsort++;
                    }
                    if (id == CardDB.cardIDEnum.EX1_612o)
                    {
                        this.ownKirintor++;
                    }
                    if (id == CardDB.cardIDEnum.EX1_145o)
                    {
                        this.ownPrepa++;
                    }
                }

                if (ent.GetTag(HRGameTag.ATTACHED) == enemycontrollerblubb && ent.GetTag(HRGameTag.ZONE) == 1) //1==play
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    if (id == CardDB.cardIDEnum.NEW1_029t)
                    {
                        this.enemyMillhouse++;
                    }
                    if (id == CardDB.cardIDEnum.FP1_030e)
                    {
                        this.enemyLoathebs++;
                    }
                    if (id == CardDB.cardIDEnum.BRM_018e)
                    {
                        this.enemyDragonConsort++;
                    }
                    // not needef for enemy, because its lasting only for his turn
                    //if (id == CardDB.cardIDEnum.EX1_612o) this.enemyKirintor++;
                    //if (id == CardDB.cardIDEnum.EX1_145o) this.enemyPrepa++;
                }
            }

            //TODO test Bolvar Fordragon but it will be on his card :D
            //Reading new values end################################



            miniEnchlist.Clear();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetTag(HRGameTag.ATTACHED) == this.enemyHero.entitiyID && ent.GetZone() == HRCardZone.PLAY)
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    int controler        = ent.GetTag(HRGameTag.CONTROLLER);
                    int creator          = ent.GetTag(HRGameTag.CREATOR);
                    miniEnchlist.Add(new miniEnch(id, creator, controler));
                }
            }

            this.enemyHero.loadEnchantments(miniEnchlist, enemyhero.GetTag(HRGameTag.CONTROLLER));
            //fastmode weapon correction:
            if (ownHero.Angr < this.heroWeaponAttack)
            {
                ownHero.Angr = this.heroWeaponAttack;
            }
            if (enemyHero.Angr < this.enemyWeaponAttack)
            {
                enemyHero.Angr = this.enemyWeaponAttack;
            }
        }
Пример #17
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);
        }
Пример #18
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
        }
Пример #19
0
        protected virtual HREngine.API.Actions.ActionBase UpdateBattleState()
        {
            HREngine.API.Actions.ActionBase result = NextFixedAction;

            if (result != null)
            {
                NextFixedAction = null;
                return(result);
            }

            // If a previous action was not handled successful the Bot remains
            // in target mode.
            // Target here with 'LastTarget'. If the specified Target is null
            // the bot automatically selects the best target based on a rule
            // or enemy condition.
            if (HRBattle.IsInTargetMode())
            {
                HRLog.Write("Targeting...");
                HREntity TargetEntity = PlayCardAction.LastTarget;
                if (TargetEntity == null)
                {
                    HRCardManager.GetTargetForCard(PlayCardAction.LastPlayedCard);
                    if (TargetEntity == null)
                    {
                        TargetEntity = GetNextAttackToAttack();
                    }
                }
                return(new TargetAction(TargetEntity));
            }

            var localPlayerState = new PlayerState(HRPlayer.GetLocalPlayer());
            var enemyPlayerState = new PlayerState(HRPlayer.GetEnemyPlayer());

            // Fix: Druid: doesn't attack (and even other)
            // https://github.com/Hearthcrawler/HREngine/issues/40
            if (!localPlayerState.Player.HasWeapon() &&
                localPlayerState.Player.GetHero().CanAttack() &&
                localPlayerState.Player.GetHero().GetATK() > 0 &&
                HRBattle.CanUseCard(localPlayerState.Player.GetHero()))
            {
                return(new AttackAction(
                           localPlayerState.Player.GetHero(), GetNextAttackToAttack()));
            }

            if (!enemyPlayerState.Player.HasATauntMinion())
            {
                if (enemyPlayerState.Player.GetHero().CanBeAttacked())
                {
                    var current = PlayerState.GetPossibleAttack(
                        localPlayerState.Player, enemyPlayerState.Health);

                    if (current.Attack >= enemyPlayerState.Health)
                    {
                        if (current.Cards.Count > 0)
                        {
                            return(new AttackAction(current.Cards[0], enemyPlayerState.Player.GetHero()));
                        }
                    }
                }
            }

            if (IsDefaultHealingEnabled())
            {
                if (localPlayerState.Player.GetHero().GetClass() == HRClass.PRIEST)
                {
                    if (localPlayerState.Player.GetHeroPower().GetCost() <= localPlayerState.Mana)
                    {
                        if (localPlayerState.Health <= 17)
                        {
                            if (HRBattle.CanUseCard(localPlayerState.Player.GetHeroPower()))
                            {
                                return(new PlayCardAction(
                                           localPlayerState.Player.GetHeroPower().GetCard(),
                                           HRPlayer.GetLocalPlayer().GetHero()));
                            }
                        }
                        else
                        {
                            // FIX: Heal minions if possible
                            // https://github.com/Hearthcrawler/HREngine/issues/27
                            foreach (var item in localPlayerState.ReadyMinions)
                            {
                                if (item.GetRemainingHP() < item.GetHealth())
                                {
                                    // Heal damaged minions...
                                    if (HRBattle.CanUseCard(localPlayerState.Player.GetHeroPower()))
                                    {
                                        return(new PlayCardAction(
                                                   localPlayerState.Player.GetHeroPower().GetCard(),
                                                   HRPlayer.GetLocalPlayer().GetHero()));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Next cards to push...
            if (HRPlayer.GetLocalPlayer().GetNumFriendlyMinionsInPlay() < 7)
            {
                result = PlayCardsToField();
                if (result != null)
                {
                    return(result);
                }
                else
                {
                    // There are no cards to play..
                    if (localPlayerState.Player.GetHero().GetClass() == HRClass.WARLOCK)
                    {
                        // Can we use our hero power?
                        // Warlock should not suicide.
                        // FIX: https://github.com/Hearthcrawler/HREngine/issues/30
                        if (localPlayerState.Health >= 10)
                        {
                            // At least 3 mana left if we draw a card, okay?
                            if (localPlayerState.Player.GetHeroPower().GetCost() + 3 <= localPlayerState.Mana)
                            {
                                if (HRBattle.CanUseCard(localPlayerState.Player.GetHeroPower()))
                                {
                                    return(new PlayCardAction(localPlayerState.Player.GetHeroPower().GetCard()));
                                }
                            }
                        }
                    }
                }
            }

            // Priority: Always attack taunt minions first.
            if (enemyPlayerState.TauntMinions.Count > 0)
            {
                result = AttackTauntMinions(enemyPlayerState);
                if (result != null)
                {
                    return(result);
                }
            }

            // Bot does not attack when there is stealthed taunts
            // Fix: https://github.com/Hearthcrawler/HREngine/issues/60
            // If AttackTauntMinions() cannot attack because of stealthed - the action is null
            // and the bot should continue with default attack routine.
            //
            // Attack other minions or hero...
            result = Attack();
            if (result != null)
            {
                return(result);
            }

            // Use Hero Power that make sense at last...
            if (localPlayerState.Player.GetHeroPower().GetCost() <= localPlayerState.Mana)
            {
                switch (localPlayerState.Player.GetHero().GetClass())
                {
                case HRClass.DRUID:
                case HRClass.WARRIOR:
                case HRClass.MAGE:
                case HRClass.PALADIN:
                case HRClass.HUNTER:
                case HRClass.SHAMAN:
                case HRClass.ROGUE:
                {
                    if (HRBattle.CanUseCard(localPlayerState.Player.GetHeroPower()))
                    {
                        return(new PlayCardAction(localPlayerState.Player.GetHeroPower().GetCard()));
                    }
                }
                break;

                default:
                    break;
                }
            }

            return(null);
        }
Пример #20
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.GetNumAvailableResources();
            this.ownMaxMana  = ownPlayer.GetNumAvailableResources();//ownPlayer.GetRealTimeTempMana();

            Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana);
            this.numMinionsPlayedThisTurn = 0;
            this.cardsPlayedThisTurn      = 0;
            if (ownPlayer.HasCombo())
            {
                this.cardsPlayedThisTurn = 1;
            }
            //this.ueberladung = ownPlayer.re(GAME_TAG.RECALL_OWED);

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



            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.ownheroAlreadyAttacked = false;

            this.heroImmuneToDamageWhileAttacking = (ownhero.IsImmune()) ? true : false;
            this.herofrozen = ownhero.IsFrozen();

            int numberofattacks = ownhero.GetNumAttacksThisTurn();

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

            if (exausted == true)
            {
                this.ownheroisread          = false;
                this.ownheroAlreadyAttacked = true;
            }
            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.GetDurability();
                this.heroImmuneToDamageWhileAttacking = false;
                if (this.ownHeroWeapon == "langbogendesgladiators")
                {
                    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
        }
Пример #21
0
        private void getMinions()
        {
            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            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)
                {
                    //Helpfunctions.Instance.ErrorLog("zonepos " + zp);
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(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();
                    if (m.Hp <= 0)
                    {
                        continue;
                    }
                    m.wounded = false;
                    if (m.maxHp > m.Hp)
                    {
                        m.wounded = true;
                    }


                    m.exhausted = entitiy.IsExhausted();

                    m.taunt = (entitiy.HasTaunt()) ? 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.charge = 0;

                    if (!m.silenced && m.name == CardDB.cardName.southseadeckhand && entitiy.GetTag(HRGameTag.CHARGE) == 1)
                    {
                        m.charge = 1;
                    }
                    if (!m.silenced && m.handcard.card.Charge)
                    {
                        m.charge = 1;
                    }

                    m.zonepos = zp;

                    m.entitiyID = entitiy.GetEntityId();


                    //Helpfunctions.Instance.ErrorLog(  m.name + " ready params ex: " + m.exhausted + " charge: " +m.charge + " attcksthisturn: " + m.numAttacksThisTurn + " playedthisturn " + m.playedThisTurn );


                    List <miniEnch> enchs = new List <miniEnch>();
                    foreach (HREntity ent in allEntitys.Values)
                    {
                        if (ent.GetTag(HRGameTag.ATTACHED) == m.entitiyID && ent.GetZone() == HRCardZone.PLAY)
                        {
                            CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                            int creator          = ent.GetTag(HRGameTag.CREATOR);
                            int controler        = ent.GetTag(HRGameTag.CONTROLLER);
                            enchs.Add(new miniEnch(id, creator, controler));
                        }
                    }

                    m.loadEnchantments(enchs, entitiy.GetControllerId());



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

                    m.updateReadyness();


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

                /*
                 * if (entitiy.GetCardType() == HRCardType.WEAPON)
                 * {
                 *  //Helpfunctions.Instance.ErrorLog("found weapon!");
                 *  if (entitiy.GetControllerId() == this.ownPlayerController) // OWN weapon
                 *  {
                 *      this.ownHeroWeapon = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.GetCardId())).name.ToString();
                 *      this.heroWeaponAttack = entitiy.GetATK();
                 *      this.heroWeaponDurability = entitiy.GetDurability();
                 *      //this.heroImmuneToDamageWhileAttacking = false;
                 *
                 *
                 *  }
                 *  else
                 *  {
                 *      this.enemyHeroWeapon = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.GetCardId())).name.ToString();
                 *      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);*/
        }
Пример #22
0
        private void getHerostuff()
        {
            Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap();

            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);
            this.enemyMaxMana = enemyPlayer.GetTag(HRGameTag.RESOURCES);
            enemySecretCount  = HRCard.GetCards(enemyPlayer, HRCardZone.SECRET).Count;
            enemySecretCount  = 0;
            //count enemy secrets
            enemySecretList.Clear();
            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.IsSecret() && ent.GetControllerId() == enemyPlayer.GetControllerId() && ent.GetZone() == HRCardZone.SECRET)
                {
                    enemySecretCount++;
                    enemySecretList.Add(ent.GetTag(HRGameTag.ENTITY_ID));
                }
            }



            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   = 0;
            this.enemyDecksize = 0;
            //count decksize
            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetControllerId() == ownPlayer.GetControllerId() && ent.GetZone() == HRCardZone.DECK)
                {
                    ownDecksize++;
                }
                if (ent.GetControllerId() == enemyPlayer.GetControllerId() && ent.GetZone() == HRCardZone.DECK)
                {
                    enemyDecksize++;
                }
            }

            //own hero stuff###########################
            int heroAtk     = ownhero.GetATK();
            int heroHp      = ownhero.GetHealth() - ownhero.GetDamage();
            int heroDefence = ownhero.GetArmor();

            this.heroname = Hrtprozis.Instance.heroIDtoName(ownhero.GetCardId());

            bool heroImmuneToDamageWhileAttacking = false;
            bool herofrozen             = ownhero.IsFrozen();
            int  heroNumAttacksThisTurn = ownhero.GetNumAttacksThisTurn();
            bool heroHasWindfury        = ownhero.HasWindfury();
            bool heroImmune             = (ownhero.GetTag(HRGameTag.CANT_BE_DAMAGED) == 1) ? true : false;

            //Helpfunctions.Instance.ErrorLog(ownhero.GetName() + " ready params ex: " + exausted + " " + heroAtk + " " + numberofattacks + " " + herofrozen);


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

                //Helpfunctions.Instance.ErrorLog("weapon: " + ownHeroWeapon + " " + heroWeaponAttack + " " + heroWeaponDurability);
            }



            //enemy hero stuff###############################################################
            this.enemyHeroname = Hrtprozis.Instance.heroIDtoName(enemyhero.GetCardId());

            int  enemyAtk        = enemyhero.GetATK();
            int  enemyHp         = enemyhero.GetHealth() - enemyhero.GetDamage();
            int  enemyDefence    = enemyhero.GetArmor();
            bool enemyfrozen     = enemyhero.IsFrozen();
            bool enemyHeroImmune = (enemyhero.GetTag(HRGameTag.CANT_BE_DAMAGED) == 1) ? true : false;

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


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

            this.heroAbility       = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(ownHeroAbility.GetCardId()));
            this.ownAbilityisReady = (ownHeroAbility.IsExhausted()) ? false : true; // if exhausted, ability is NOT ready
            this.enemyAbility      = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(enemyhero.GetHeroPower().GetCardId()));

            //generate Heros
            this.ownHero             = new Minion();
            this.enemyHero           = new Minion();
            this.ownHero.isHero      = true;
            this.enemyHero.isHero    = true;
            this.ownHero.own         = true;
            this.enemyHero.own       = false;
            this.ownHero.maxHp       = ownhero.GetHealth();
            this.enemyHero.maxHp     = enemyhero.GetHealth();
            this.ownHero.entitiyID   = ownhero.GetEntityId();
            this.enemyHero.entitiyID = enemyhero.GetEntityId();

            this.ownHero.Angr   = heroAtk;
            this.ownHero.Hp     = heroHp;
            this.ownHero.armor  = heroDefence;
            this.ownHero.frozen = herofrozen;
            this.ownHero.immuneWhileAttacking = heroImmuneToDamageWhileAttacking;
            this.ownHero.immune             = heroImmune;
            this.ownHero.numAttacksThisTurn = heroNumAttacksThisTurn;
            this.ownHero.windfury           = heroHasWindfury;

            this.enemyHero.Angr   = enemyAtk;
            this.enemyHero.Hp     = enemyHp;
            this.enemyHero.frozen = enemyfrozen;
            this.enemyHero.armor  = enemyDefence;
            this.enemyHero.immune = enemyHeroImmune;
            this.enemyHero.Ready  = false;

            this.ownHero.updateReadyness();


            //load enchantments of the heros
            List <miniEnch> miniEnchlist = new List <miniEnch>();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetTag(HRGameTag.ATTACHED) == this.ownHero.entitiyID && ent.GetZone() == HRCardZone.PLAY)
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    int controler        = ent.GetTag(HRGameTag.CONTROLLER);
                    int creator          = ent.GetTag(HRGameTag.CREATOR);
                    miniEnchlist.Add(new miniEnch(id, creator, controler));
                }
            }

            this.ownHero.loadEnchantments(miniEnchlist, ownhero.GetTag(HRGameTag.CONTROLLER));

            miniEnchlist.Clear();

            foreach (HREntity ent in allEntitys.Values)
            {
                if (ent.GetTag(HRGameTag.ATTACHED) == this.enemyHero.entitiyID && ent.GetZone() == HRCardZone.PLAY)
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.GetCardId());
                    int controler        = ent.GetTag(HRGameTag.CONTROLLER);
                    int creator          = ent.GetTag(HRGameTag.CREATOR);
                    miniEnchlist.Add(new miniEnch(id, creator, controler));
                }
            }

            this.enemyHero.loadEnchantments(miniEnchlist, enemyhero.GetTag(HRGameTag.CONTROLLER));
            //fastmode weapon correction:
            if (ownHero.Angr < this.heroWeaponAttack)
            {
                ownHero.Angr = this.heroWeaponAttack;
            }
            if (enemyHero.Angr < this.enemyWeaponAttack)
            {
                enemyHero.Angr = this.enemyWeaponAttack;
            }
        }
Пример #23
0
        public bool updateEverything(Behavior botbase, bool runExtern = false, bool passiveWait = false)
        {
            this.updateBehaveString(botbase);

            HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
            HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();

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


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

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

            Hrtprozis.Instance.setOwnPlayer(ownPlayerController);
            Handmanager.Instance.setOwnPlayer(ownPlayerController);

            this.numOptionPlayedThisTurn  = 0;
            this.numOptionPlayedThisTurn += this.cardsPlayedThisTurn + this.ownHero.numAttacksThisTurn;
            foreach (Minion m in this.ownMinions)
            {
                if (m.Hp >= 1)
                {
                    this.numOptionPlayedThisTurn += m.numAttacksThisTurn;
                }
            }

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

            Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability, this.heroname, this.heroAbility, this.ownAbilityisReady, this.ownHero);
            Hrtprozis.Instance.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability, this.enemyHeroname, this.enemyMaxMana, this.enemyAbility, this.enemyHero);

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

            Hrtprozis.Instance.updateFatigueStats(this.ownDecksize, this.ownHeroFatigue, this.enemyDecksize, this.enemyHeroFatigue);

            Probabilitymaker.Instance.getEnemySecretGuesses(this.enemySecretList, Hrtprozis.Instance.heroNametoEnum(this.enemyHeroname));

            //learnmode :D

            Playfield p = new Playfield();



            if (lastpf != null)
            {
                if (lastpf.isEqualf(p))
                {
                    return(false);
                }

                //board changed we update secrets!
                //if(Ai.Instance.nextMoveGuess!=null) Probabilitymaker.Instance.updateSecretList(Ai.Instance.nextMoveGuess.enemySecretList);
                Probabilitymaker.Instance.updateSecretList(p, lastpf);
                lastpf = p;
            }
            else
            {
                lastpf = p;
            }

            p = new Playfield();//secrets have updated :D
            // calculate stuff
            Helpfunctions.Instance.ErrorLog("calculating stuff... " + DateTime.Now.ToString("HH:mm:ss.ffff"));
            if (runExtern)
            {
                Helpfunctions.Instance.logg("recalc-check###########");
                //p.printBoard();
                //Ai.Instance.nextMoveGuess.printBoard();
                if (p.isEqual(Ai.Instance.nextMoveGuess, true))
                {
                    printstuff(false);
                    Ai.Instance.doNextCalcedMove();
                }
                else
                {
                    printstuff(true);
                    readActionFile(passiveWait);
                }
            }
            else
            {
                printstuff(false);
                Ai.Instance.dosomethingclever(botbase);
            }

            Helpfunctions.Instance.ErrorLog("calculating ended! " + DateTime.Now.ToString("HH:mm:ss.ffff"));

            return(true);
        }