コード例 #1
0
        public static DuelTask SearchDeckForTask <T>(Card source, int numberOfCardsToTake = 1, bool optionalSearch = true) where T : Card
        {
            string description = $"{source.Name}: Take ";

            description += numberOfCardsToTake > 1 ? $"{numberOfCardsToTake} {GetTypeString(typeof(T))}s" : $"a {GetTypeString(typeof(T))}";
            description += " from your deck and put it into your hand.";
            Func <T[]> allArgs = () => source.Owner.Deck.GetAll <T>();

            return(new DuelTask(
                       description,
                       (args) => {
                T[] allCards = allArgs();
                Zone hand = source.Owner.Hand;
                for (int i = 0; i < numberOfCardsToTake && allCards.Length > 0; i++)
                {
                    if (i >= args.Length)
                    {
                        if (optionalSearch)
                        {
                            break;
                        }
                        else
                        {
                            hand.Put(allCards[0]);
                        }
                    }
                    else
                    {
                        hand.Put((T)args[i]);
                    }
                    allCards = allArgs();
                }
                source.Owner.Deck.Shuffle();
            },
                       optionalSearch,
                       allArgs
                       ));
        }
コード例 #2
0
        /// <typeparam name="T">Card type that can be put into the Graveyard.</typeparam>
        public static DuelTask ManaZoneToGraveyardTask <T>(Card source, int numberOfCardsToTransfer = 1, bool optionalTransfer = true) where T : Card
        {
            string description = "Put ";

            description += numberOfCardsToTransfer > 1 ? $"{numberOfCardsToTransfer} {GetTypeString(typeof(T))}s" : $"a {GetTypeString(typeof(T))}";
            description += " from your mana zone into your graveyard.";
            Func <T[]> allArgs = () => source.Owner.ManaZone.GetAll <T>();

            return(new DuelTask(
                       description,
                       (args) => {
                T[] allCards = allArgs();
                Zone graveyard = source.Owner.Graveyard;
                for (int i = 0; i < numberOfCardsToTransfer && allCards.Length > 0; i++)
                {
                    if (i >= args.Length)
                    {
                        if (optionalTransfer)
                        {
                            break;
                        }
                        else
                        {
                            graveyard.Put(allCards[0]);
                        }
                    }
                    else
                    {
                        graveyard.Put((T)args[i]);
                    }
                    allCards = allArgs();
                }
            },
                       optionalTransfer,
                       allArgs
                       ));
        }
コード例 #3
0
        public Duelist(Game game, params Type[] cards) {
            Game = game;
            DuelAction = new DuelAction(this);
            TaskList = new DuelTaskList(this);
            Deck = new Zone(this);
            Hand = new Hand(this);
            ShieldZone = new ShieldZone(this);
            ManaZone = new Zone(this);
            BattleZone = new BattleZone(this);
            Graveyard = new Zone(this);

            AllCards = new Card[cards.Length];
            int i = 0;
            foreach (Type card in cards) {
                Card createdCard = (Card)Activator.CreateInstance(card, this);
                AllCards[i] = createdCard;
                Deck.Put(createdCard);
                i += 1;
            }
        }