Пример #1
0
 private void CustomEventManager_MulliganStarted(object sender, MulliganStartedEventArgs e)
 {
     Log.InfoFormat("CustomEventManager_MulliganStarted");
     if (_realWinRate >= _winRateThreshold)
     {
         e.ConcedeSuccessfully = TritonHs.Concede(true);
     }
 }
Пример #2
0
 internal void method_4(GameOverFlag gameOverFlag_0, bool bool_0)
 {
     if (this.int_0 != this.int_1)
     {
         this.int_0 = this.int_1;
         object[] args = new object[] { this, new GameOverEventArgs(gameOverFlag_0, bool_0) };
         TritonHs.InvokeEvent(eventHandler_3, args);
     }
 }
Пример #3
0
 private void method_3(object sender, UnhandledExceptionEventArgs e)
 {
     if (e.ExceptionObject != null)
     {
         ilog_0.DebugFormat("Unhandled global exception! {0}", e.ExceptionObject.ToString());
     }
     Class12.smethod_0();
     TritonHs.smethod_1();
     Logger.OpenLogFile();
 }
Пример #4
0
        private void ButtonConcede_Click(object sender, EventArgs e)
        {
            bool success = TritonHs.Concede(true);

            if (success)
            {
                MessageBox.Show(@"Concede successfully!");
            }
            else
            {
                MessageBox.Show(@"Concede failed!");
            }
        }
Пример #5
0
        public static int getLastAffected(int entityid)
        {
            List <HSCard> allEntitys = TritonHs.GetAllCards();

            foreach (HSCard ent in allEntitys)
            {
                if (ent.GetTag(GAME_TAG.LAST_AFFECTED_BY) == entityid)
                {
                    return(ent.GetTag(GAME_TAG.ENTITY_ID));
                }
            }

            return(0);
        }
Пример #6
0
        public static int getCardTarget(int entityid)
        {
            List <HSCard> allEntitys = TritonHs.GetAllCards();

            foreach (HSCard ent in allEntitys)
            {
                if (ent.GetTag(GAME_TAG.ENTITY_ID) == entityid)
                {
                    return(ent.GetTag(GAME_TAG.CARD_TARGET));
                }
            }

            return(0);
        }
Пример #7
0
        private static void smethod_3(IBot ibot_1, BotEvent botEvent_6)
        {
            if (botEvent_6 == null)
            {
                return;
            }

            using (TritonHs.AcquireFrame())
            {
                using (TritonHs.Memory.TemporaryCacheState(false))
                {
                    botEvent_6(ibot_1);
                }
            }
        }
Пример #8
0
        private void getHandcards()
        {
            handCards.Clear();
            anzcards      = 0;
            enemyAnzCards = 0;
            List <HSCard> list = TritonHs.GetCards(CardZone.Hand);

            List <HSCard> list2 = TritonHs.GetCards(CardZone.Graveyard);

            //List<HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            foreach (HSCard entitiy in list)
            {
                if (entitiy.ZonePosition >= 1) // own handcard
                {
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.Id));
                    //c.cost = entitiy.GetCost();
                    //c.entityID = entitiy.GetEntityId();

                    var hc = new Handmanager.Handcard();
                    hc.card      = c;
                    hc.position  = entitiy.ZonePosition;
                    hc.entity    = entitiy.EntityId;
                    hc.manacost  = entitiy.Cost;
                    hc.addattack = 0;
                    if (c.name == CardDB.cardName.bolvarfordragon)
                    {
                        hc.addattack = entitiy.GetTag(GAME_TAG.ATK) - 1;
                        // -1 because it starts with 1, we count only the additional attackvalue
                    }
                    handCards.Add(hc);
                    anzcards++;
                }
            }

            List <HSCard> allcards = TritonHs.GetAllCards();

            enemyAnzCards = 0;
            foreach (HSCard hs in allcards)
            {
                if (hs.GetTag(GAME_TAG.ZONE) == 3 && hs.ControllerId != ownPlayerController &&
                    hs.GetTag(GAME_TAG.ZONE_POSITION) >= 1)
                {
                    enemyAnzCards++;
                }
            }
            // dont know if you can count the enemys-handcars in this way :D
        }
Пример #9
0
        private void getHandcards()
        {
            handCards.Clear();
            anzcards      = 0;
            enemyAnzCards = 0;
            List <HSCard> list = TritonHs.GetCards(CardZone.Hand);

            List <HSCard> list2 = TritonHs.GetCards(CardZone.Graveyard);

            //List<HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

            foreach (HSCard entitiy in list)
            {
                if (entitiy.ZonePosition >= 1) // own handcard
                {
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.Id));
                    //c.cost = entitiy.GetCost();
                    //c.entityID = entitiy.GetEntityId();

                    var hc = new Handmanager.Handcard();
                    hc.card      = c;
                    hc.position  = entitiy.ZonePosition;
                    hc.entity    = entitiy.EntityId;
                    hc.manacost  = entitiy.Cost;
                    hc.addattack = 0;
                    int attackchange = entitiy.GetTag(GAME_TAG.ATK) - c.Attack;
                    int hpchange     = entitiy.GetTag(GAME_TAG.HEALTH) - c.Health;
                    hc.addattack = attackchange;
                    hc.addHp     = hpchange;
                    handCards.Add(hc);
                    anzcards++;
                }
            }

            List <HSCard> allcards = TritonHs.GetAllCards();

            enemyAnzCards = 0;
            foreach (HSCard hs in allcards)
            {
                if (hs.GetTag(GAME_TAG.ZONE) == 3 && hs.ControllerId != ownPlayerController &&
                    hs.GetTag(GAME_TAG.ZONE_POSITION) >= 1)
                {
                    enemyAnzCards++;
                }
            }
            // dont know if you can count the enemys-handcars in this way :D
        }
Пример #10
0
        internal static void smethod_1(IBot ibot_1)
        {
            object obj2;

            try
            {
                obj2 = object_0;
                lock (obj2)
                {
                    if (bool_1)
                    {
                        return;
                    }
                    bool_1 = true;
                }
                smethod_3(ibot_1, botEvent_2);
                try
                {
                    using (TritonHs.AcquireFrame())
                    {
                        using (TritonHs.Memory.TemporaryCacheState(false))
                        {
                            TritonHs.Memory.ClearCache();
                            ibot_1.Tick();
                            TritonHs.smethod_2(false);
                        }
                    }
                }
                catch (Exception exception)
                {
                    ilog_0.Error("[Tick] Exception during execution:", exception);
                    throw;
                }
                smethod_3(ibot_1, botEvent_3);
            }
            finally
            {
                obj2 = object_0;
                lock (obj2)
                {
                    bool_1 = false;
                }
            }
        }
