Exemple #1
0
        private void HideEntity(LogLine line)
        {
            Match match = PowerTaskList.HideEntityRegex.Match(line.Log);

            if (LogRegex.EntityRegex.IsMatch(match.Groups["entity"].Value))
            {
                Match  matchEntity = LogRegex.EntityRegex.Match(match.Groups["entity"].Value);
                HSCard card        = Game.GetCard(int.Parse(matchEntity.Groups["player"].Value), int.Parse(matchEntity.Groups["id"].Value));
                Match  matchPeek   = PowerTaskList.TagChangeRegex.Match(PeekLine(PowerReader).Log);
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.ZONE))
                {
                    Zone oldzone = card.Zone;
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                    MoveCard(card, oldzone);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            else
            {
                throw new IndexOutOfRangeException();
            }
        }
Exemple #2
0
        /// <summary>
        ///     check if we have coin in hand, and play it if needed
        /// </summary>
        private IEnumerator TryToPlayCoin()
        {
            // Coin card ID
            const string coinId = "GAME_005";

            // Should we play coin?
            if (TritonHS.GetCards(CardZone.Hand).Any(s => s.Id == coinId) // Do we have coin in hand?
                &&
                !TritonHS.GetCards(CardZone.Hand)
                .Any(s => s.CanBeUsed     // Ensure we cant play cards with current mana avaible
                     &&
                     TritonHS.GetCards(CardZone.Hand)
                     .Any(c => c.Cost == TritonHS.CurrentMana + 1 && c.IsMinion && !c.HasBattlecry)))
            // A card is awaible with currentmana + 1 (more checks are needed!!)
            {
                HSCard coin = TritonHS.GetCards(CardZone.Hand).FirstOrDefault(s => s.Id == coinId);
                if (coin != null)
                {
                    Logging.Write("Lets play coin!");
                    coin.DoGrab();
                    yield return(Coroutine.Sleep(500));

                    coin.DoDrop();
                    yield return(Coroutine.Sleep(500));
                }
            }
        }
Exemple #3
0
 /// <summary>
 ///     Determine if we should play a card with charge
 /// </summary>
 /// <returns>PlayPriority</returns>
 public static PlayPriority ShouldICharge(int attack)
 {
     if (Murloc.DoTheEnemyHasATaunter())
     {
         HSCard Taunter = Murloc.RetrieveEnemyTaunter();
         if (Taunter != null && Taunter.Health <= attack)
         {
             return(PlayPriority.High);
         }
         else
         {
             return(PlayPriority.Low);
         }
     }
     else
     {
         if (TritonHS.EnemyHeroHealthAndArmor <= attack)
         {
             return(PlayPriority.Ultra);
         }
         else
         {
             return(PlayPriority.Normal);
         }
     }
 }
        public void Init()
        {
            Console.Title         = "HearthstoneCORE";
            Console.CursorVisible = false;

            //Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            //Console.SetBufferSize(Console.LargestWindowWidth, Console.LargestWindowHeight);

            RenderComponents = new List <RenderComponent>();


            List <HSCard> cards = HSCard.GetAllCards();

            HSDeck deck = new HSDeck();

            deck.AddCards(cards);

            player1 = new HSPlayer(deck);

            Logo = new ASCIIComponent("logo", new RenderLocation(Console.WindowWidth - 5, 10));

            GameBoard = new GameBoardComponent(new RenderLocation(1, 1));

            RenderComponents.Add(GameBoard);

            //int i = 1;
            //foreach(var card in deck.Cards)
            //{
            //    card.RenderComponent = new CardComponent(card, new RenderLocation(i * 5, 6));
            //    RenderComponents.Add(card.RenderComponent);
            //    i++;
            //}

            RenderComponents.Add(Logo);
        }
