Example #1
0
        public void setEnchantments(List <BattleField.HrtUnit> enchantments)
        {
            foreach (BattleField.HrtUnit bhu in enchantments)
            {
                //create enchantment
                Enchantment ench = CardDB.getEnchantmentFromCardID(bhu.CardID);
                ench.creator         = bhu.getTag(GAME_TAG.CREATOR);
                ench.cantBeDispelled = false;
                if (bhu.getTag(GAME_TAG.CANT_BE_DISPELLED) == 1)
                {
                    ench.cantBeDispelled = true;
                }

                foreach (Minion m in this.ownMinions)
                {
                    if (m.entitiyID == bhu.getTag(GAME_TAG.ATTACHED))
                    {
                        m.enchantments.Add(ench);
                    }
                }

                foreach (Minion m in this.enemyMinions)
                {
                    if (m.entitiyID == bhu.getTag(GAME_TAG.ATTACHED))
                    {
                        m.enchantments.Add(ench);
                    }
                }
            }
        }
Example #2
0
//    wenn ein spieler einen zauber wirkt, erhält der andere spieler eine kopie desselben auf seine hand.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
        {
            if (c.type == CardDB.cardtype.SPELL)
            {
                p.drawACard(c.cardIDenum, !wasOwnCard, true);
            }
        }
Example #3
0
//    erhält jedes mal +1 angriff, wenn ihr einen zauber wirkt.
        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
        {
            if (triggerEffectMinion.own == wasOwnCard && c.type == CardDB.cardtype.SPELL)
            {
                triggerEffectMinion.Angr++;
            }
        }
Example #4
0
 public miniEnch(CardDB.cardIDEnum id, int crtr, int controler, int copydr)
 {
     this.CARDID = id;
     this.creator = crtr;
     this.controllerOfCreator = controler;
     this.copyDeathrattle = copydr;
 }
Example #5
0
//    erhält jedes mal +1/+1, wenn ihr eine karte ausspielt.
        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target)
        {
            if (triggerEffectMinion.own == wasOwnCard)
            {
                p.minionGetBuffed(triggerEffectMinion, 1, 1);
            }
        }
Example #6
0
//    erhaltet jedes mal einen „feuerball“-zauber auf eure hand, wenn ihr einen zauber wirkt.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
        {
            if (wasOwnCard == triggerEffectMinion.own && c.type == CardDB.cardtype.SPELL)
            {
                p.drawACard(CardDB.cardName.fireball, wasOwnCard, true);
            }
        }
Example #7
0
//    erhält jedes mal +2 angriff in diesem zug, wenn ihr einen zauber wirkt.
        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target)
        {
            if (triggerEffectMinion.own == wasOwnCard && c.type == CardDB.cardtype.SPELL)
            {
                p.minionGetTempBuff(triggerEffectMinion, 2, 0);
            }
        }
Example #8
0
        //   Whenever your opponent casts a spell, gain +1 Attack.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
        {
            if (c.type == CardDB.cardtype.SPELL && wasOwnCard != triggerEffectMinion.own)
            {
                p.minionGetBuffed(triggerEffectMinion, 1, 0);
            }
        }
Example #9
0
//    erhaltet jedes mal einen „feuerball“-zauber auf eure hand, wenn ihr einen zauber wirkt.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
        {
            if (wasOwnCard == triggerEffectMinion.own && c.type == CardDB.cardtype.SPELL)
            {
                p.drawACard(CardDB.cardIDEnum.CS2_029, wasOwnCard, true);
            }
        }
Example #10
0
 // erhält jedes Mal +1/+1, wenn Ihr eine Karte mit uberladung&lt; ausspielt.
 public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
 {
     if (wasOwnCard == triggerEffectMinion.own && c.Recall)
     {
         p.minionGetBuffed(triggerEffectMinion, 1, 1);
     }
 }
Example #11
0
        private void setEnchantments(List <HREntity> enchantments)
        {
            foreach (HREntity bhu in enchantments)
            {
                //create enchantment
                Enchantment ench = CardDB.getEnchantmentFromCardID(bhu.GetCardId());
                ench.creator             = bhu.GetCreatorId();
                ench.controllerOfCreator = bhu.GetControllerId();
                ench.cantBeDispelled     = false;
                //if (bhu.c) ench.cantBeDispelled = true;

                foreach (Minion m in this.ownMinions)
                {
                    if (m.entitiyID == bhu.GetAttached())
                    {
                        m.enchantments.Add(ench);
                        //HRLog.Write("add enchantment " +bhu.GetCardId()+" to: " + m.entitiyID);
                    }
                }

                foreach (Minion m in this.enemyMinions)
                {
                    if (m.entitiyID == bhu.GetAttached())
                    {
                        m.enchantments.Add(ench);
                    }
                }
            }
        }
