Пример #1
0
        private static void ManaPayment(Card c, GameState state)
        {
            tbxDirections = tbxReal;
            int[] manaPool  = manaAvailable(state);
            int   forests   = 0;
            int   plains    = 0;
            int   mountains = 0;
            int   Selesnya  = 0;
            int   Treetop   = 0;
            int   sejiri    = 0;

            foreach (Card ca in state.PlayerField)
            {
                if (!ca.Tapped)
                {
                    if (ca is KnightCards.Forest)
                    {
                        forests++;
                    }
                    else if (ca is KnightCards.Plains)
                    {
                        plains++;
                    }
                    else if (ca is DragonCards.Mountain)
                    {
                        mountains++;
                    }
                    else if (ca is KnightCards.Selesnya_Sanctuary)
                    {
                        Selesnya++;
                    }
                    else if (ca is KnightCards.Treetop_Village)
                    {
                        Treetop++;
                    }
                    else if (ca is KnightCards.Sejiri_Steppe)
                    {
                        sejiri++;
                    }
                }
            }
            if ((c.ManaByColor[(int)Card.manaColor.White] > 0 || c.ManaByColor[(int)Card.manaColor.Green] > 0) && Selesnya > 0 && c.ConvManaCost > 1)
            {
                AI.sendDirections("Tap Selesnya Sanctuary for W and G");
                int provide = 2;
                if (c.ManaByColor[(int)Card.manaColor.Green] > 0 && provide > 0)
                {
                    --provide;
                    --c.ManaByColor[(int)Card.manaColor.Green];
                }
                if (c.ManaByColor[(int)Card.manaColor.White] > 0 && provide > 0)
                {
                    --provide;
                    --c.ManaByColor[(int)Card.manaColor.White];
                }
                if (provide > 0)
                {
                    --provide;
                    --c.ManaByColor[(int)Card.manaColor.Colorless];
                }
            }
            while (c.ManaByColor[(int)Card.manaColor.Green] > 0)
            {
                if (Treetop > 0)
                {
                    AI.sendDirections("Tap treetop village for G");
                    Treetop--;
                    c.ManaByColor[(int)Card.manaColor.Green]--;
                }
                else if (forests > 0)
                {
                    AI.sendDirections("Tap Forest for F");
                    forests--;
                    c.ManaByColor[(int)Card.manaColor.Green]--;
                }
            }
            while (c.ManaByColor[(int)Card.manaColor.White] > 0)
            {
                if (sejiri > 0)
                {
                    AI.sendDirections("Tap Sejiri Steppe for W");
                    sejiri--;
                    c.ManaByColor[(int)Card.manaColor.White]--;
                }
                else if (plains > 0)
                {
                    AI.sendDirections("Tap Plains for W");
                    plains--;
                    c.ManaByColor[(int)Card.manaColor.White]--;
                }
            }
            while (c.ManaByColor[(int)Card.manaColor.Red] > 0)
            {
                AI.sendDirections("Tap Mountain for Red");
                mountains--;
                c.ManaByColor[(int)Card.manaColor.Red]--;
            }
            while (c.ManaByColor[(int)Card.manaColor.Colorless] > 0)
            {
                if (c.GetType().FullName.Contains("Knight"))
                {
                    if ((plains + sejiri) > ((forests + Treetop) * 2))
                    {
                        if (sejiri > 0)
                        {
                            AI.sendDirections("Tap Sejiri Steppe for W");
                            sejiri--;
                            c.ManaByColor[(int)Card.manaColor.Colorless]--;
                        }
                        else
                        {
                            AI.sendDirections("Tap Plains for W");
                            plains--;
                            c.ManaByColor[(int)Card.manaColor.Colorless]--;
                        }
                    }
                    else
                    {
                        if (Treetop > 0)
                        {
                            AI.sendDirections("Tap Treetop Village for G");
                            Treetop--;
                            c.ManaByColor[(int)Card.manaColor.Colorless]--;
                        }
                        else
                        {
                            AI.sendDirections("Tap Forest for G");
                            forests--;
                            c.ManaByColor[(int)Card.manaColor.Colorless]--;
                        }
                    }
                }
                else if (c.GetType().FullName.Contains("Dragon"))
                {
                    AI.sendDirections("Tap Mountain for Red");
                    mountains--;
                    c.ManaByColor[(int)Card.manaColor.Colorless]--;
                }
            }
            tbxDirections = tbxFake;
        }
Пример #2
0
        public static void Attack(GameState state)
        {
            getNewState();
            state       = MasterState;
            ActiveState = MasterState;
            int usCreatureCount    = 0;
            int enemyCreatureCount = 0;
            int enemyTotalPower    = 0;
            int totalTough         = 0;

            foreach (Card c in state.EnemyField)
            {
                if (c is Creature && !c.Tapped)
                {
                    enemyCreatureCount++;
                    if ((c as Creature).abilities.Contains <Creature.CreatureAbilities>(Creature.CreatureAbilities.DoubleStrike))
                    {
                        enemyTotalPower += (c as Creature).Power;
                    }
                    enemyTotalPower += (c as Creature).Power;
                }
            }

            foreach (Card c in state.PlayerField)
            {
                if (c is Creature && !c.Tapped && !(c as Creature).SummonSick)
                {
                    usCreatureCount++;

                    if ((c as Creature).abilities.Contains <Creature.CreatureAbilities>(Creature.CreatureAbilities.DoubleStrike))
                    {
                        totalTough -= (c as Creature).Toughness;
                    }
                    totalTough += (c as Creature).Toughness;
                }
            }

            if ((usCreatureCount) == 0)
            {
                AI.sendDirections("Nothing to attack with");
            }
            else if (enemyCreatureCount == 0)
            {
                int atk = 0;
                foreach (Card c in state.PlayerField)
                {
                    if (c is Creature && !c.Tapped)
                    {
                        Creature cr = c as Creature;
                        if (!cr.abilities.Contains <Creature.CreatureAbilities>(Creature.CreatureAbilities.Defender) && !cr.Tapped && !cr.SummonSick)
                        {
                            atk++;
                            AI.sendDirections(String.Format("Attack with {0}", cr.CName));
                        }
                    }
                }
                if (atk == 0)
                {
                    AI.sendDirections("No legal attackers");
                }
            }
            else if ((enemyTotalPower / enemyCreatureCount) > (totalTough / usCreatureCount))
            {
                AI.sendDirections("Don't Attack");
            }
            else
            {
                Creature eBiggest = null;
                foreach (Card c in state.EnemyField)
                {
                    if (c is Creature)
                    {
                        Creature cr = c as Creature;
                        if (eBiggest == null)
                        {
                            eBiggest = cr;
                        }
                        else
                        {
                            if (cr.Power > eBiggest.Power)
                            {
                                eBiggest = cr;
                            }
                        }
                    }
                }
                Creature blocker = findBlockerDuringAttack(eBiggest, state);
                int      atk     = 0;
                foreach (Card c in state.PlayerField)
                {
                    if (c is Creature && c != blocker && !(c.Tapped) && !(c as Creature).abilities.Contains <Creature.CreatureAbilities>(Creature.CreatureAbilities.Defender))
                    {
                        if (!(c as Creature).SummonSick)
                        {
                            atk++;
                            AI.sendDirections(String.Format("Attack with {0}", c));
                        }
                    }
                }
                if (atk == 0)
                {
                    AI.sendDirections("Don't attack, stay on defense");
                }
            }
        }