Exemple #5
0
 public HSCard UseBattlecryOn(HSCard thisCard)
 {
     // Card c = GameState.Get().GetRemotePlayer().GetBattlefieldZone().GetCards().FirstOrDefault(s => s.GetRace() == TAG_RACE.MURLOC);
     // if (c != null)
     // return new HSCard(c);
     // return new HSCard(GameState.Get().GetLocalPlayer().GetBattlefieldZone().GetCards().FirstOrDefault(s => s.GetRace() == TAG_RACE.MURLOC));
     return(null);
 }
Exemple #6
0
        public HSCard GetCardToUseOn(HSCard thisCard)
        {
            if (Murloc.DoTheEnemyHasATaunter())
            {
                // Do our attack on enemy taunter
                return(Murloc.RetrieveEnemyTaunter());
            }

            // Enemy has NO taunter and we can target him => go for the face
            if (TritonHS.EnemyHero.CanBeTargetedByOpponents)
            {
                // Do our attack
                return(TritonHS.EnemyHero);
            }

            return(null);
        }
Exemple #7
0
        private void TagChange(LogLine line)
        {
            Match match = PowerTaskList.TagChangeRegex.Match(line.Log);

            if (match.Groups["entity"].Value.Equals("GameEntity"))
            {
                Game.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.STATE) && match.Groups["value"].Value.Equals("COMPLETE"))
                {
                    THS.Windows.THS.GameCore.EndGame();
                }
            }
            else if (match.Groups["entity"].Value.Equals(Game.User.PlayerName))
            {
                Game.User.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
            }
            else if (match.Groups["entity"].Value.Equals(Game.Opponent.PlayerName))
            {
                Game.Opponent.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
            }
            else if (LogRegex.EntityRegex.IsMatch(match.Groups["entity"].Value))
            {
                Match  matchEntity = LogRegex.EntityRegex.Match(match.Groups["entity"].Value);
                HSCard card        = Game.GetCard(int.Parse(matchEntity.Groups["player"].Value), int.Parse(matchEntity.Groups["id"].Value));
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.ZONE))
                {
                    //Cambiar la zona de la carta en las variables
                    Zone oldzone = card.Zone;
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                    MoveCard(card, oldzone);
                }
                else
                {
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                }
            }
            else
            {
                throw new IndexOutOfRangeException();
            }
        }
Exemple #8
0
        private void UpdatingEntity(LogLine line)
        {
            Match match       = PowerTaskList.UpdatingEntityRegex.Match(line.Log);
            Match matchEntity = LogRegex.EntityRegex.Match(match.Groups["entity"].Value);

            if (!Game.PlayersOrdered)
            {
                if (matchEntity.Groups["player"].Value.Equals("2"))
                {
                    HSPlayer tmp = Game.User;
                    Game.User           = Game.Opponent;
                    Game.Opponent       = tmp;
                    Game.User.Enemy     = false;
                    Game.Opponent.Enemy = true;
                }
                Game.PlayersOrdered = true;
            }
            HSCard card = Game.GetCard(int.Parse(matchEntity.Groups["player"].Value), int.Parse(matchEntity.Groups["id"].Value));

            if (card.CardDB == null)
            {
                card.CardDB = Cards.All[match.Groups["cardId"].Value];
            }
            while (PowerTaskList.TagRegex.IsMatch(PeekLine(PowerReader).Log))
            {
                var a = GetLine(PowerReader).Log;
                match = PowerTaskList.TagRegex.Match(a);
                if (HsConstants.StringToTag(match.Groups["tag"].Value).Equals(GameTag.ZONE))
                {
                    Zone oldzone = card.Zone;
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                    MoveCard(card, oldzone);
                }
                else
                {
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                }
            }
            IO.LogDebug("Updated card " + card, IO.DebugFile.Hs, false);
        }