Example #12
0
 public void setInstances()
 {
     help     = Helpfunctions.Instance;
     penman   = PenalityManager.Instance;
     settings = Settings.Instance;
     cdb      = CardDB.Instance;
 }
Example #13
0
        //todo (later)
        // ogre brut, dunemaul shaman, ogre ninja, mogor the ogre, == game-tag forgetfull

        //TODO secrets
        // resurrect,
        // blingtron 3000

        // minions to do:
        //http://hearthstone.gamepedia.com/Random_effect

        static void Main(string[] args)
        {
            //Bot b = new Bot();

            CardDB   carddb = CardDB.Instance;
            HSServer hsc    = new HSServer();

            hsc.start(100);

            /*
             * bool readed =false;
             * while(!readed)
             * {
             *  try
             *  {
             *      string data = System.IO.File.ReadAllText("crrntbrd.txt");
             *      if (data != "" && data != "<EoF>")
             *      {
             *          data = data.Replace("<EoF>", "");
             *          Helpfunctions.Instance.resetBuffer();
             *          Helpfunctions.Instance.writeBufferToFile();
             *          //readed = true;
             *          b.doData(data);
             *      }
             *  }
             *  catch
             *  {
             *
             *  }
             *  System.Threading.Thread.Sleep(10);
             * }*/

            Console.ReadLine();
        }
Example #14
0
        //Whenever you target this minion with a spell, gain Divine Shield

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
        {
            if (triggerEffectMinion.own == wasOwnCard && c.type == CardDB.cardtype.SPELL && target!=null && target.entityID == triggerEffectMinion.entityID)
            {
                triggerEffectMinion.divineshild = true;
            }
        }
Example #15
0
        CardDB.Card d = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_614t);//flameofazzinoth
//    beschwört jedes mal eine flamme von azzinoth (2/1), wenn ihr eine karte ausspielt.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target)
        {
            if (wasOwnCard == triggerEffectMinion.own)
            {
                    p.callKid(d, triggerEffectMinion.zonepos, triggerEffectMinion.own);

            }
        }
Example #16
0
 //    Whenever you cast a spell on another friendly minion, cast a copy of it on this one.
 public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
 {
     if (target != null && target.own == wasOwnCard && triggerEffectMinion.own == wasOwnCard && target.entitiyID != triggerEffectMinion.entitiyID && c.type == CardDB.cardtype.SPELL)
     {
         c.sim_card.onCardPlay(p, wasOwnCard, triggerEffectMinion, choice);
         p.doDmgTriggers();
     }
 }
Example #17
0
//    zieht jedes mal eine karte, wenn ihr einen zauber wirkt.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
        {
            if (c.type == CardDB.cardtype.SPELL && wasOwnCard == triggerEffectMinion.own)
            {
                p.drawACard(CardDB.cardIDEnum.None, wasOwnCard);
            }

        }
Example #18
0
 public Handcard(CardDB.Card c)
 {
     this.position = 0;
     this.entity = -1;
     this.card = c;
     this.addattack = 0;
     this.addHp = 0;
 }
Example #19
0
 public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
 {
     if (wasOwnCard == triggerEffectMinion.own && c.type == CardDB.cardtype.SPELL)
     {
         int place = (wasOwnCard)? p.ownMinions.Count : p.enemyMinions.Count;
         p.callKid(card, place, wasOwnCard);
     }
 }
Example #20
0
        //    Whenever your opponent casts a spell, gain a copy of it and give them a Coin.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target)
        {
            if (c.type == CardDB.cardtype.SPELL && c.name != CardDB.cardName.gallywixscoin && wasOwnCard != triggerEffectMinion.own)
            {
                p.drawACard(c.cardIDenum, triggerEffectMinion.own, true);
                p.drawACard(CardDB.cardIDEnum.GVG_028t, wasOwnCard, true);
            }
        }
Example #21
0
        //    After you cast a spell, deal 2 damage randomly split among all enemies.

        public override void onCardWasPlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
        {
            if (triggerEffectMinion.own == wasOwnCard)
            {
                if (p.isServer)
                {
                    int timesS = 2;
                    for (int iS = 0; iS < timesS; iS++)
                    {
                        Minion poortarget = p.getRandomMinionFromSide_SERVER(!wasOwnCard, true);
                        if (poortarget != null) p.minionGetDamageOrHeal(poortarget, 1);
                    }
                    return;
                }

                List<Minion> temp = (triggerEffectMinion.own) ? p.enemyMinions : p.ownMinions;
                for (int i = 0; i < 2; i++)
                {
                    if (temp.Count >= 1)
                    {
                        //search Minion with lowest hp
                        Minion enemy = temp[0];
                        int minhp = 10000;
                        bool found = false;
                        foreach (Minion m in temp)
                        {
                            if (m.name == CardDB.cardName.nerubianegg && m.Hp >= 2) continue; //dont attack nerubianegg!
                            if (m.handcard.card.isToken && m.Hp == 1) continue;
                            if (m.name == CardDB.cardName.defender) continue;
                            if (m.name == CardDB.cardName.spellbender) continue;
                            if (m.Hp >= 2 && minhp > m.Hp)
                            {
                                enemy = m;
                                minhp = m.Hp;
                                found = true;
                            }
                        }

                        if (found)
                        {
                            p.minionGetDamageOrHeal(enemy, 1);
                        }
                        else
                        {
                            p.minionGetDamageOrHeal(triggerEffectMinion.own ? p.enemyHero : p.ownHero, 1);
                        }

                    }
                    else
                    {
                        p.minionGetDamageOrHeal(triggerEffectMinion.own ? p.enemyHero : p.ownHero, 1);
                    }
                }

                triggerEffectMinion.stealth = false;
            }
        }
