diff --git a/TallyCore/Adapters/XenForoAdapter.cs b/TallyCore/Adapters/XenForoAdapter.cs index fb53b865..f2c13f98 100644 --- a/TallyCore/Adapters/XenForoAdapter.cs +++ b/TallyCore/Adapters/XenForoAdapter.cs @@ -320,6 +320,8 @@ public async Task GetStartingPostNumber(IPageProvider pageProvider, IQuest if (pageProvider == null) throw new ArgumentNullException(nameof(pageProvider)); + quest.ThreadmarkPost = 0; + // Use the provided start post if we aren't trying to find the threadmarks. if (!quest.CheckForLastThreadmark) return quest.StartPost; @@ -342,9 +344,9 @@ public async Task GetStartingPostNumber(IPageProvider pageProvider, IQuest int threadmarkPostNumber = GetPostNumberOfPost(threadmarkPost); if (threadmarkPostNumber > 0) - return threadmarkPostNumber + 1; - else - return quest.StartPost; + quest.ThreadmarkPost = threadmarkPostNumber + 1; + + return quest.FirstTallyPost; } #endregion diff --git a/TallyCore/Interfaces/IQuest.cs b/TallyCore/Interfaces/IQuest.cs index 1d57d704..362e1665 100644 --- a/TallyCore/Interfaces/IQuest.cs +++ b/TallyCore/Interfaces/IQuest.cs @@ -59,6 +59,16 @@ public interface IQuest /// bool ReadToEndOfThread { get; } + /// + /// Store the found threadmark post number. + /// + int ThreadmarkPost { get; set; } + + /// + /// Return either the StartPost or the ThreadmarkPost, depending on config. + /// + int FirstTallyPost { get; } + /// /// Get the forum adapter needed to read results from the web site this /// quest is for. diff --git a/TallyCore/Quest.cs b/TallyCore/Quest.cs index 09030495..571275f0 100644 --- a/TallyCore/Quest.cs +++ b/TallyCore/Quest.cs @@ -210,6 +210,25 @@ public bool CheckForLastThreadmark /// of the thread. This is done when the EndPost is 0. /// public bool ReadToEndOfThread => EndPost < 1; + + /// + /// Property to store any found threadmark post number. + /// + public int ThreadmarkPost { get; set; } = 0; + + /// + /// Return either the StartPost or the ThreadmarkPost, depending on config. + /// + public int FirstTallyPost + { + get + { + if (CheckForLastThreadmark && ThreadmarkPost > 0) + return ThreadmarkPost; + else + return StartPost; + } + } #endregion diff --git a/TallyCore/VoteCounter.cs b/TallyCore/VoteCounter.cs index 770f877f..dc1092ff 100644 --- a/TallyCore/VoteCounter.cs +++ b/TallyCore/VoteCounter.cs @@ -55,7 +55,7 @@ public void TallyVotes(IQuest quest, List pages) where post != null let postNumber = forumAdapter.GetPostNumberOfPost(post) where forumAdapter.GetAuthorOfPost(post) != threadAuthor && - postNumber >= quest.StartPost && (quest.ReadToEndOfThread || postNumber <= quest.EndPost) + postNumber >= quest.FirstTallyPost && (quest.ReadToEndOfThread || postNumber <= quest.EndPost) select post;