Пример #11
0
 private static void smethod_3(IBot ibot_1, BotEvent botEvent_6)
 {
     if (botEvent_6 != null)
     {
         try
         {
             using (TritonHs.AcquireFrame())
             {
                 using (TritonHs.Memory.TemporaryCacheState(false))
                 {
                     botEvent_6(ibot_1);
                 }
             }
         }
         catch (Exception exception)
         {
             ilog_0.Error("[Invoke] Error during execution:", exception);
             throw;
         }
     }
 }
Пример #12
0
        private void getMinions()
        {
            // ALL minions on Playfield:
            List <HSCard> list = TritonHs.GetCards(CardZone.Battlefield, true);

            list.AddRange(TritonHs.GetCards(CardZone.Battlefield, false));

            var enchantments = new List <HSCard>();

            ownMinions.Clear();
            enemyMinions.Clear();
            List <HSCard> allcards = TritonHs.GetAllCards();

            foreach (HSCard entiti in list)
            {
                int zp = entiti.GetTag(GAME_TAG.ZONE_POSITION);

                if (entiti.IsMinion && zp >= 1)
                {
                    HSCard entitiy = entiti;

                    foreach (HSCard ent in allcards)
                    {
                        if (ent.EntityId == entiti.EntityId)
                        {
                            entitiy = ent;
                            break;
                        }
                    }

                    //Helpfunctions.Instance.ErrorLog("zonepos " + zp);
                    CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.Id));
                    Minion      m = new Minion();
                    m.name          = c.name;
                    m.handcard.card = c;

                    m.Angr  = entitiy.GetTag(GAME_TAG.ATK);
                    m.maxHp = entitiy.GetTag(GAME_TAG.HEALTH);
                    m.Hp    = entitiy.GetTag(GAME_TAG.HEALTH) - entitiy.GetTag(GAME_TAG.DAMAGE);
                    if (m.Hp <= 0)
                    {
                        continue;
                    }
                    m.wounded = false;
                    if (m.maxHp > m.Hp)
                    {
                        m.wounded = true;
                    }


                    m.exhausted = (entitiy.GetTag(GAME_TAG.EXHAUSTED) == 0) ? false : true;

                    m.taunt = (entitiy.GetTag(GAME_TAG.TAUNT) == 0) ? false : true;

                    m.numAttacksThisTurn = entitiy.GetTag(GAME_TAG.NUM_ATTACKS_THIS_TURN);

                    int temp = entitiy.GetTag(GAME_TAG.NUM_TURNS_IN_PLAY);
                    m.playedThisTurn = (temp == 0) ? true : false;

                    m.windfury = (entitiy.GetTag(GAME_TAG.WINDFURY) == 0) ? false : true;

                    m.frozen = (entitiy.GetTag(GAME_TAG.FROZEN) == 0) ? false : true;

                    m.divineshild = (entitiy.GetTag(GAME_TAG.DIVINE_SHIELD) == 0) ? false : true;

                    m.stealth = (entitiy.GetTag(GAME_TAG.STEALTH) == 0) ? false : true;

                    m.poisonous = (entitiy.GetTag(GAME_TAG.POISONOUS) == 0) ? false : true;

                    m.immune = (entitiy.GetTag(GAME_TAG.IMMUNE_WHILE_ATTACKING) == 0) ? false : true;

                    m.silenced = (entitiy.GetTag(GAME_TAG.SILENCED) == 0) ? false : true;

                    // Drew: fixed | is the tag removed when silenced, via Mass Dispel?
                    m.cantBeTargetedBySpellsOrHeroPowers = (entitiy.GetTag(GAME_TAG.CANT_BE_TARGETED_BY_HERO_POWERS) == 0) ? false : true;

                    m.charge = 0;

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

                    m.zonepos = zp;

                    m.entitiyID = entitiy.EntityId;


                    //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 (HSCard ent in allcards)
                    {
                        if (ent.GetTag(GAME_TAG.ATTACHED) == m.entitiyID && ent.GetTag(GAME_TAG.ZONE) == 1) //1==play
                        {
                            CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.Id);
                            int controler        = ent.GetTag(GAME_TAG.CONTROLLER);
                            int creator          = ent.GetTag(GAME_TAG.CREATOR);
                            enchs.Add(new miniEnch(id, creator, controler));
                        }
                    }

                    m.loadEnchantments(enchs, entitiy.GetTag(GAME_TAG.CONTROLLER));

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

                    m.updateReadyness();


                    if (entitiy.GetTag(GAME_TAG.CONTROLLER) == this.ownPlayerController) // OWN minion
                    {
                        m.own = true;
                        this.ownMinions.Add(m);
                    }
                    else
                    {
                        m.own = false;
                        this.enemyMinions.Add(m);
                    }
                }
            }
        }