Example #22
0
 //   Whenever you cast a 1-mana spell, add a random Mech to your hand.
 //todo: do it right (not card.cost, we have to use current cost)
 public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
 {
     if (triggerEffectMinion.own == wasOwnCard)
     {
         if (c.type == CardDB.cardtype.SPELL && c.cost == 1)
         {
             p.drawACard(CardDB.cardIDEnum.GVG_058, wasOwnCard, true);
         }
     }
 }
Example #23
0
        //After you cast a spell, Freeze a random enemy character.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
        {
            if (triggerEffectMinion.own == wasOwnCard && c.type == CardDB.cardtype.SPELL)
            {
                Minion target2 = null;
                List<Minion> temp = (wasOwnCard) ? p.enemyMinions : p.ownMinions;
                if (temp.Count > 0) target2 = p.searchRandomMinion(temp, Playfield.searchmode.searchLowestHP);
                if (target2 == null) target2 = (wasOwnCard) ? p.enemyHero : p.ownHero;
                target2.frozen = true;
            }
        }
Example #24
0
        //public int cardsPlayedThisTurn = 0;

        public player(int sock, string path, string fold)
        {
            cdb         = CardDB.Instance;
            this.socket = sock;
            this.folder = fold;
            string deckToLoad = path + Path.DirectorySeparatorChar + fold + Path.DirectorySeparatorChar;

            Console.WriteLine("path: " + deckToLoad);

            usedCards.Clear();
            loadCards(deckToLoad);
        }
        public bool hasEnemyThisCardInDeck(CardDB.cardIDEnum cardid)
        {
            if (this.enemyCardsPlayed.ContainsKey(cardid))
            {
                if (this.enemyCardsPlayed[cardid] == 1)
                {

                    return true;
                }
                return false;
            }
            return true;
        }
Example #26
0
        public int getBonusValue(CardDB.cardIDEnum cardid, string ownclass, string enemyclass)
        {
            int bonus = 0;
            foreach (discoveryitem di in this.discoverylist)
            {
                if (di.cardid == cardid && (di.ownclass == "all" || di.ownclass == ownclass) && (di.enemyclass == "all" || di.enemyclass == enemyclass))
                {
                    if (di.bonus > bonus) bonus = di.bonus;
                }
            }

            return bonus;
        }
Example #27
0
        //    Whenever your opponent plays a card, discard the top 3 cards of your deck.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
        {
            if (wasOwnCard == triggerEffectMinion.own) return; //owner of card = owner of minion -> no effect

            if (triggerEffectMinion.own)
            {
                p.ownDeckSize = Math.Max(0, p.ownDeckSize - 3);
            }
            else
            {
                p.enemyDeckSize = Math.Max(0, p.enemyDeckSize - 3);
            }
        }
Example #28
0
        // After you cast a spell, deal 2 damage randomly split among all enemies.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool ownplay, Minion m)
        {
            if (m.own == ownplay && c.type == CardDB.cardtype.SPELL)
            {
                Minion target = (ownplay) ? p.enemyHero : p.ownHero;
                p.minionGetDamageOrHeal(target, 1);

                List<Minion> temp = (ownplay) ? p.enemyMinions : p.ownMinions;
                if (temp.Count > 0) target = p.searchRandomMinion(temp, Playfield.searchmode.searchLowestHP);
                if (target == null) target = (ownplay) ? p.enemyHero : p.ownHero;
                p.minionGetDamageOrHeal(target, 1);
            }
        }
Example #29
0
        //Whenever you target this minion with a spell, deal 3 damage to a random enemy.

        public override void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target, int choice)
        {
            if (triggerEffectMinion.own == wasOwnCard && c.type == CardDB.cardtype.SPELL && target!=null && target.entitiyID == triggerEffectMinion.entitiyID)
            {
                if (p.isServer)
                {
                    Minion choosen = p.getRandomMinionFromSide_SERVER(!triggerEffectMinion.own, true);
                    if (choosen != null) p.minionGetDamageOrHeal(choosen, 3);
                    return;
                }

                p.doDmgToRandomEnemyCLIENT2(3, true, triggerEffectMinion.own);
            }
        }
