示例#1
0
        private static GameState Cast(Card C, GameState state)
        {
            GameState newState = new GameState(state, C);

            ActiveState = newState;
            Card            targ = null;
            Creature        cr   = null;
            Spell           sp   = null;
            ArtifactEnchant ae   = null;

            foreach (Card ca in newState.PlayerHand)
            {
                if (ca.GetType() == C.GetType())
                {
                    targ = ca;
                }
            }
            if (targ != null)
            {
                targ.Hand.Remove(targ);
                targ.Field.Add(targ);
                if (targ is Creature)
                {
                    cr = targ as Creature;
                    cr.Cast();

                    cr.EnterBattlefield();
                    foreach (Card ca in ActiveState.PlayerField)
                    {
                        if (ca is Creature)
                        {
                            Creature cre = ca as Creature;
                            cre.OtherEnterBattlefield(cr);
                        }
                    }
                }
                else if (targ is Spell)
                {
                    sp = targ as Spell;
                    sp.Field.Remove(sp);
                    sp.Graveyard.Add(sp);
                    sp.Cast();
                }
                else if (targ is ArtifactEnchant)
                {
                    ae = targ as ArtifactEnchant;
                    ae.Cast();
                    ae.EnterBattlefield();
                }
            }

            return(newState);
        }
        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);
                }
            }
        }