Пример #13
0
        private void getHerostuff()
        {
            List <HSCard> allcards = TritonHs.GetAllCards();

            HSCard ownHeroCard     = TritonHs.OurHero;
            HSCard enemHeroCard    = TritonHs.EnemyHero;
            int    ownheroentity   = TritonHs.OurHero.EntityId;
            int    enemyheroentity = TritonHs.EnemyHero.EntityId;

            foreach (HSCard ent in allcards)
            {
                if (ent.EntityId == enemyheroentity)
                {
                    enemHeroCard = ent;
                }
                if (ent.EntityId == ownheroentity)
                {
                    ownHeroCard = ent;
                }
            }

            //player stuff#########################
            //this.currentMana =ownPlayer.GetTag(HRGameTag.RESOURCES) - ownPlayer.GetTag(HRGameTag.RESOURCES_USED) + ownPlayer.GetTag(HRGameTag.TEMP_RESOURCES);
            this.currentMana  = TritonHs.CurrentMana;
            this.ownMaxMana   = TritonHs.Resources;
            this.enemyMaxMana = ownMaxMana;

            //count own secrets
            ownSecretList    = new List <string>(); // the CARDIDS of the secrets
            enemySecretCount = 0;
            //count enemy secrets:
            enemySecretList.Clear();
            foreach (HSCard ent in allcards)
            {
                if (ent.IsSecret && ent.ControllerId != ownPlayerController && ent.GetTag(GAME_TAG.ZONE) == 7)
                {
                    enemySecretCount++;
                    enemySecretList.Add(ent.GetTag(GAME_TAG.ENTITY_ID));
                }
                if (ent.IsSecret && ent.ControllerId == ownPlayerController && ent.GetTag(GAME_TAG.ZONE) == 7)
                {
                    ownSecretList.Add(ent.Id);
                }
            }


            int ourSecretsCount = ownSecretList.Count;

            numMinionsPlayedThisTurn = TritonHs.NumMinionsPlayedThisTurn;
            cardsPlayedThisTurn      = TritonHs.NumCardsPlayedThisTurn;


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

            this.ownHeroFatigue   = ownHeroCard.GetTag(GAME_TAG.FATIGUE);
            this.enemyHeroFatigue = enemHeroCard.GetTag(GAME_TAG.FATIGUE);

            this.ownDecksize   = 0;
            this.enemyDecksize = 0;
            //count decksize
            foreach (HSCard ent in allcards)
            {
                if (ent.ControllerId == ownPlayerController && ent.GetTag(GAME_TAG.ZONE) == 2)
                {
                    ownDecksize++;
                }
                if (ent.ControllerId != ownPlayerController && ent.GetTag(GAME_TAG.ZONE) == 2)
                {
                    enemyDecksize++;
                }
            }

            //own hero stuff###########################
            int heroAtk     = ownHeroCard.GetTag(GAME_TAG.ATK);
            int heroHp      = ownHeroCard.GetTag(GAME_TAG.HEALTH) - ownHeroCard.GetTag(GAME_TAG.DAMAGE);
            int heroDefence = ownHeroCard.GetTag(GAME_TAG.ARMOR);

            this.heroname = Hrtprozis.Instance.heroIDtoName(TritonHs.OurHero.Id);

            bool heroImmuneToDamageWhileAttacking = false;
            bool herofrozen             = (ownHeroCard.GetTag(GAME_TAG.FROZEN) == 0) ? false : true;
            int  heroNumAttacksThisTurn = ownHeroCard.GetTag(GAME_TAG.NUM_ATTACKS_THIS_TURN);
            bool heroHasWindfury        = (ownHeroCard.GetTag(GAME_TAG.WINDFURY) == 0) ? false : true;
            bool heroImmune             = (ownHeroCard.GetTag(GAME_TAG.CANT_BE_DAMAGED) == 0) ? false : true;

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


            if (TritonHs.DoWeHaveWeapon)
            {
                HSCard weapon = TritonHs.OurWeaponCard;
                ownHeroWeapon =
                    CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(weapon.Id)).name.ToString();
                heroWeaponAttack     = weapon.GetTag(GAME_TAG.ATK);
                heroWeaponDurability = weapon.GetTag(GAME_TAG.DURABILITY) - weapon.GetTag(GAME_TAG.DAMAGE);
                //weapon.GetDurability();
                if (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(TritonHs.EnemyHero.Id);

            int  enemyAtk        = enemHeroCard.GetTag(GAME_TAG.ATK); //lol should be zero :D
            int  enemyHp         = enemHeroCard.GetTag(GAME_TAG.HEALTH) - enemHeroCard.GetTag(GAME_TAG.DAMAGE);
            int  enemyDefence    = enemHeroCard.GetTag(GAME_TAG.ARMOR);
            bool enemyfrozen     = (enemHeroCard.GetTag(GAME_TAG.FROZEN) == 0) ? false : true;
            bool enemyHeroImmune = (enemHeroCard.GetTag(GAME_TAG.CANT_BE_DAMAGED) == 0) ? false : true;

            this.enemyHeroWeapon       = "";
            this.enemyWeaponAttack     = 0;
            this.enemyWeaponDurability = 0;
            if (TritonHs.DoesEnemyHasWeapon)
            {
                HSCard weapon = TritonHs.EnemyWeaponCard;
                enemyHeroWeapon =
                    CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(weapon.Id)).name.ToString();
                enemyWeaponAttack     = weapon.GetTag(GAME_TAG.ATK);
                enemyWeaponDurability = weapon.GetTag(GAME_TAG.DURABILITY) - weapon.GetTag(GAME_TAG.DAMAGE);
            }


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

            this.heroAbility =
                CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(TritonHs.OurHeroPowerCard.Id));
            this.ownAbilityisReady = (TritonHs.OurHeroPowerCard.GetTag(GAME_TAG.EXHAUSTED) == 0) ? true : false;
            this.enemyAbility      =
                CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(TritonHs.OurHeroPowerCard.Id));
            int ownHeroAbilityEntity = TritonHs.OurHeroPowerCard.EntityId;

            foreach (HSCard ent in allcards)
            {
                if (ent.EntityId != ownHeroAbilityEntity && ent.GetTag(GAME_TAG.CARDTYPE) == 10)
                {
                    enemyAbility = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(ent.Id));
                    break;
                }
            }

            //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       = ownHeroCard.GetTag(GAME_TAG.HEALTH);
            this.enemyHero.maxHp     = enemHeroCard.GetTag(GAME_TAG.HEALTH);
            this.ownHero.entitiyID   = ownHeroCard.EntityId;
            this.enemyHero.entitiyID = enemHeroCard.EntityId;

            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 (HSCard ent in allcards)
            {
                if (ent.GetTag(GAME_TAG.ATTACHED) == this.ownHero.entitiyID && ent.GetTag(GAME_TAG.ZONE) == 1) //1==play
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.Id);
                    int controler        = ent.GetTag(GAME_TAG.CONTROLLER);
                    int creator          = ent.GetTag(GAME_TAG.CREATOR);
                    miniEnchlist.Add(new miniEnch(id, creator, controler));
                }
            }

            this.ownHero.loadEnchantments(miniEnchlist, ownHeroCard.GetTag(GAME_TAG.CONTROLLER));


            ueberladung = TritonHs.RecallOwed;//was at the start, but copied it over here :D , its german for overload :D
            //Reading new values:###################################################################################################
            //ToDo:
            this.numberMinionsDiedThisTurn = 0;// GameTag.NUM_MINIONS_KILLED_THIS_TURN;

            //this should work (hope i didnt oversee a value :D)
            //THIS IS WRONG CHANGE THIS (should be the ownPLAYER and enemyPLAYER
            this.ownCurrentOverload = ownHeroCard.GetTag(GAME_TAG.RECALL);
            this.enemyOverload      = enemHeroCard.GetTag(GAME_TAG.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   = ownHeroCard.GetTag(GAME_TAG.CONTROLLER) + 1;  // controller = 1 or 2, but entity with 1 is the board -> +1
            int enemycontrollerblubb = enemHeroCard.GetTag(GAME_TAG.CONTROLLER) + 1; // controller = 1 or 2, but entity with 1 is the board -> +1

            foreach (HSCard ent in allcards)
            {
                if (ent.GetTag(GAME_TAG.ATTACHED) == owncontrollerblubb && ent.GetTag(GAME_TAG.ZONE) == 1) //1==play
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.Id);
                    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(GAME_TAG.ATTACHED) == enemycontrollerblubb && ent.GetTag(GAME_TAG.ZONE) == 1) //1==play
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.Id);
                    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 (HSCard ent in allcards)
            {
                if (ent.GetTag(GAME_TAG.ATTACHED) == this.enemyHero.entitiyID && ent.GetTag(GAME_TAG.ZONE) == 1)
                //1==play
                {
                    CardDB.cardIDEnum id = CardDB.Instance.cardIdstringToEnum(ent.Id);
                    int controler        = ent.GetTag(GAME_TAG.CONTROLLER);
                    int creator          = ent.GetTag(GAME_TAG.CREATOR);
                    miniEnchlist.Add(new miniEnch(id, creator, controler));
                }
            }

            this.enemyHero.loadEnchantments(miniEnchlist, enemHeroCard.GetTag(GAME_TAG.CONTROLLER));
            //fastmode weapon correction:
            if (this.ownHero.Angr < this.heroWeaponAttack)
            {
                this.ownHero.Angr = this.heroWeaponAttack;
            }
            if (this.enemyHero.Angr < this.enemyWeaponAttack)
            {
                this.enemyHero.Angr = this.enemyWeaponAttack;
            }
        }