Example #30
0
        public virtual void onCardIsDiscarded(Playfield p, CardDB.Card card, bool own)
        {

            int dmg = (own) ? p.getSpellDamageDamage(4) : p.getEnemySpellDamageDamage(4);

            if (p.isServer)
            {
                Minion choosen = p.getRandomMinionFromSide_SERVER(!own, true);
                if (choosen != null) p.minionGetDamageOrHeal(choosen, dmg);
                return;
            }

            p.doDmgToRandomEnemyCLIENT(dmg, true, !own);
        }
Example #31
0
        public Bot()
        {
            //crawler stuff-----------------
            OnVictory             = HandleWining;
            OnLost                = HandleLosing;
            OnBattleStateUpdate   = HandleOnBattleStateUpdate;
            OnMulliganStateUpdate = HandleBattleMulliganPhase;
            //-----------------------------------------
            starttime = DateTime.Now;


            Settings set = Settings.Instance;

            this.sf = Silverfish.Instance;
            set.setSettings();
            sf.setnewLoggFile();
            CardDB cdb = CardDB.Instance;

            if (cdb.installedWrong)
            {
                Helpfunctions.Instance.ErrorLog("cant find CardDB");
                return;
            }

            bool teststuff  = false; // set to true, to run a testfile (requires test.txt file in folder where _cardDB.txt file is located)
            bool printstuff = false; // if true, the best board of the tested file is printet stepp by stepp

            Helpfunctions.Instance.ErrorLog("----------------------------");
            Helpfunctions.Instance.ErrorLog("you are running uai V" + sf.versionnumber);
            Helpfunctions.Instance.ErrorLog("----------------------------");

            if (Settings.Instance.useExternalProcess)
            {
                Helpfunctions.Instance.ErrorLog("YOU USE SILVER.EXE FOR CALCULATION, MAKE SURE YOU STARTED IT!");
            }
            if (Settings.Instance.useExternalProcess)
            {
                Helpfunctions.Instance.ErrorLog("SILVER.EXE IS LOCATED IN: " + Settings.Instance.path);
            }



            if (teststuff)//run autotester for developpers
            {
                Ai.Instance.autoTester(printstuff);
            }
            writeSettings();
        }
Example #32
0
        //    After you cast a spell, deal 2 damage randomly split among all enemies.

        public override void onCardWasPlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion)
        {
            if (triggerEffectMinion.own == wasOwnCard)
            {
                if (p.isServer)
                {
                    int timesS = 2;
                    for (int iS = 0; iS < timesS; iS++)
                    {
                        Minion poortarget = p.getRandomMinionFromSide_SERVER(!wasOwnCard, true);
                        if (poortarget != null) p.minionGetDamageOrHeal(poortarget, 1);
                    }
                    return;
                }

                List<Minion> targets = (triggerEffectMinion.own) ? new List<Minion>(p.enemyMinions) : new List<Minion>(p.ownMinions);

                if (triggerEffectMinion.own)
                {
                    targets.Add(p.enemyHero);
                    targets.Sort((a, b) => -a.Hp.CompareTo(b.Hp));  // most hp -> least
                }
                else
                {
                    targets.Add(p.ownHero);
                    targets.Sort((a, b) => a.Hp.CompareTo(b.Hp));  // least hp -> most
                }

                // Distribute the damage evenly among the targets
                int i = 0;
                while (i < 2)
                {
                    int loc = i % targets.Count;
                    p.minionGetDamageOrHeal(targets[loc], 1);
                    i++;
                }

                triggerEffectMinion.stealth = false;
            }
        }
Example #33
0
        public Card getCardData(CardDB.cardName cardname)
        {
            Card c = new Card();

            foreach (Card ca in this.cardlist)
            {
                if (ca.name == cardname)
                {
                    return ca;
                }
            }

            return c;
        }
Example #34
0
 public bool isRequirementInList(CardDB.ErrorType2 et)
 {
     if (this.playrequires.Contains(et)) return true;
     return false;
 }
Example #35
0
 public void setInstances()
 {
     help = Helpfunctions.Instance;
     cdb  = CardDB.Instance;
 }
