Example #1
0
 public static bool Contains(this SecretZone s, Card c)
 {
     for (int i = 0; i < s.Count; ++i)
     {
         if (s[i].Card.Name == c.Name)
         {
             return(true);
         }
     }
     return(false);
 }
Example #2
0
 public static bool Contains(this SecretZone s, Func <Spell, bool> p)
 {
     for (int i = 0; i < s.Count; ++i)
     {
         if (p(s[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
        private SecretZone GetSecretZone(SabberStoneCore.Model.Zones.SecretZone zone)
        {
            var result = new SecretZone();
            var span   = zone.GetSpan();

            for (int i = 0; i < span.Length; i++)
            {
                result.Entities.Add(GetPlayable(span[i], true));
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// Initializes this agent's estimation of the opponent
        /// </summary>
        /// <param name="opponent"></param>
        /// <returns></returns>
        void SetupOpponent(Game game)
        {
            BlindGame     = game.Clone();
            Opponent      = BlindGame.CurrentOpponent;
            Opponent.Game = BlindGame;

            OpponentDeck     = DeckQuery.GetMostPopular(Opponent.HeroClass);
            OpponentDeckZone = new DeckZone(Opponent)
            {
                Controller = Opponent
            };

            Opponent.Deck     = OpponentDeck.Clone();
            Opponent.DeckZone = OpponentDeckZone;

            OpponentGraveyardZone = new GraveyardZone(Opponent);
            OpponentSecretZone    = new SecretZone(Opponent);

            OpponentSet = true;
        }
Example #5
0
        private int getActiveSecrits(Controller player)
        {
            SecretZone secretZone = player.SecretZone;

            return(secretZone.Count);
        }
Example #6
0
        /// <summary>
        /// Updates this agent's estimation of the opponent
        /// </summary>
        void UpdateOpponent(int handSize)
        {
            Opponent.Game     = BlindGame;
            Opponent.Deck     = OpponentDeck.Clone();
            Opponent.DeckZone = OpponentDeckZone.Clone(Opponent);
            //OpponentDeckZone.Controller = Opponent;

            OpponentHandZone = new HandZone(Opponent);
            //{
            //	Controller = Opponent
            //};

            foreach (Card card in OpponentDeck)
            {
                Entity.FromCard(Opponent, card, null, OpponentDeckZone);
            }

            foreach (Card card in PlayedSoFar)
            {
                if (OpponentDeckZone.Contains(card))
                {
                    OpponentDeckZone.Remove(card);
                }
            }

            for (int i = 0; i < handSize; ++i)
            {
                IPlayable rnd = OpponentDeckZone.Random;
                OpponentDeckZone.Remove(rnd);
                rnd.Controller = OpponentHandZone.Controller;
                OpponentHandZone.Add(rnd);
            }

            Opponent.HandZone     = OpponentHandZone.Clone(Opponent);
            OpponentGraveyardZone = BlindGame.CurrentOpponent.GraveyardZone.Clone(Opponent);

            if (BlindGame.CurrentOpponent.SecretZone.Count == 0)
            {
                OpponentSecretZone = new SecretZone(Opponent);
            }

            else if (BlindGame.CurrentOpponent.SecretZone.Count == 1 && BlindGame.CurrentOpponent.SecretZone.Contains(s => s.IsQuest))
            {
                OpponentSecretZone = BlindGame.CurrentOpponent.SecretZone.Clone(Opponent);
            }

            else
            {
                OpponentSecretZone = new SecretZone(Opponent);
                if (!OpponentDeck.Contains(c => c.IsSecret))
                {
                    AddBlindSecrets();
                }

                else
                {
                    var secretsPlayed = OpponentGraveyardZone.Where(p => p.Card.IsSecret).ToList();
                    if (secretsPlayed != null)
                    {
                        List <string> secrets = GetSecrets(Opponent.HeroClass);
                        foreach (Spell s in secretsPlayed)
                        {
                            if (secretsPlayed.Count(s) > 2)
                            {
                                secrets.Remove(s.Card.Name);
                            }
                        }

                        if (secrets.Count != 0)
                        {
                            AddBlindSecrets(secrets);
                        }

                        else
                        {
                            AddBlindSecrets(GetSecrets(Opponent.HeroClass));
                        }
                    }
                }
            }

            BlindGame.Player2              = Opponent;
            BlindGame.CurrentPlayer.Game   = BlindGame;
            BlindGame.CurrentOpponent.Game = BlindGame;
        }