Пример #14
0
 internal void method_7()
 {
     object[] args = new object[] { this, new FatalErrorEventArgs() };
     TritonHs.InvokeEvent(eventHandler_7, args);
 }
Пример #15
0
 internal void method_6()
 {
     object[] args = new object[] { this, new CustomDecksCachedEventArgs() };
     TritonHs.InvokeEvent(eventHandler_6, args);
 }
Пример #16
0
        private static void smethod_4()
        {
            object obj = object_0;

            lock (obj)
            {
                Thread.Sleep(1);
            }
            TritonHs.Memory.DisableCache();
            TritonHs.Memory.ClearCache();
            TritonHs.Memory.Executor.FrameDropWaitTime = 15000u;
            TritonHs.Memory.Executor.ExecuteWaitTime   = 15000;
            try
            {
                TritonHs.smethod_2();
            }
            catch
            {
            }
            try
            {
                smethod_0(CurrentBot);
                goto IL_FA;
            }
            catch
            {
                autoResetEvent_0.Set();
                goto IL_FA;
            }
IL_87:
            try
            {
                if (MsBeforeNextTick != 0)
                {
                    Thread.Sleep(MsBeforeNextTick);
                    MsBeforeNextTick = 0;
                }
                smethod_1(CurrentBot);
                bool_3 = false;
                if (MsBetweenTicks != 0)
                {
                    Thread.Sleep(MsBetweenTicks);
                }
            }
            catch (InjectionDesyncException)
            {
                //BotManager.ilog_0.DebugFormat("[BotThreadFunction] An InjectionDesyncException was detected.", Array.Empty<object>());
                bool_3 = true;
                TritonHs.InvokeEvent(eventHandler_1, null, new ClientFrozenEventArgs());
            }
            catch
            {
            }
IL_FA:
            if (!autoResetEvent_0.WaitOne(0))
            {
                goto IL_87;
            }
            try
            {
                smethod_2(CurrentBot);
            }
            catch
            {
            }
            BotThread = null;
            if (bool_3)
            {
                TritonHs.InvokeEvent(eventHandler_1, null, new ClientFrozenEventArgs());
                return;
            }
            try
            {
                TritonHs.smethod_2();
            }
            catch
            {
            }
        }