Exemple #9
0
        private void FullEntityUpdating(LogLine line)
        {
            Match  match = PowerTaskList.FullEntityUpdatingRegex.Match(line.Log);
            HSCard card  = Game.GetCard(int.Parse(match.Groups["player"].Value), int.Parse(match.Groups["id"].Value));

            if (card == null)
            {
                card = CreateCard(int.Parse(match.Groups["id"].Value), match.Groups["cardId"].Value);
            }
            else
            {
                if (card.CardDB == null)
                {
                    card.CardDB = Cards.All[match.Groups["cardId"].Value];
                }
                while (PowerTaskList.TagRegex.IsMatch(PeekLine(PowerReader).Log))
                {
                    var a = GetLine(PowerReader).Log;
                    match = PowerTaskList.TagRegex.Match(a);
                    card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
                }
            }
            IO.LogDebug("Updated card " + card, IO.DebugFile.Hs, false);
        }
Exemple #10
0
 public HSCard UseBattlecryOn(HSCard thisCard)
 {
     return(null);
 }
Exemple #11
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);
                    }
                }
            }
        }
Exemple #12
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;
            }
        }
Exemple #13
0
        public static double DetermineMinionDangerousLevel(HSCard c)
        {
            double level = 0;

            level += c.Health * 0.5;
            level += c.Attack * 1.5;
            if (c.HasTaunt)
            {
                level += c.Health * 0.5;
            }

            if (c.IsPoisonous)
            {
                level += 4;
            }
            if (c.IsEnraged)
            {
                level += 5;
            }

            if (c.HasWindfury)
            {
                level += c.Attack * 1.5;
            }
            if (c.HasDivineShield)
            {
                level += 1;
            }
            if (c.Attack >= TritonHS.OurHeroHealthAndArmor)
            {
                level += 100;
            }

            switch (c.Rarity)
            {
            case TAG_RARITY.LEGENDARY:
                level += 5;
                break;

            case TAG_RARITY.EPIC:
                level += 3.5;
                break;

            case TAG_RARITY.RARE:
                level += 2;
                break;

            case TAG_RARITY.COMMON:
                level += 1;
                break;
            }

            if (c.IsSilenced)
            {
                level -= 3;
            }
            if (c.IsFrozen)
            {
                level -= 5;
            }
            if (c.HasDeathrattle)
            {
                level -= 2;
            }

            if (ImportantMinionsIds.Contains(c.Id))
            {
                level += 8;
            }

            return(level);
        }
