Beispiel #1
0
        private IEnumerable <Choice> Choice_CastSpell()
        {
            var choices = new List <Choice>();

            // 301.1. A player who has priority may cast an artifact card from his or her hand
            // during a main phase of his or her turn when the stack is empty. Casting an artifact
            // as a spell uses the stack. (See rule 601, "Casting Spells.")

            // 302.1. A player who has priority may cast a creature card from his or her hand
            // during a main phase of his or her turn when the stack is empty. Casting a creature
            // as a spell uses the stack. (See rule 601, "Casting Spells.")

            // 303.1. A player who has priority may cast an enchantment card from his or her hand
            // during a main phase of his or her turn when the stack is empty. Casting an enchantment
            // as a spell uses the stack. (See rule 601, "Casting Spells.")

            // 306.1. A player who has priority may cast a planeswalker card from his or her hand
            // during a main phase of his or her turn when the stack is empty. Casting a planeswalker
            // as a spell uses the stack. (See rule 601, "Casting Spells.")

            // 307.1. A player who has priority may cast a sorcery card from his or her hand
            // during a main phase of his or her turn when the stack is empty. Casting a sorcery
            // as a spell uses the stack. (See rule 601, "Casting Spells.")
            var canCastNonInstants = (_gs.Phase == Phase.PreCombatMain || _gs.Phase == Phase.PostCombatMain) &&
                                     _gs.Stack.Empty &&
                                     _gs.Priority == _gs.Active;

            var activeIndex     = _gs.Players.IndexOf(_gs.Active);
            var nonInstantTypes = new CardType[] { CardType.Artifact, CardType.Creature, CardType.Enchantment,
                                                   CardType.Planeswalker, CardType.Sorcery };

            if (canCastNonInstants)
            {
                _gs.Hands[activeIndex]
                .Objects
                .Where(c => c.CardTypes.Any(ct => nonInstantTypes.Contains(ct)))
                .ForEach(c => choices.Add(new PlayCardChoice(_gs.Active, c)));
            }

            // 304.1. A player who has priority may cast an instant card from his or her hand.
            // Casting an instant as a spell uses the stack. (See rule 601, "Casting Spells.")
            _gs.Hands[activeIndex]
            .Objects
            .Where(c => c.CardTypes.Contains(CardType.Instant))
            .ForEach(c => choices.Add(new PlayCardChoice(_gs.Active, c)));

            return(choices);
        }