Пример #17
0
        internal static void smethod_3()
        {
            State = StateEnum.None;
            string[] strArray = string_0;
            int      index    = 0;

            while (true)
            {
                if (index >= strArray.Length)
                {
                    break;
                }
                string path = strArray[index];
                try
                {
                    File.Delete(path);
                }
                catch
                {
                }
                index++;
            }
            ExternalProcessMemory memory = ExternalProcessMemory_0;

            intptr_1 = memory.GetProcAddress("user32.dll", "GetActiveWindow");
            if (intptr_1 == IntPtr.Zero)
            {
                throw new Exception("The function 'GetActiveWindow' was not found.");
            }
            intptr_0 = memory.GetProcAddress("user32.dll", "GetForegroundWindow");
            if (intptr_0 == IntPtr.Zero)
            {
                throw new Exception("The function 'GetForegroundWindow' was not found.");
            }
            intptr_2 = memory.GetProcAddress("user32.dll", "GetKeyState");
            if (intptr_2 == IntPtr.Zero)
            {
                throw new Exception("The function 'GetKeyState' was not found.");
            }
            intptr_3 = memory.GetProcAddress("user32.dll", "GetCursorPos");
            if (intptr_3 == IntPtr.Zero)
            {
                throw new Exception("The function 'GetCursorPos' was not found.");
            }
            intptr_4 = memory.GetProcAddress("user32.dll", "ScreenToClient");
            if (intptr_4 == IntPtr.Zero)
            {
                throw new Exception("The function 'ScreenToClient' was not found.");
            }
            allocatedMemory_0 = memory.CreateAllocatedMemory(0x1000);
            List <byte[]> list = smethod_1();

            if (list != null)
            {
                using (TritonHs.AcquireFrame())
                {
                    ExternalProcessMemory_0.WriteBytes(intptr_0, list[0]);
                    ExternalProcessMemory_0.WriteBytes(intptr_1, list[1]);
                    ExternalProcessMemory_0.WriteBytes(intptr_2, list[2]);
                    ExternalProcessMemory_0.WriteBytes(intptr_3, list[3]);
                    ExternalProcessMemory_0.WriteBytes(intptr_4, list[4]);
                }
            }
            bool flag = false;

            try
            {
                int         offsetInBytes = 0;
                IntPtr      ptr           = IntPtr_0;
                ManagedFasm asm           = memory.Asm;
                asm.Clear();
                asm.AddLine("mov eax, " + ptr.ToString());
                asm.AddLine("retn");
                byte[] bytes = asm.Assemble();
                asm.Clear();
                allocatedMemory_0.WriteBytes(0, bytes);
                IntPtr ptr2 = allocatedMemory_0.Address + IntPtr.Zero;
                ptr2 = allocatedMemory_0.Address + IntPtr.Zero;
                int num3 = (ptr2.ToInt32() - intptr_1.ToInt32()) - 5;
                offsetInBytes = 0 + bytes.Length;
                byte_0        = new byte[5];
                byte_0[0]     = 0xe9;
                byte[] buffer2 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_0.ToInt32()) - 5));
                for (int i = 0; i < buffer2.Length; i++)
                {
                    byte_0[i + 1] = buffer2[i];
                }
                byte_1    = new byte[5];
                byte_1[0] = 0xe9;
                byte[] buffer3 = BitConverter.GetBytes(num3);
                for (int j = 0; j < buffer3.Length; j++)
                {
                    byte_1[j + 1] = buffer3[j];
                }
                memory.Patches.Create(intptr_0, byte_0, "ProcessHookManager_GetForegroundWindow");
                memory.Patches.Create(intptr_1, byte_1, "ProcessHookManager_GetActiveWindow");
                byte[] buffer4 = new byte[0x400];
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer4);
                IntPtr ptr3 = allocatedMemory_0.Address + offsetInBytes;
                int_0          = offsetInBytes;
                offsetInBytes += 0x400;
                byte[] buffer5 = new byte[8];
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer5);
                IntPtr ptr4 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                IntPtr ptr5 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                ManagedFasm fasm = memory.Asm;
                fasm.Clear();
                fasm.AddLine("pop eax");
                object[] args = new object[] { ptr4 };
                fasm.AddLine("mov [{0}], eax", args);
                fasm.AddLine("pop eax");
                object[] objArray2 = new object[] { ptr5 };
                fasm.AddLine("mov [{0}], eax", objArray2);
                fasm.AddLine("imul eax, 4");
                object[] objArray3 = new object[] { ptr3 };
                fasm.AddLine("add eax, {0}", objArray3);
                fasm.AddLine("mov eax, [eax]");
                object[] objArray4 = new object[] { ptr4 };
                fasm.AddLine("pushd [{0}]", objArray4);
                fasm.AddLine("retn");
                byte[] buffer6 = fasm.Assemble();
                fasm.Clear();
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer6);
                ptr2           = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += buffer6.Length;
                byte_2         = new byte[5];
                byte_2[0]      = 0xe9;
                byte[] buffer7 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_2.ToInt32()) - 5));
                for (int k = 0; k < buffer7.Length; k++)
                {
                    byte_2[k + 1] = buffer7[k];
                }
                memory.Patches.Create(intptr_2, byte_2, "ProcessHookManager_GetKeyState");
                byte[] buffer8 = new byte[12];
                buffer8[8] = 1;
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer8);
                IntPtr ptr6 = allocatedMemory_0.Address + offsetInBytes;
                int_1          = offsetInBytes;
                offsetInBytes += 4;
                int_2          = offsetInBytes;
                offsetInBytes += 4;
                int_3          = offsetInBytes;
                offsetInBytes += 4;
                byte[] buffer9 = new byte[8];
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer9);
                IntPtr ptr7 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                IntPtr ptr8 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                ManagedFasm fasm2 = memory.Asm;
                fasm2.Clear();
                fasm2.AddLine("pop eax");
                object[] objArray5 = new object[] { ptr7 };
                fasm2.AddLine("mov [{0}], eax", objArray5);
                fasm2.AddLine("pop eax");
                object[] objArray6 = new object[] { ptr8 };
                fasm2.AddLine("mov [{0}], eax", objArray6);
                fasm2.AddLine("push ecx");
                object[] objArray7 = new object[] { ptr6 };
                fasm2.AddLine("mov ecx, {0}", objArray7);
                fasm2.AddLine("mov ecx, [ecx]");
                fasm2.AddLine("mov [eax], ecx");
                fasm2.AddLine("add eax, 4");
                object[] objArray8 = new object[] { ptr6 };
                fasm2.AddLine("mov ecx, {0}", objArray8);
                fasm2.AddLine("add ecx, 4");
                fasm2.AddLine("mov ecx, [ecx]");
                fasm2.AddLine("mov [eax], ecx");
                object[] objArray9 = new object[] { ptr6 };
                fasm2.AddLine("mov ecx, {0}", objArray9);
                fasm2.AddLine("add ecx, 8");
                fasm2.AddLine("mov eax, [ecx]");
                fasm2.AddLine("pop ecx");
                object[] objArray10 = new object[] { ptr7 };
                fasm2.AddLine("pushd [{0}]", objArray10);
                fasm2.AddLine("retn");
                byte[] buffer10 = fasm2.Assemble();
                fasm2.Clear();
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer10);
                ptr2           = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += buffer10.Length;
                byte_3         = new byte[5];
                byte_3[0]      = 0xe9;
                byte[] buffer11 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_3.ToInt32()) - 5));
                for (int m = 0; m < buffer11.Length; m++)
                {
                    byte_3[m + 1] = buffer11[m];
                }
                memory.Patches.Create(intptr_3, byte_3, "ProcessHookManager_GetCursorPos");
                byte[] buffer12 = new byte[12];
                buffer12[8] = 1;
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer12);
                IntPtr ptr9 = allocatedMemory_0.Address + offsetInBytes;
                int_4          = offsetInBytes;
                offsetInBytes += 4;
                int_5          = offsetInBytes;
                offsetInBytes += 4;
                int_6          = offsetInBytes;
                offsetInBytes += 4;
                byte[] buffer13 = new byte[12];
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer13);
                IntPtr ptr10 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                IntPtr ptr11 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                IntPtr ptr12 = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += 4;
                ManagedFasm fasm3 = memory.Asm;
                fasm3.Clear();
                fasm3.AddLine("pop eax");
                object[] objArray11 = new object[] { ptr10 };
                fasm3.AddLine("mov [{0}], eax", objArray11);
                fasm3.AddLine("pop eax");
                object[] objArray12 = new object[] { ptr11 };
                fasm3.AddLine("mov [{0}], eax", objArray12);
                fasm3.AddLine("pop eax");
                object[] objArray13 = new object[] { ptr12 };
                fasm3.AddLine("mov [{0}], eax", objArray13);
                fasm3.AddLine("push ecx");
                object[] objArray14 = new object[] { ptr9 };
                fasm3.AddLine("mov ecx, {0}", objArray14);
                fasm3.AddLine("mov ecx, [ecx]");
                fasm3.AddLine("mov [eax], ecx");
                fasm3.AddLine("add eax, 4");
                object[] objArray15 = new object[] { ptr9 };
                fasm3.AddLine("mov ecx, {0}", objArray15);
                fasm3.AddLine("add ecx, 4");
                fasm3.AddLine("mov ecx, [ecx]");
                fasm3.AddLine("mov [eax], ecx");
                object[] objArray16 = new object[] { ptr9 };
                fasm3.AddLine("mov ecx, {0}", objArray16);
                fasm3.AddLine("add ecx, 8");
                fasm3.AddLine("mov eax, [ecx]");
                fasm3.AddLine("pop ecx");
                object[] objArray17 = new object[] { ptr10 };
                fasm3.AddLine("pushd [{0}]", objArray17);
                fasm3.AddLine("retn");
                byte[] buffer14 = fasm3.Assemble();
                fasm3.Clear();
                allocatedMemory_0.WriteBytes(offsetInBytes, buffer14);
                ptr2           = allocatedMemory_0.Address + offsetInBytes;
                offsetInBytes += buffer14.Length;
                byte_4         = new byte[5];
                byte_4[0]      = 0xe9;
                byte[] buffer15 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_4.ToInt32()) - 5));
                for (int n = 0; n < buffer15.Length; n++)
                {
                    byte_4[n + 1] = buffer15[n];
                }
                memory.Patches.Create(intptr_4, byte_4, "ProcessHookManager_ScreenToClient");
                smethod_2();
            }
            catch (Exception)
            {
                flag = true;
                throw;
            }
            finally
            {
                if (flag && (allocatedMemory_0 != null))
                {
                    allocatedMemory_0.Dispose();
                    allocatedMemory_0 = null;
                }
            }
        }
