示例#1
0
        protected override bool ApplyAction()
        {
            var      mtg      = MTG.Instance;
            int      player   = GetPlayerFromSource();
            ManaPool manaPool = mtg.players[player].manaPool;
            bool     manaPaid = false;

            while (!manaPaid)
            {
                List <ManaSymbol> possibleMana = new List <ManaSymbol>();
                foreach (var manaPoolMana in manaPool)
                {
                    if (mana.CanThisPayForMe(manaPoolMana))
                    {
                        possibleMana.Add(manaPoolMana);
                    }
                }
                var choice = new ManaChoice(possibleMana, mana, player);
                mtg.PushChoice(choice);
                if (choice.Cancelled)
                {
                    RevertAllChildren();
                    return(false);
                }

                var chosen = choice.FirstChoice;

                switch (chosen.type)
                {
                case (ManaChoiceOption.OptionType.UseMana):
                    if (!PushChild(new RemoveManaEvent(source, player, chosen.manaSymbol)))
                    {
                        RevertAllChildren();
                        return(false);
                    }
                    manaPaid = true;
                    break;

                case (ManaChoiceOption.OptionType.ActivateManaAbility):
                    if (!PushChild(new ActivateAbilityEvent(chosen.manaAbilitySource, chosen.manaAbility)))
                    {
                        RevertAllChildren();
                        return(false);
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            return(true);
        }