Example #36
0
        public Bot()
        {
            behave                = this.getBotBehave();
            OnVictory             = HandleWining;
            OnLost                = HandleLosing;
            OnBattleStateUpdate   = HandleOnBattleStateUpdate;
            OnMulliganStateUpdate = HandleBattleMulliganPhase;
            starttime             = DateTime.Now;
            bool concede           = false;
            bool writeToSingleFile = false;

            try
            {
                this.learnmode = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.wwuaid") == "true") ? true : false;
                if (this.learnmode)
                {
                    Helpfunctions.Instance.ErrorLog("Learn mode is ON");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
            }
            try
            {
                concede           = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.autoconcede") == "true") ? true : false;
                writeToSingleFile = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.singleLog") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
            }
            try
            {
                this.concedeLvl = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.concedelvl")));
                if (this.concedeLvl >= 20)
                {
                    this.concedeLvl = 20;
                }
                if (concede)
                {
                    Helpfunctions.Instance.ErrorLog("concede till rank " + concedeLvl);
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read your concede-Lvl");
            }

            try
            {
                this.stopAfterWins = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.stopwin")));
                if (this.stopAfterWins <= 0)
                {
                    this.stopAfterWins = 10000;
                }
                Helpfunctions.Instance.ErrorLog("stop after " + stopAfterWins + " wins");
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read stop after # of wins");
            }

            try
            {
                this.enemyConcede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyconcede") == "true") ? true : false;
                if (this.enemyConcede)
                {
                    Helpfunctions.Instance.ErrorLog("concede whether enemy has lethal");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read enemy concede");
            }

            this.sf = new Silverfish(writeToSingleFile);


            CardDB cdb = CardDB.Instance;

            if (cdb.installedWrong)
            {
                return;
            }


            Mulligan.Instance.setAutoConcede(concede);

            sf.setnewLoggFile();

            try
            {
                int enfacehp = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyfacehp")));
                Helpfunctions.Instance.ErrorLog("set enemy-face-hp to: " + enfacehp);
                ComboBreaker.Instance.attackFaceHP = enfacehp;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading enemy-face-hp");
            }

            try
            {
                int mxwde = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.maxwide")));
                Ai.Instance.setMaxWide(mxwde);
                if (mxwde != 3000)
                {
                    Ai.Instance.setMaxWide(mxwde);
                    Helpfunctions.Instance.ErrorLog("set maxwide to: " + mxwde);
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading Maxwide from settings, please recheck the entry");
            }

            try
            {
                bool twots = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateTwoTurns") == "true") ? true : false;
                Ai.Instance.setTwoTurnSimulation(twots);
                if (twots)
                {
                    Ai.Instance.setTwoTurnSimulation(twots);
                    Helpfunctions.Instance.ErrorLog("activated two turn simulation");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading two-turn-simulation from settings");
            }

            try
            {
                bool playaround     = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAround") == "true") ? true : false;
                int  playaroundprob = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb"));
                if (playaroundprob > 100)
                {
                    playaroundprob = 100;
                }
                if (playaroundprob < 0)
                {
                    playaroundprob = 0;
                }

                int playaroundprob2 = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb2"));
                if (playaroundprob2 < playaroundprob)
                {
                    playaroundprob2 = playaroundprob;
                }
                if (playaroundprob2 > 100)
                {
                    playaroundprob2 = 100;
                }
                if (playaroundprob2 < 0)
                {
                    playaroundprob2 = 0;
                }
                if (playaround)
                {
                    Ai.Instance.setPlayAround(playaround, playaroundprob, playaroundprob2);
                    Helpfunctions.Instance.ErrorLog("activated playaround");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading play around settings");
            }

            Helpfunctions.Instance.ErrorLog("write to single log file is: " + writeToSingleFile);

            bool teststuff  = false;
            bool printstuff = false;

            try
            {
                printstuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.longteststuff") == "true") ? true : false;
                teststuff  = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.teststuff") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("something went wrong with simulating stuff!");
            }
            Helpfunctions.Instance.ErrorLog("----------------------------");
            Helpfunctions.Instance.ErrorLog("you are running uai V" + sf.versionnumber);
            Helpfunctions.Instance.ErrorLog("----------------------------");

            if (teststuff)
            {
                Ai.Instance.autoTester(behave, printstuff);
            }
            writeSettings();
        }
Example #37
0
        public void updateOwnHero(string weapon, int watt, int wdur, string heron, CardDB.Card hab, bool habrdy, Minion Hero)
        {
            this.ownHeroWeapon = CardDB.Instance.cardNamestringToEnum(weapon);
            this.heroWeaponAttack = watt;
            this.heroWeaponDurability = wdur;

            this.heroname = this.heroNametoEnum(heron);

            this.heroAbility = hab;
            this.ownAbilityisReady = habrdy;

            this.ownHero = new Minion(Hero);
            this.ownHero.updateReadyness();
        }
Example #38
0
        public void updateEnemyHero(string weapon, int weaponAttack, int weaponDurability, string heron,int enemMaxMana, CardDB.Card eab, Minion enemyHero)
        {
            this.enemyHeroWeapon = CardDB.Instance.cardNamestringToEnum(weapon);
            this.enemyWeaponAttack = weaponAttack;
            this.enemyWeaponDurability = weaponDurability;

            this.enemyMaxMana = enemMaxMana;

            this.enemyHeroname = this.heroNametoEnum(heron);

            this.enemyAbility = eab;

            this.enemyHero = new Minion(enemyHero);
            
        }
Example #39
0
        public BoardTester()
        {
            string[] lines = new string[0] {
            };
            try
            {
                string path = Settings.Instance.path;
                lines = System.IO.File.ReadAllLines(path + "test.txt");
            }
            catch
            {
                Helpfunctions.Instance.logg("cant find test.txt");
                return;
            }

            CardDB.Card heroability  = CardDB.Instance.getCardDataFromID("CS2_034");
            bool        abilityReady = false;

            int readstate = 0;
            int counter   = 0;

            Minion tempminion = new Minion();
            int    j          = 0;

            foreach (string sss in lines)
            {
                string s = sss + " ";
                Helpfunctions.Instance.logg(s);

                if (s.StartsWith("ailoop"))
                {
                    break;
                }
                if (s.StartsWith("####"))
                {
                    continue;
                }
                if (s.StartsWith("start calculations"))
                {
                    continue;
                }

                if (s.StartsWith("enemy secretsCount:"))
                {
                    this.enemySecrets = Convert.ToInt32(s.Split(' ')[2]);
                    continue;
                }

                if (s.StartsWith("mana "))
                {
                    string ss = s.Replace("mana ", "");
                    mana    = Convert.ToInt32(ss.Split('/')[0]);
                    maxmana = Convert.ToInt32(ss.Split('/')[1]);
                }

                if (readstate == 42 && counter == 1) // player
                {
                    this.overdrive = Convert.ToInt32(s.Split(' ')[2]);
                    this.numMinionsPlayedThisTurn = Convert.ToInt32(s.Split(' ')[0]);
                    this.cardsPlayedThisTurn      = Convert.ToInt32(s.Split(' ')[1]);
                    this.ownPlayer = Convert.ToInt32(s.Split(' ')[3]);
                }

                if (readstate == 1 && counter == 1) // class + hp + defence + immune
                {
                    ownheroname    = s.Split(' ')[0];
                    ownherohp      = Convert.ToInt32(s.Split(' ')[1]);
                    ownherodefence = Convert.ToInt32(s.Split(' ')[2]);
                    string boolim = s.Split(' ')[4];
                    this.ownHeroimmunewhileattacking = (boolim == "True") ? true : false;
                }

                if (readstate == 1 && counter == 2) // ready, num attacks this turn, frozen
                {
                    string readystate = s.Split(' ')[1];
                    this.ownheroready            = (readystate == "True") ? true : false;
                    this.ownheroattacksThisRound = Convert.ToInt32(s.Split(' ')[3]);

                    this.ownHeroFrozen = (s.Split(' ')[5] == "True")? true:false;

                    ownHeroAttack                = Convert.ToInt32(s.Split(' ')[7]);
                    ownHeroWeaponAttack          = Convert.ToInt32(s.Split(' ')[8]);
                    this.ownHeroWeaponDurability = Convert.ToInt32(s.Split(' ')[9]);
                    if (ownHeroWeaponAttack == 0)
                    {
                        ownHeroWeapon = ""; //:D
                    }
                    else
                    {
                        ownHeroWeapon = s.Split(' ')[10];
                    }
                }

                if (readstate == 1 && counter == 3) // ability + abilityready
                {
                    abilityReady = (s.Split(' ')[1] == "True") ? true : false;
                    heroability  = CardDB.Instance.getCardDataFromID(s.Split(' ')[2]);
                }

                if (readstate == 1 && counter >= 5) // secrets
                {
                    if (!s.StartsWith("enemyhero:"))
                    {
                        ownsecretlist.Add(s.Replace(" ", ""));
                    }
                }

                if (readstate == 2 && counter == 1) // class + hp + defence + frozen
                {
                    enemyheroname    = s.Split(' ')[0];
                    enemyherohp      = Convert.ToInt32(s.Split(' ')[1]);
                    enemyherodefence = Convert.ToInt32(s.Split(' ')[2]);
                    enemyFrozen      = (s.Split(' ')[3] == "True") ? true : false;
                }

                if (readstate == 2 && counter == 2) // wepon + stuff
                {
                    this.enemyWeaponAttack = Convert.ToInt32(s.Split(' ')[0]);
                    this.enemyWeaponDur    = Convert.ToInt32(s.Split(' ')[1]);
                    if (enemyWeaponDur == 0)
                    {
                        this.enemyWeapon = "";
                    }
                    else
                    {
                        this.enemyWeapon = s.Split(' ')[2];
                    }
                }

                if (readstate == 3) // minion or enchantment
                {
                    if (s.Contains(" id:"))
                    {
                        if (counter >= 2)
                        {
                            this.ownminions.Add(tempminion);
                        }

                        string minionname = s.Split(' ')[0];
                        int    attack     = Convert.ToInt32(s.Split(new string[] { " A:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        int    hp         = Convert.ToInt32(s.Split(new string[] { " H:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        int    maxhp      = Convert.ToInt32(s.Split(new string[] { " mH:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        bool   ready      = s.Split(new string[] { " rdy:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        bool   taunt      = s.Split(new string[] { " tnt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        bool   silenced   = false;
                        if (s.Contains(" silenced:"))
                        {
                            silenced = s.Split(new string[] { " silenced:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool divshield = false;
                        if (s.Contains(" divshield:"))
                        {
                            divshield = s.Split(new string[] { " divshield:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool ptt = false;//played this turn
                        if (s.Contains(" ptt:"))
                        {
                            ptt = s.Split(new string[] { " ptt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool wndfry = false;//windfurry
                        if (s.Contains(" wndfr:"))
                        {
                            wndfry = s.Split(new string[] { " wndfr:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        int natt = 0;
                        if (s.Contains(" natt:"))
                        {
                            natt = Convert.ToInt32(s.Split(new string[] { " natt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        }

                        int ent = 1000 + j;
                        if (s.Contains(" e:"))
                        {
                            ent = Convert.ToInt32(s.Split(new string[] { " e:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        }

                        bool pois = false;//poision
                        if (s.Contains(" poi:"))
                        {
                            pois = s.Split(new string[] { " poi:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool stl = false;//stealth
                        if (s.Contains(" stl:"))
                        {
                            stl = s.Split(new string[] { " stl:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool immn = false;//immune
                        if (s.Contains(" imm:"))
                        {
                            immn = s.Split(new string[] { " imm:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool chrg = false;//charge
                        if (s.Contains(" chrg:"))
                        {
                            chrg = s.Split(new string[] { " chrg:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool ex = false;//exhausted
                        if (s.Contains(" ex:"))
                        {
                            ex = s.Split(new string[] { " ex:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }


                        int id = Convert.ToInt32(s.Split(new string[] { " id:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        tempminion                    = createNewMinion(new Handmanager.Handcard(CardDB.Instance.getCardData(minionname)), id);
                        tempminion.Angr               = attack;
                        tempminion.Hp                 = hp;
                        tempminion.maxHp              = maxhp;
                        tempminion.Ready              = ready;
                        tempminion.taunt              = taunt;
                        tempminion.divineshild        = divshield;
                        tempminion.playedThisTurn     = ptt;
                        tempminion.windfury           = wndfry;
                        tempminion.numAttacksThisTurn = natt;
                        tempminion.entitiyID          = ent;
                        tempminion.handcard.entity    = ent;
                        tempminion.silenced           = silenced;
                        tempminion.exhausted          = ex;
                        tempminion.poisonous          = pois;
                        tempminion.stealth            = stl;
                        tempminion.immune             = immn;
                        tempminion.charge             = chrg;
                        if (maxhp > hp)
                        {
                            tempminion.wounded = true;
                        }
                    }
                    else
                    {
                        try
                        {
                            Enchantment e = CardDB.getEnchantmentFromCardID(s.Split(' ')[0]);
                            e.controllerOfCreator = Convert.ToInt32(s.Split(' ')[2]);
                            e.creator             = Convert.ToInt32(s.Split(' ')[1]);
                            tempminion.enchantments.Add(e);
                        }
                        catch
                        {
                        }
                    }
                }

                if (readstate == 4) // minion or enchantment
                {
                    if (s.Contains(" id:"))
                    {
                        if (counter >= 2)
                        {
                            this.enemyminions.Add(tempminion);
                        }

                        string minionname = s.Split(' ')[0];
                        int    attack     = Convert.ToInt32(s.Split(new string[] { " A:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        int    hp         = Convert.ToInt32(s.Split(new string[] { " H:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        int    maxhp      = Convert.ToInt32(s.Split(new string[] { " mH:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        bool   ready      = s.Split(new string[] { " rdy:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        bool   taunt      = s.Split(new string[] { " tnt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        bool   silenced   = false;
                        if (s.Contains(" silenced:"))
                        {
                            silenced = s.Split(new string[] { " silenced:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool divshield = false;
                        if (s.Contains(" divshield:"))
                        {
                            divshield = s.Split(new string[] { " divshield:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool ptt = false;//played this turn
                        if (s.Contains(" ptt:"))
                        {
                            ptt = s.Split(new string[] { " ptt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool wndfry = false;//windfurry
                        if (s.Contains(" wndfr:"))
                        {
                            wndfry = s.Split(new string[] { " wndfr:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        int natt = 0;
                        if (s.Contains(" natt:"))
                        {
                            natt = Convert.ToInt32(s.Split(new string[] { " natt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        }

                        int ent = 1000 + j;
                        if (s.Contains(" e:"))
                        {
                            ent = Convert.ToInt32(s.Split(new string[] { " e:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        }

                        bool pois = false;//poision
                        if (s.Contains(" poi:"))
                        {
                            pois = s.Split(new string[] { " poi:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool stl = false;//stealth
                        if (s.Contains(" stl:"))
                        {
                            stl = s.Split(new string[] { " stl:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool immn = false;//immune
                        if (s.Contains(" imm:"))
                        {
                            immn = s.Split(new string[] { " imm:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool chrg = false;//charge
                        if (s.Contains(" chrg:"))
                        {
                            chrg = s.Split(new string[] { " chrg:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }
                        bool ex = false;//exhausted
                        if (s.Contains(" ex:"))
                        {
                            ex = s.Split(new string[] { " ex:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
                        }

                        int id = Convert.ToInt32(s.Split(new string[] { " id:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
                        tempminion                    = createNewMinion(new Handmanager.Handcard(CardDB.Instance.getCardData(minionname)), id);
                        tempminion.Angr               = attack;
                        tempminion.Hp                 = hp;
                        tempminion.maxHp              = maxhp;
                        tempminion.Ready              = ready;
                        tempminion.taunt              = taunt;
                        tempminion.divineshild        = divshield;
                        tempminion.playedThisTurn     = ptt;
                        tempminion.windfury           = wndfry;
                        tempminion.numAttacksThisTurn = natt;
                        tempminion.entitiyID          = ent;
                        tempminion.silenced           = silenced;
                        tempminion.exhausted          = ex;
                        tempminion.poisonous          = pois;
                        tempminion.stealth            = stl;
                        tempminion.immune             = immn;
                        tempminion.charge             = chrg;
                        if (maxhp > hp)
                        {
                            tempminion.wounded = true;
                        }
                    }
                    else
                    {
                        try
                        {
                            Enchantment e = CardDB.getEnchantmentFromCardID(s.Split(' ')[0]);
                            e.controllerOfCreator = Convert.ToInt32(s.Split(' ')[2]);
                            e.creator             = Convert.ToInt32(s.Split(' ')[1]);
                            tempminion.enchantments.Add(e);
                        }
                        catch
                        {
                        }
                    }
                }

                if (readstate == 5) // minion or enchantment
                {
                    Handmanager.Handcard card = new Handmanager.Handcard();

                    string minionname = s.Split(' ')[2];
                    int    pos        = Convert.ToInt32(s.Split(' ')[1]);
                    int    mana       = Convert.ToInt32(s.Split(' ')[3]);
                    card.card     = CardDB.Instance.getCardData(minionname);
                    card.entity   = Convert.ToInt32(s.Split(' ')[5]);
                    card.manacost = mana;
                    card.position = pos;
                    handcards.Add(card);
                }


                if (s.StartsWith("ownhero:"))
                {
                    readstate = 1;
                    counter   = 0;
                }

                if (s.StartsWith("enemyhero:"))
                {
                    readstate = 2;
                    counter   = 0;
                }

                if (s.StartsWith("OwnMinions:"))
                {
                    readstate = 3;
                    counter   = 0;
                }

                if (s.StartsWith("EnemyMinions:"))
                {
                    if (counter >= 2)
                    {
                        this.ownminions.Add(tempminion);
                    }

                    readstate = 4;
                    counter   = 0;
                }

                if (s.StartsWith("Own Handcards:"))
                {
                    if (counter >= 2)
                    {
                        this.enemyminions.Add(tempminion);
                    }

                    readstate = 5;
                    counter   = 0;
                }

                if (s.StartsWith("player:"))
                {
                    readstate = 42;
                    counter   = 0;
                }



                counter++;
                j++;
            }
            Helpfunctions.Instance.logg("rdy");


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

            Hrtprozis.Instance.updatePlayer(this.maxmana, this.mana, this.cardsPlayedThisTurn, this.numMinionsPlayedThisTurn, this.overdrive, 100, 200);
            Hrtprozis.Instance.updateSecretStuff(this.ownsecretlist, enemySecrets);

            int  numattttHero = 0;
            bool herowindfury = false;

            Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.ownHeroWeaponAttack, this.ownHeroWeaponDurability, ownHeroimmunewhileattacking, this.ownHeroAttack, this.ownherohp, this.ownherodefence, this.ownheroname, this.ownheroready, this.ownHeroFrozen, heroability, abilityReady, numattttHero, herowindfury);
            Hrtprozis.Instance.updateEnemyHero(this.enemyWeapon, this.enemyWeaponAttack, this.enemyWeaponDur, this.enemyWeaponAttack, this.enemyherohp, this.enemyherodefence, this.enemyheroname, this.enemyFrozen);

            Hrtprozis.Instance.updateMinions(this.ownminions, this.enemyminions);
            Handmanager.Instance.setHandcards(this.handcards, this.handcards.Count, 5);
        }