Пример #18
0
 internal void method_1()
 {
     object[] args = new object[] { this, new MulliganConfirmEventArgs() };
     TritonHs.InvokeEvent(eventHandler_4, args);
 }
Пример #19
0
 protected override void OnExit(ExitEventArgs e)
 {
     Class12.smethod_0();
     TritonHs.smethod_1();
     base.OnExit(e);
 }
Пример #20
0
        private void getDecks()
        {
            List <HSCard> allEntitys     = TritonHs.GetAllCards();
            int           owncontroler   = TritonHs.OurHero.GetTag(GAME_TAG.CONTROLLER);
            int           enemycontroler = TritonHs.EnemyHero.GetTag(GAME_TAG.CONTROLLER);


            /*var wer = TritonHs.OurHero.ControllerId;
             * using (TritonHs.AcquireFrame())
             * {
             *  foreach (var kvp in CollectionManager.Get().GetDecks())
             *  {
             *      var eee = kvp.Key;
             *      var eed = kvp.Value.m_name;
             *      var deck = CollectionManager.Get().GetDeck(kvp.Key);
             *      if (deck.m_netContentsLoaded == false)
             *      {
             *          var ffs = 1;
             *      }
             *      foreach (var slot in deck.GetSlots())
             *      {
             *          var ddsee = slot.m_cardId;
             *      }
             *  }
             * }*/



            List <CardDB.cardIDEnum> ownCards   = new List <CardDB.cardIDEnum>();
            List <CardDB.cardIDEnum> enemyCards = new List <CardDB.cardIDEnum>();
            List <GraveYardItem>     graveYard  = new List <GraveYardItem>();

            foreach (HSCard ent in allEntitys)
            {
                if (ent.GetTag(GAME_TAG.ZONE) == 7 && ent.GetTag(GAME_TAG.CONTROLLER) == enemycontroler)
                {
                    continue; // cant know enemy secrets :D
                }
                if (ent.GetTag(GAME_TAG.ZONE) == 2)
                {
                    continue;
                }
                if (ent.GetTag(GAME_TAG.CARDTYPE) == 4 || ent.GetTag(GAME_TAG.CARDTYPE) == 5 ||
                    ent.GetTag(GAME_TAG.CARDTYPE) == 7) //is minion, weapon or spell
                {
                    CardDB.cardIDEnum cardid = CardDB.Instance.cardIdstringToEnum(ent.Id);
                    //Helpfunctions.Instance.logg("found " + cardid);

                    if (ent.GetTag(GAME_TAG.ZONE) == 4) // 4 == graveyard
                    {
                        GraveYardItem gyi = new GraveYardItem(cardid, ent.EntityId,
                                                              ent.GetTag(GAME_TAG.CONTROLLER) == owncontroler);
                        graveYard.Add(gyi);
                    }

                    int creator = ent.GetTag(GAME_TAG.CREATOR);
                    if (creator != 0 && creator != owncontroler && creator != enemycontroler)
                    {
                        continue; //if creator is someone else, it was not played
                    }
                    if (ent.GetTag(GAME_TAG.CONTROLLER) == owncontroler)
                    {
                        if (ent.GetTag(GAME_TAG.ZONE) == 4) // 4 == graveyard
                        {
                            ownCards.Add(cardid);
                        }
                    }
                    else
                    {
                        if (ent.GetTag(GAME_TAG.ZONE) == 4) // 4 == 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);
        }
Пример #21
0
 internal void method_2()
 {
     object[] args = new object[] { this, new QuestUpdateEventArgs() };
     TritonHs.InvokeEvent(eventHandler_1, args);
 }
Пример #22
0
        private static void smethod_4()
        {
            object obj2 = object_0;

            lock (obj2)
            {
                Thread.Sleep(1);
            }
            TritonHs.Memory.DisableCache();
            TritonHs.Memory.ClearCache();
            TritonHs.Memory.Executor.FrameDropWaitTime = 0x3a98;
            TritonHs.Memory.Executor.ExecuteWaitTime   = 0x3a98;
            try
            {
                TritonHs.smethod_2(true);
            }
            catch
            {
            }
            try
            {
                smethod_0(CurrentBot);
                goto Label_00DF;
            }
            catch
            {
                autoResetEvent_0.Set();
                goto Label_00DF;
            }
            Label_0084 :;
            try
            {
                if (MsBeforeNextTick != 0)
                {
                    Thread.Sleep(MsBeforeNextTick);
                    MsBeforeNextTick = 0;
                }
                smethod_1(CurrentBot);
                if (MsBetweenTicks != 0)
                {
                    Thread.Sleep(MsBetweenTicks);
                }
                bool_3 = false;
            }
            catch (InjectionDesyncException)
            {
                ilog_0.DebugFormat("[BotThreadFunction] An InjectionDesyncException was detected.", Array.Empty <object>());
                bool_3 = true;
                goto Label_00EC;
            }
            catch
            {
            }
Label_00DF:
            if (!autoResetEvent_0.WaitOne(0))
            {
                goto Label_0084;
            }
            Label_00EC :;
            try
            {
                smethod_2(CurrentBot);
            }
            catch
            {
            }
            BotThread = null;
            if (bool_3)
            {
                object[] args = new object[2];
                args[1] = new ClientFrozenEventArgs();
                TritonHs.InvokeEvent(eventHandler_1, args);
            }
            else
            {
                try
                {
                    TritonHs.smethod_2(true);
                }
                catch
                {
                }
            }
        }
Пример #23
0
        private static void smethod_2()
        {
            List <Class239> source = smethod_0();

            if (!source.Any <Class239>((Class240.< > 9__36_0 ?? (Class240.< > 9__36_0 = new Func <Class239, bool>(Class240.< > 9.method_1)))))
            {
                Class239 item = new Class239 {
                    int_0  = ExternalProcessMemory_0.Process.Id,
                    list_0 = new List <byte[]>()
                };
                ExternalProcessMemory memory = ExternalProcessMemory_0;
                using (TritonHs.AcquireFrame())
                {
                    item.list_0.Add(memory.Patches["ProcessHookManager_GetForegroundWindow"].OriginalBytes);
                    item.list_0.Add(memory.Patches["ProcessHookManager_GetActiveWindow"].OriginalBytes);
                    item.list_0.Add(memory.Patches["ProcessHookManager_GetKeyState"].OriginalBytes);
                    item.list_0.Add(memory.Patches["ProcessHookManager_GetCursorPos"].OriginalBytes);
                    item.list_0.Add(memory.Patches["ProcessHookManager_ScreenToClient"].OriginalBytes);
                }
                source.Add(item);
                Class239[] classArray = source.ToArray();
                int        index      = 0;
                while (true)
                {
                    if (index >= classArray.Length)
                    {
                        break;
                    }
                    Class239 class3 = classArray[index];
                    try
                    {
                        Process processById = Process.GetProcessById(class3.int_0);
                        try
                        {
                            if (!processById.ProcessName.ToLowerInvariant().Contains("hearthstone"))
                            {
                                source.Remove(class3);
                            }
                        }
                        catch
                        {
                            source.Remove(class3);
                        }
                    }
                    catch (ArgumentException)
                    {
                        source.Remove(class3);
                    }
                    index++;
                }
                using (FileStream stream = File.Create(String_0))
                {
                    using (BinaryWriter writer = new BinaryWriter(stream))
                    {
                        writer.Write(source.Count);
                        foreach (Class239 class4 in source)
                        {
                            writer.Write(class4.int_0);
                            writer.Write(class4.list_0.Count);
                            foreach (byte[] buffer in class4.list_0)
                            {
                                writer.Write(buffer.Length);
                                writer.Write(buffer);
                            }
                        }
                    }
                }
            }
        }
Пример #24
0
 internal void method_3(List <RewardData> list_0)
 {
     object[] args = new object[] { this, new ArenaRewardsEventArgs(list_0) };
     TritonHs.InvokeEvent(eventHandler_2, args);
 }
Пример #25
0
        private void GameEventManagerOnStartingNewGame(object sender, StartingNewGameEventArgs startingNewGameEventArgs)
        {
            var usableDecks = QuestSettings.Instance.UsableDecks;

            if (_findNewQuest)
            {
                var quests = TritonHs.CurrentQuests;

                // Remove Tavern Brawl quest and spectate.
                quests = quests.Where(q => q.Id != 222 && q.Id != 214).ToList();

                // No quests to do, not much else for this plugin to mess with.
                if (!quests.Any())
                {
                    // Stop the bot if the user wants it.
                    if (QuestSettings.Instance.StopAfterAllQuestsAreDone)
                    {
                        Log.ErrorFormat(
                            "[日常任务插件] Now stopping the bot, because there are no quests to complete and [StopAfterAllQuestsAreDone] is enabled.");
                        BotManager.Stop();
                        return;
                    }

                    _findNewQuest = false;

                    if (usableDecks.Any())
                    {
                        // Choose a random deck. We can add more logic for selection later...
                        var rngDeck =
                            usableDecks[
                                Client.Random.Next(0, usableDecks.Count)];

                        Log.InfoFormat("[Quest] Now choosing a random custom deck to play with since all quests are done.");

                        DefaultBotSettings.Instance.ConstructedCustomDeck = rngDeck.Name;
                        if (rngDeck.IsWild)
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.狂野模式;
                        }
                        else
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.标准模式;
                        }
                    }
                    return;
                }

                var foundQuest = false;

                // First, look for a quest to complete with a custom deck. We want to use custom decks to complete quests first,
                // before trying to use a basic deck (which is why this logic is two parts).
                foreach (var quest in quests)
                {
                    // Loop through for each each class.
                    foreach (var @class in TritonHs.BasicHeroTagClasses)
                    {
                        // If this is a class specific quest, find a suitable deck. Otherwise,
                        // just use a random custom deck.
                        if (TritonHs.IsQuestForSpecificClass(quest.Id))
                        {
                            // If this quest is a win quest for this class.
                            if (TritonHs.IsQuestForClass(quest.Id, @class))
                            {
                                // Check to see if we have a custom deck to complete it with.
                                var cardId = TritonHs.GetBasicHeroCardIdFromClass(@class);
                                var decks  =
                                    usableDecks.Where(d => d.HeroCardId == cardId).ToList();
                                if (decks.Any())
                                {
                                    // Choose a random deck. We can add more logic for selection later...
                                    var deck = decks[Client.Random.Next(0, decks.Count)];

                                    Log.InfoFormat(
                                        "[Quest] Now choosing a random compatible deck to complete the class specific quest [{0}] with.",
                                        quest.Name);

                                    DefaultBotSettings.Instance.ConstructedCustomDeck = deck.Name;
                                    if (deck.IsWild)
                                    {
                                        DefaultBotSettings.Instance.ConstructedGameRule = GameRule.狂野模式;
                                    }
                                    else
                                    {
                                        DefaultBotSettings.Instance.ConstructedGameRule = GameRule.标准模式;
                                    }

                                    foundQuest = true;

                                    break;
                                }
                            }
                        }
                    }

                    // If we found a quest and changed bot settings, we're done.
                    if (foundQuest)
                    {
                        break;
                    }

                    // Make sure we have a non-class quest to choose a random deck for.
                    // Also make sure we have custom decks in the first place.

                    var filterDecks = usableDecks;
                    if (quest.Id == 341 || quest.Id == 340)
                    {
                        filterDecks = filterDecks.Where(d => !d.IsWild).ToList();
                    }

                    if (!TritonHs.IsQuestForSpecificClass(quest.Id) && filterDecks.Any())
                    {
                        // Choose a random deck. We can add more logic for selection later...
                        var rngDeck = filterDecks[Client.Random.Next(0, filterDecks.Count)];

                        Log.InfoFormat(
                            "[Quest] Now choosing a random compatible deck to complete the non-class specific quest [{0}] with.",
                            quest.Name);

                        DefaultBotSettings.Instance.ConstructedCustomDeck = rngDeck.Name;
                        if (rngDeck.IsWild)
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.狂野模式;
                        }
                        else
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.标准模式;
                        }

                        foundQuest = true;

                        break;
                    }
                }

                // All done? For now, yes.
                if (foundQuest)
                {
                    _findNewQuest = false;
                    return;
                }

                Log.ErrorFormat(
                    "[日常任务插件] 现在停止挂机, 本卡组的任务已经完成.");
                BotManager.Stop();
            }
        }
