コード例 #1
0
        private void btnUsCast_Click(object sender, EventArgs e)
        {
            Card temp = (Card)lbxUsHand.SelectedItem;

            if (temp != null)
            {
                lbxUsHand.Items.Remove(temp);
                if (temp is Land)
                {
                    Land l = temp as Land;
                    l.Cast();
                    manaForTurn = true;
                    lbxUsField.Items.Add(temp);
                }
                else if (temp is Creature)
                {
                    Creature c = temp as Creature;
                    c.Cast();
                    lbxUsField.Items.Add(temp);
                    c.EnterBattlefield();
                    foreach (Card ca in lbxUsField.Items)
                    {
                        if (ca is Creature)
                        {
                            Creature cr = ca as Creature;
                            cr.OtherEnterBattlefield(c);
                        }
                    }
                }
                else if (temp is ArtifactEnchant)
                {
                    ArtifactEnchant ae = temp as ArtifactEnchant;
                    ae.Cast();
                    lbxUsField.Items.Add(temp);
                }
                else
                {
                    Spell sp = temp as Spell;
                    sp.Cast();
                    lbxUsGraveyard.Items.Add(temp);
                }
            }
        }
コード例 #2
0
        public void generateMeta()
        {
            meta            = new stateMeta();
            meta.playerLife = this.playerHealth;
            meta.enemyLife  = this.enemyHealth;
            foreach (Card temp in this.PlayerField)
            {
                if (temp is Creature)
                {
                    Creature c = temp as Creature;
                    meta.totalPow   += (c.Power);
                    meta.totalTough += (c.Toughness);
                    ++meta.usCreatureCount;
                }
            }
            foreach (Card temp in this.EnemyField)
            {
                if (temp is Creature)
                {
                    Creature c = temp as Creature;
                    meta.enemyTotalPow   += c.Power;
                    meta.enemyTotalTough += c.Toughness;
                    ++meta.enemyCreatureCount;
                }
            }
            if (this.active == activePlayer.Us)
            {
                foreach (Card temp in this.Attacking)
                {
                    if (temp is Creature)
                    {
                        Creature c = temp as Creature;
                        meta.totalPow   += (c.Power);
                        meta.totalTough += (c.Toughness);
                        ++meta.usCreatureCount;
                    }
                }
                foreach (Card temp in this.Defending)
                {
                    if (temp is Creature)
                    {
                        Creature c = temp as Creature;
                        meta.enemyTotalPow   += c.Power;
                        meta.enemyTotalTough += c.Toughness;
                        ++meta.enemyCreatureCount;
                    }
                }
            }
            else
            {
                foreach (Card temp in this.Defending)
                {
                    if (temp is Creature)
                    {
                        Creature c = temp as Creature;
                        meta.totalPow   += (c.Power);
                        meta.totalTough += (c.Toughness);
                        ++meta.usCreatureCount;
                    }
                }
                foreach (Card temp in this.Attacking)
                {
                    if (temp is Creature)
                    {
                        Creature c = temp as Creature;
                        meta.enemyTotalPow   += c.Power;
                        meta.enemyTotalTough += c.Toughness;
                        ++meta.enemyCreatureCount;
                    }
                }
            }

            foreach (Card temp in this.PlayerField)
            {
                if (temp is Land)
                {
                    Land l = temp as Land;
                    if (!l.Tapped)
                    {
                        ++meta.totalMana;
                    }
                }
            }
        }
コード例 #3
0
        /* public static Card Target(ArtifactEnchant card, GameState state)
         * {
         *   return null;
         * }*/

        public static Card Target(TargetEffects.ReturnToHand RtoH, GameState state)
        {
            LinkedList <Land> landList = new LinkedList <Land>();
            int  plainsCount           = 0;
            int  forestCount           = 0;
            Land target = null;

            foreach (Card c in state.PlayerField)
            {
                if (c is Land)
                {
                    landList.AddLast((Land)c);
                }
            }

            foreach (Land L in landList)
            {
                if (L is KnightCards.Plains)
                {
                    ++plainsCount;
                }
                else
                {
                    ++forestCount;
                }
            }

            if (plainsCount >= forestCount * 2)
            {
                foreach (Land l in landList)
                {
                    if (l is KnightCards.Plains && l.Tapped)
                    {
                        target = l;
                    }
                }
                LinkedListNode <Land> node = landList.First;
                target = node.Value;
                while (!(target is KnightCards.Plains))
                {
                    node   = node.Next;
                    target = node.Value;
                }
            }
            else
            {
                foreach (Land l in landList)
                {
                    if (l is KnightCards.Forest && l.Tapped)
                    {
                        target = l;
                    }
                }
                LinkedListNode <Land> node = landList.First;
                target = node.Value;
                while (!(target is KnightCards.Forest))
                {
                    node   = node.Next;
                    target = node.Value;
                }
            }


            return(target);
        }