コード例 #1
0
        public string ExplainCardCommand(string args)
        {
            DeckOfManyThingsFunctions functions = new DeckOfManyThingsFunctions();
            var message = new StringBuilder();

            functions.CardName = args;
            KeyValuePair <string, string>?definition = functions.GetCardDefinitionByName();

            message.AppendLine($"__***{definition.Value.Key}***__");
            message.AppendLine($"*{definition.Value.Value}*");

            return(message.ToString());
        }
コード例 #2
0
        public string DrawCardCommand(IUser user,
                                      int cardsToDraw,
                                      bool includeEffects,
                                      bool useExpandedDeck,
                                      List <string> exclusions)
        {
            DeckOfManyThingsFunctions functions = new DeckOfManyThingsFunctions();
            var message = new StringBuilder();

            functions.CardsToDraw     = cardsToDraw;
            functions.UseExpandedDeck = useExpandedDeck;
            functions.CardsToExclude  = exclusions;

            if (!functions.EnoughCardsAvailable())
            {
                return("There are not enough unique cards to draw!");
            }

            message.AppendLine($"**{user.Mention} has drawn {cardsToDraw} from the Deck of Many Things...**");
            for (int i = 1; i <= cardsToDraw; i++)
            {
                if (includeEffects)
                {
                    functions.CardId = functions.CardNumberGenerator();
                    var drawnCard = functions.GetCardDefinitionById();
                    while (exclusions.Contains(drawnCard.Key))
                    {
                        functions.CardId = functions.CardNumberGenerator();
                        drawnCard        = functions.GetCardDefinitionById();
                    }
                    message.AppendLine($"They have drawn... **{drawnCard.Key}**");
                    message.AppendLine($"*{drawnCard.Value}*");
                    exclusions.Add(drawnCard.Key);
                }
                else
                {
                    functions.CardId = functions.CardNumberGenerator();
                    var drawnCard = functions.GetCardDefinitionById();
                    while (exclusions.Contains(drawnCard.Key))
                    {
                        functions.CardId = functions.CardNumberGenerator();
                        drawnCard        = functions.GetCardDefinitionById();
                    }
                    message.AppendLine($"They have drawn... **{drawnCard.Key}**");
                    exclusions.Add(drawnCard.Key);
                }
            }

            return(message.ToString());
        }