Пример #26
0
 internal void method_5()
 {
     object[] args = new object[] { this, new StartingNewGameEventArgs() };
     TritonHs.InvokeEvent(eventHandler_5, args);
 }
Пример #27
0
        private void GameEventManagerOnStartingNewGame(object sender, StartingNewGameEventArgs startingNewGameEventArgs)
        {
            _isStartingNewGame = true;
            Log.DebugFormat("GameEventManagerOnStartingNewGame");

            if (!_isUnlocking && _findNewQuest)
            {
                var foundQuest = false;
                var quests     = TritonHs.CurrentQuests;
                StatsSettings.Instance.Quests = TritonHs.CurrentQuests.Count;

                // Choose a basic deck to complete the quests.
                foreach (var quest in quests)
                {
                    // Loop through for each each class.
                    foreach (var @class in TritonHs.BasicHeroTagClasses)
                    {
                        // If this is a class specific quest, find a suitable deck. Otherwise,
                        // just use a random custom deck.
                        if (TritonHs.IsQuestForSpecificClass(quest.Id))
                        {
                            // If this quest is a win quest for this class.

                            if (TritonHs.IsQuestForClass(quest.Id, @class))
                            {
                                Log.InfoFormat(
                                    "[Quest] Now choosing the basic hero class to complete 要求职业的任务: [{0}] ,任务ID: [{1}] with.",
                                    quest.Name, quest.Id);

                                DefaultBotSettings.Instance.ConstructedDeckType  = DeckType.Basic;
                                DefaultBotSettings.Instance.ConstructedBasicDeck = @class;
                                unlockDeck = @class;
                                foundQuest = true;
                                break;
                            }
                        }
                    }

                    // If we found a quest and changed bot settings, we're done.
                    if (foundQuest)
                    {
                        break;
                    }

                    // Make sure we have a non-class quest to choose a random deck for.
                    if (!TritonHs.IsQuestForSpecificClass(quest.Id)) //不要求职业的任务
                    {
                        var decks = TritonHs.BasicHeroTagClasses;

                        // //Choose a random deck. We can add more logic for selection later...
                        var deck = decks[Client.Random.Next(0, decks.Length)];

                        Log.InfoFormat("[Quest] 预留功能,开发卡牌组,不要求职业的任务: [{0}] ,任务ID: [{1}]", quest.Name, quest.Id);

                        DefaultBotSettings.Instance.ConstructedDeckType  = DeckType.Basic;
                        DefaultBotSettings.Instance.ConstructedBasicDeck = deck;

                        foundQuest = true;
                        break;
                    }
                }
            }
        }
