Ejemplo n.º 1
0
        private void FindDecklist(RedditSharp.Things.Comment comment, ref string message, ref int numMatches)
        {
            _syntaxRegex = @"\d{1,2}\s[A-Z].*[a-z]\s";
            string tempMessage    = "";
            int    tempNumMatches = 0;
            int    totalAmount    = 0;

            foreach (Match match in Regex.Matches(comment.Body, _syntaxRegex))
            {
                string amountString = match.Value.Substring(0, 2);
                int    amount       = Convert.ToInt32(amountString);
                totalAmount += amount;
                string      cardName = match.Value.Trim(' ').Trim(' ').Substring(2);
                EternalCard card     = _cards.Where((x) => x.Name == cardName).FirstOrDefault();
                if (card != null)
                {
                    tempMessage += @"[" + cardName + "](" + card.ImageUrl + ") - [EWC](https://eternalwarcry.com/cards/details/" + card.SetNumber + "-" + card.EternalID + "/" + card.Name.ToLower().Replace(' ', '-') + ")  " + Environment.NewLine;
                    tempNumMatches++;
                }
            }

            if (totalAmount == 45 || totalAmount == 75)
            {
                message    += tempMessage;
                numMatches += tempNumMatches;
            }
        }
Ejemplo n.º 2
0
        static void RecursivelyInspectComments(Func <Subs.Post, RedditSharp.Things.Comment, Subs.Comment, Subs.Comment> commentFunc,
                                               Subs.Post post,
                                               RedditSharp.Things.Comment redditComment,
                                               Subs.Comment parentComment = null)
        {
            if (redditComment.Kind == "more")
            {
                return;
            }

            if (redditComment.Kind != "t1")
            {
                return;
            }

            var comment = commentFunc(post, redditComment, parentComment);

            if (comment == null)
            {
                return;
            }

            foreach (var childRedditComment in redditComment.Comments)
            {
                RecursivelyInspectComments(commentFunc, post, childRedditComment, comment);
            }
        }
Ejemplo n.º 3
0
 private void FindCardsInBrackets(RedditSharp.Things.Comment comment, ref string message, ref int numMatches)
 {
     foreach (Match match in Regex.Matches(comment.Body, _syntaxRegex))
     {
         string      cardName = match.Value.Trim('[').Trim(']');
         EternalCard card     = _cards.Where((x) => x.Name == cardName).FirstOrDefault();
         if (card != null)
         {
             numMatches++;
             message += @"[" + cardName + "](" + card.ImageUrl + ") - [EWC](https://eternalwarcry.com/cards/details/" + card.SetNumber + "-" + card.EternalID + "/" + card.Name.ToLower().Replace(' ', '-') + ")  " + Environment.NewLine;
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This is used when getting a new comment from a source and predicting its value
 /// </summary>
 /// <param name="id"></param>
 /// <param name="comment"></param>
 /// <param name="parentId"></param>
 public Comment(int id, RedditSharp.Things.Comment comment, int parentId)
     : this(id, Regex.Replace(comment.Body, @"[\n-]", ""), 0, 0, 0, comment.Upvotes, comment.Downvotes, 0.5f, parentId)
 {
     Predict();
 }
Ejemplo n.º 5
0
 public Comment(int id, RedditSharp.Things.Comment comment, float userScore, int parentId)
     : this(id, Regex.Replace(comment.Body, @"[\n-]", ""), 0, 0, 0, comment.Upvotes, comment.Downvotes, userScore, parentId)
 {
 }