Exemple #14
0
        private void MoveCard(HSCard card, Zone oldzone)
        {
            //Desactivado porque hay a veces que al crear la carta no funciona bien
            //if (card.Equals(oldzone)) return;
            switch (oldzone)
            {
            case Zone.INVALID:
                break;

            case Zone.PLAY:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Play.Remove(card);
                    IO.LogDebug("Removed User " + Zone.PLAY + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Play.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.PLAY + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.DECK:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Deck.Remove(card);
                    IO.LogDebug("Removed User " + Zone.DECK + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Deck.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.DECK + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.HAND:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Hand.Remove(card);
                    IO.LogDebug("Removed User " + Zone.HAND + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Hand.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.HAND + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.GRAVEYARD:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Graveyard.Remove(card);
                    IO.LogDebug("Removed User " + Zone.GRAVEYARD + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Graveyard.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.GRAVEYARD + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.REMOVEDFROMGAME:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Removed.Remove(card);
                    IO.LogDebug("Removed User " + Zone.REMOVEDFROMGAME + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Removed.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.REMOVEDFROMGAME + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.SETASIDE:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Setaside.Remove(card);
                    IO.LogDebug("Removed User " + Zone.SETASIDE + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Setaside.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.SETASIDE + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.SECRET:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Secret.Remove(card);
                    IO.LogDebug("Removed User " + Zone.SECRET + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Secret.Remove(card);
                    IO.LogDebug("Removed Opponent " + Zone.SECRET + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            default:
                throw new OverflowException();
            }
            switch ((Zone)card.Tags[GameTag.ZONE])
            {
            case Zone.INVALID:
                break;

            case Zone.PLAY:
                if (card.Controller == Game.User.PlayerId)
                {
                    if (card.CardType == CardType.HERO)
                    {
                        Game.User.Play.Add(Game.User.Hero);
                        Game.User.Hero = card;
                        IO.LogDebug("Added User Hero card id: " + card.Id, IO.DebugFile.Hs, false);
                    }
                    else
                    {
                        Game.User.Play.Add(card);
                        IO.LogDebug("Added User " + Zone.PLAY + " card id: " + card.Id, IO.DebugFile.Hs, false);
                    }
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    if (card.CardType == CardType.HERO)
                    {
                        Game.Opponent.Play.Add(Game.Opponent.Hero);
                        Game.Opponent.Hero = card;
                        IO.LogDebug("Added Opponent Hero card id: " + card.Id, IO.DebugFile.Hs, false);
                    }
                    else
                    {
                        Game.Opponent.Play.Add(card);
                        IO.LogDebug("Added Opponent " + Zone.PLAY + " card id: " + card.Id, IO.DebugFile.Hs, false);
                    }
                }
                break;

            case Zone.DECK:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Deck.Add(card);
                    IO.LogDebug("Added User " + Zone.DECK + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Deck.Add(card);
                    IO.LogDebug("Added Opponent " + Zone.DECK + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.HAND:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Hand.Add(card);
                    IO.LogDebug("Added User " + Zone.HAND + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Hand.Add(card);
                    IO.LogDebug("Added Opponent " + Zone.HAND + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.GRAVEYARD:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Graveyard.Add(card);
                    IO.LogDebug("Added User " + Zone.GRAVEYARD + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Graveyard.Add(card);
                    IO.LogDebug("Added Opponent " + Zone.GRAVEYARD + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.REMOVEDFROMGAME:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Removed.Add(card);
                    IO.LogDebug("Added User " + Zone.REMOVEDFROMGAME + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Removed.Add(card);
                    IO.LogDebug("Added Opponent " + Zone.REMOVEDFROMGAME + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.SETASIDE:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Setaside.Add(card);
                    IO.LogDebug("Added User " + Zone.SETASIDE + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Setaside.Add(card);
                    IO.LogDebug("Added Opponent " + Zone.SETASIDE + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            case Zone.SECRET:
                if (card.Controller == Game.User.PlayerId)
                {
                    Game.User.Secret.Add(card);
                    IO.LogDebug("Added User " + Zone.SECRET + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                else if (card.Controller == Game.Opponent.PlayerId)
                {
                    Game.Opponent.Secret.Add(card);
                    IO.LogDebug("Added Opponent " + Zone.SECRET + " card id: " + card.Id, IO.DebugFile.Hs, false);
                }
                break;

            default:
                throw new OverflowException();
            }
        }
Exemple #15
0
        private HSCard CreateCard(int id, string cardId)
        {
            HSCard card = new HSCard(id);
            Match  match;

            while (PowerTaskList.TagRegex.IsMatch(PeekLine(PowerReader).Log))
            {
                var a = GetLine(PowerReader).Log;
                match = PowerTaskList.TagRegex.Match(a);
                card.AddTag(match.Groups["tag"].Value, match.Groups["value"].Value);
            }
            if (cardId != "")
            {
                card.CardDB = Cards.All[cardId];
            }
            else
            {
                card.CardDB = null;
            }
            if (card.Controller == Game.User.PlayerId)
            {
                if (card.CardDB != null && card.CardType == CardType.HERO)
                {
                    Game.User.Hero = card;
                    return(card);
                }
                else if (card.CardDB != null && card.CardType == CardType.HERO_POWER)
                {
                    Game.User.HeroPower = card;
                    return(card);
                }
                switch (card.Zone)
                {
                case Zone.INVALID:
                    break;

                case Zone.PLAY:
                    Game.User.Play.Add(card);
                    break;

                case Zone.DECK:
                    Game.User.Deck.Add(card);
                    break;

                case Zone.HAND:
                    Game.User.Hand.Add(card);
                    break;

                case Zone.GRAVEYARD:
                    Game.User.Graveyard.Add(card);
                    break;

                case Zone.REMOVEDFROMGAME:
                    break;

                case Zone.SETASIDE:
                    Game.User.Setaside.Add(card);
                    break;

                case Zone.SECRET:
                    Game.User.Secret.Add(card);
                    break;

                default:
                    throw new OverflowException();
                }
            }
            else if (card.Controller == Game.Opponent.PlayerId)
            {
                if (card.CardDB != null && card.CardType == CardType.HERO)
                {
                    Game.Opponent.Hero = card;
                    return(card);
                }
                else if (card.CardDB != null && card.CardType == CardType.HERO_POWER)
                {
                    Game.Opponent.HeroPower = card;
                    return(card);
                }
                switch (card.Zone)
                {
                case Zone.INVALID:
                    break;

                case Zone.PLAY:
                    Game.Opponent.Play.Add(card);
                    break;

                case Zone.DECK:
                    Game.Opponent.Deck.Add(card);
                    break;

                case Zone.HAND:
                    Game.Opponent.Hand.Add(card);
                    break;

                case Zone.GRAVEYARD:
                    Game.Opponent.Graveyard.Add(card);
                    break;

                case Zone.REMOVEDFROMGAME:
                    break;

                case Zone.SETASIDE:
                    Game.Opponent.Setaside.Add(card);
                    break;

                case Zone.SECRET:
                    Game.Opponent.Secret.Add(card);
                    break;

                default:
                    throw new OverflowException();
                }
            }
            IO.LogDebug("Created card " + card.Id + " " + card.CardDB?.Name + " Zone: " + card.Zone + " Controller: " + card.Controller + " " + card.CardDB?.Type, IO.DebugFile.Hs, false);
            return(card);
        }
Exemple #16
0
        public IEnumerator SelectCard()
        {
            // Some verbose


            Logging.Write("------- Turn " + TritonHS.CurrentTurn + " Loop " + _loopCount + " -------");
            _loopCount++;

            // ----- First : drops
            // Try to play coin :
            yield return(TryToPlayCoin());

            // Retrieve our cards in hand which can be used
            // Can be used do a lot of check for us : enough mana, battlefield is not full to drop a minion, this spell can be used, etc...
            // Use this function to determine if a card can be played from you hand

            // Retrieve cards priority
            var lowPriority    = new List <HSCard>();
            var normalPriority = new List <HSCard>();
            var highPriority   = new List <HSCard>();
            var ultraPriority  = new List <HSCard>();

            Logging.Write("Checking hand cards priorities :");

            foreach (HSCard card in TritonHS.GetCards(CardZone.Hand).Where(s =>
                                                                           s.CanBeUsed))
            {
                // Retrieve priority
                PlayPriority priority = MurlocMap[card.Id].GetPlayPriority();
                //Logging.Write("Card " + c.GetName() + " has priority " + priority);
                switch (priority)
                {
                case PlayPriority.VeryLow:
                    //Logging.Write("\tCard " + c.GetName() + " has a very low priority");
                    break;

                case PlayPriority.Low:
                    lowPriority.Add(card);
                    Logging.Write("\tCard " + card.Name + " has a low priority");
                    break;

                case PlayPriority.Normal:
                    normalPriority.Add(card);
                    Logging.Write("\tCard " + card.Name + " has a normal priority");
                    break;

                case PlayPriority.High:
                    highPriority.Add(card);
                    Logging.Write("\tCard " + card.Name + " has a high priority!");
                    break;

                case PlayPriority.Ultra:
                    ultraPriority.Add(card);
                    Logging.Write("\tCard " + card.Name + " has an ULTRA priority!");
                    break;

                default:
                    //Dont play
                    Logging.Write("\tCard " + card.Name + " must be ignored");
                    break;
                }
            }

            if (ultraPriority.Count != 0)
            {
                HSCard best = null;

                foreach (HSCard card in ultraPriority.Where(s => s.IsMinion))
                {
                    if (best == null)
                    {
                        best = card;
                    }

                    if (card.Cost == TritonHS.CurrentMana && best.Cost != TritonHS.CurrentMana)
                    {
                        best = card;
                    }

                    // for minions priority is choosed with atk (in a first time)
                    if (best.Attack < card.Attack)
                    {
                        best = card;
                    }
                }
                Logging.Write("Lets play " + best.Name + " !");
                best.DoGrab();
                yield return(Coroutine.Sleep(500));

                best.DoDrop();
                yield return(Coroutine.Sleep(500));

                yield break;
            }
            else if (highPriority.Count != 0)
            {
                HSCard best = null;

                foreach (HSCard card in highPriority.Where(s => s.IsMinion))
                {
                    if (best == null)
                    {
                        best = card;
                    }

                    if (card.Cost == TritonHS.CurrentMana && best.Cost != TritonHS.CurrentMana)
                    {
                        best = card;
                    }

                    // for minions priority is choosed with atk (in a first time)
                    if (best.Attack < card.Attack)
                    {
                        best = card;
                    }
                }
                Logging.Write("Lets play " + best.Name + " !");
                best.DoGrab();
                yield return(Coroutine.Sleep(500));

                best.DoDrop();
                yield return(Coroutine.Sleep(500));

                yield break;
            }
            else if (normalPriority.Count != 0)
            {
                HSCard best = null;

                foreach (HSCard card in normalPriority.Where(s => s.IsMinion))
                {
                    if (best == null)
                    {
                        best = card;
                    }

                    if (card.Cost == TritonHS.CurrentMana && best.Cost != TritonHS.CurrentMana)
                    {
                        best = card;
                    }

                    // for minions priority is choosed with atk (in a first time)
                    if (best.Attack < card.Attack)
                    {
                        best = card;
                    }
                }
                Logging.Write("Lets play " + best.Name + " !");
                best.DoGrab();
                yield return(Coroutine.Sleep(500));

                best.DoDrop();
                yield return(Coroutine.Sleep(500));

                yield break;
            }
            else if (lowPriority.Count != 0)                      // Dont play low priority if coin if used [... =0 && !_coinPlayed
            {
                HSCard best = null;

                foreach (HSCard card in lowPriority.Where(s => s.IsMinion))
                {
                    if (best == null)
                    {
                        best = card;
                    }

                    if (card.Cost == TritonHS.CurrentMana && best.Cost != TritonHS.CurrentMana)
                    {
                        best = card;
                    }

                    // for minions priority is choosed with atk (in a first time)
                    if (best.Attack < card.Attack)
                    {
                        best = card;
                    }
                }
                Logging.Write("Lets play " + best.Name + " !");
                best.DoGrab();
                yield return(Coroutine.Sleep(500));

                best.DoDrop();
                yield return(Coroutine.Sleep(500));

                yield break;
            }



            // ----- Second : check hero power
            if (TritonHS.OurHeroPowerCard.CanBeUsed)
            {
                // We can use our hero power
                if (TritonHS.OurHero.Class == TAG_CLASS.WARLOCK && TritonHS.OurHeroHealthAndArmor < 10)
                // Be careful with warlock power
                {
                    Logging.Write("We are a warlock and we are low life : ignore our hero power.");
                }
                else
                {
                    Logging.Write("Lets use our hero power.");

                    // Grab card : only a grab is needed for spells
                    TritonHS.OurHeroPowerCard.DoGrab();
                    yield return(Coroutine.Sleep(1000)); // Game need to load some stuff

                    // Is a target needed for hero power?
                    // Check if target retrieved is not null (maybe we did a misstake in our RetrieveTargetForHeroPower function)
                    if (TritonHS.IsInTargetMode() && RetrieveTargetForHeroPower() != null)
                    {
                        // So, find a target
                        TritonHS.OurHeroPowerCard.DoTarget(RetrieveTargetForHeroPower());
                        yield return(Coroutine.Sleep(1000)); // Game need to load some stuff
                    }
                    yield break;
                    // Get out of this loop => return at the start of the function => check if we can use new cards (maybe we have drawn a card?)
                }
            }

            // ------ Third : use our Hero
            // Our hero can be used : our hero ATK is > 0 && we are not frozen
            // Dont focus taunters with our hero -> Focus enemy hero
            // Enemy hero can be attacked
            if (TritonHS.OurHero.CanBeUsed && !DoTheEnemyHasATaunter() &&
                TritonHS.EnemyHero.CanBeTargetedByOpponents)
            {
                TritonHS.OurHero.DoAttack(TritonHS.EnemyHero);
            }

            // ----- Fourth : attacks


            // Retrive cards on our battlefield which can be used
            // CanbeUsed function is checking if we can attack with this minion (it is not frozen, not exhausted, has atk > 0, etc...)


            foreach (HSCard card in TritonHS.GetCards(CardZone.Battlefield).Where(s => s.CanBeUsed))
            {
                HSCard BestEnnemy = null;
                //Seek if a dangerous monster is on the field

                foreach (HSCard EnnemyCard in TritonHS.GetCards(CardZone.Battlefield, false).Where(s => s.CanBeAttacked))
                {
                    double level = TradeHelper.DetermineMinionDangerousLevel(EnnemyCard);
                    Logging.Write("Level of : " + EnnemyCard.Name + " -> " + level);

                    if (DoTheEnemyHasATaunter())
                    {
                        if (EnnemyCard.HasTaunt)
                        {
                            if (EnnemyCard.Health <= card.Attack)                            //Can we kill it ?
                            {
                                // Do our attack on enemy taunter
                                BestEnnemy = EnnemyCard;
                                Logging.Write("Kill the Taunter : " + card.Name + " -> " + EnnemyCard.Name);

                                // Get out of this loop => return at the start of the function => check if we can use new cards (maybe we have drawn a card?)
                            }
                            else
                            {
                                BestEnnemy = null;
                            }
                        }
                    }
                    else
                    {
                        if (level <= 14)
                        {
                            if (EnnemyCard.Health <= card.Attack && card.Health > EnnemyCard.Attack)
                            {
                                Logging.Write("Best ennemy for : " + card.Name + " -> " + EnnemyCard.Name);
                                BestEnnemy = EnnemyCard;
                            }
                        }
                        if (level > 14 && level < 20)
                        {
                            if (EnnemyCard.Health <= card.Attack)
                            {
                                Logging.Write("Best ennemy for : " + card.Name + " -> " + EnnemyCard.Name);
                                BestEnnemy = EnnemyCard;
                            }
                        }
                        if (level >= 20)
                        {
                            if (EnnemyCard.Health / 2 <= card.Attack)
                            {
                                Logging.Write("Best ennemy for : " + card.Name + " -> " + EnnemyCard.Name);
                                BestEnnemy = EnnemyCard;
                            }
                        }
                    }
                }

                if (BestEnnemy != null)
                {
                    card.DoAttack(BestEnnemy);
                    yield return(Coroutine.Sleep(1000)); // Little sleep after an attack
                }
                else if (TritonHS.EnemyHero.CanBeTargetedByOpponents)
                {
                    // Do our attack
                    Logging.Write("Do attack : " + card.Name + " -> " + TritonHS.EnemyHero.Name);
                    card.DoAttack(TritonHS.EnemyHero);
                    yield return(Coroutine.Sleep(1000));                                    // Little sleep after an attack

                    // Get out of this loop => return at the start of the function => check if we can use new cards (maybe we have drawn a card?)
                }
                yield break;
            }


            // ----- Finally : end our turn
            // If we reach this point : all our hand cards avaible are dropped & all our usable cards on battlefield are exhausted.

            // Ensure we are not in target mode (maybe we failed somewhere)
            // If game is still in target mode, endturn will fail
            if (TritonHS.IsInTargetMode())
            {
                TritonHS.CancelTargetingMode();
            }

            sure++;
            if (sure == 2)
            {
                // End our turn
                _loopCount = 1;
                sure       = 0;
                Logging.Write("End turn.");
                TritonHS.EndTurn();
            }
            else
            {
                Logging.Write("Last check");
                yield break;
            }
        }
Exemple #17
0
 public CardComponent(HSCard Card, RenderLocation Location) : base(Location)
 {
     this.Card = Card;
 }