Пример #28
0
 public void method_21(object object_0)
 {
     try
     {
         this.method_22();
         string text;
         if (this.process_0 == null)
         {
             MessageBox.Show("can not find process");
             return;
         }
         else if (!TritonHs.smethod_0(this.process_0, Class12.smethod_4, out text))
         {
             Console.WriteLine(text);
             MessageBox.Show("TritonHs.smethod_0 == false");
         }
         else
         {
             TritonHs.Memory.ProcessExited += Class25.Instance.method_1;
             TritonHs.Memory.Executor.FrameDropWaitTime = 15000u;
             TritonHs.Memory.Executor.ExecuteWaitTime   = 15000;
             TritonHs.Memory.DisableCache();
             TritonHs.Memory.ClearCache();
             int version;
             int clientChangelist;
             using (TritonHs.AcquireFrame())
             {
                 version          = Version.version;
                 clientChangelist = Version.clientChangelist;
             }
             if ((long)version != (long)((ulong)Class247.UInt32_1) && (long)clientChangelist != (long)((ulong)Class247.UInt32_2))
             {
                 Console.WriteLine("Hearthstone client version ({0}, {1})", version, clientChangelist);
                 //MainWindow.ilog_0.InfoFormat("Hearthstone client version ({0}, {1})", version, clientChangelist);
                 //new Coroutine(new Func<Task>(Class25.Instance.method_2));
                 smethod_0();
                 //Configuration.Instance.AddSettings(MainSettings.Instance);
                 //Configuration.Instance.AddSettings(DevSettings.Instance);
                 //Configuration.Instance.SaveAll();
                 //base.Dispatcher.Invoke(new Action(this.method_23));
                 //BotManager.PreStart += this.method_11;
                 //BotManager.PostStop += this.method_10;
                 BotManager.Load();
                 this.method_24();
                 this.method_25();
                 //BotManager.OnBotChanged += this.method_6;
                 RoutineManager.Load();
                 this.method_26();
                 this.method_27();
                 //RoutineManager.OnRoutineChanged += this.method_7;
                 //PluginManager.Load();
                 //foreach (IPlugin plugin in PluginManager.Plugins)
                 //{
                 //    if (MainSettings.Instance.EnabledPlugins.Contains(plugin.Name))
                 //    {
                 //        using (TritonHs.AcquireFrame())
                 //        {
                 //            PluginManager.Enable(plugin);
                 //        }
                 //        Thread.Sleep(20);
                 //    }
                 //    else
                 //    {
                 //        using (TritonHs.AcquireFrame())
                 //        {
                 //            PluginManager.Disable(plugin);
                 //        }
                 //        Thread.Sleep(20);
                 //    }
                 //}
                 //this.listBox_0.Dispatcher.Invoke<IEnumerable>(new Func<IEnumerable>(this.method_28), DispatcherPriority.Normal);
                 this.method_29();
                 //PluginManager.PluginEnabled += this.method_5;
                 //PluginManager.PluginDisabled += this.method_4;
                 //MainWindow.ilog_0.ErrorFormat("{0}Please read the following guide before using this program:{0}https://github.com/ChuckHearthBuddy/SilverFish/blob/master/ReadMe.md", Environment.NewLine);
                 //base.Dispatcher.Invoke(new Action(this.method_30));
                 //base.Dispatcher.Invoke(new Action(this.method_31));
                 //this.stopwatch_0.Restart();
                 //RoutineManager.OnRoutineChanged += this.method_7;
                 //BotManager.OnBotChanged += this.method_6;
                 TritonHs.IsBotFullyLoaded = true;
                 Hotkeys.Register("BotManager.StartStop", Keys.S, ModifierKeys.Alt | ModifierKeys.Shift, Class25.Instance.method_3);
                 //if (CommandLine.Arguments.Exists("autostart"))
                 {
                     //var bot = new DefaultBot();
                     //BotManager.CurrentBot = bot;
                     BotManager.Start();
                 }
             }
             else
             {
                 text = string.Format("This client version ({0}, {1}) is unsupported. Hearthbuddy currently supports client version ({2}, {3}). Please check the forums for more information: https://www.thebuddyforum.com/hearthbuddy-forum/", new object[]
                 {
                     version,
                     clientChangelist,
                     Class247.UInt32_1,
                     Class247.UInt32_2
                 });
                 //MainWindow.ilog_0.ErrorFormat(text, Array.Empty<object>());
                 //System.Windows.MessageBox.Show(text, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
                 //base.Dispatcher.BeginInvoke(new Action(base.Close), Array.Empty<object>());
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         //MainWindow.ilog_0.Error("[OnStartup] A top-level exception has been caught.", exception);
     }
 }