User:KitanBot/Completed Tasks/Questlong

Task
There is a Bot Request to deprecate questtb for questlong.

Issues

 * This technically created some broken links for quests we didn't have but that we had the Thott ID for. Concensus from IRC was that that was fine.

Algorithm
namespace WikiUpdateAlgorithm {   public class WikiUpdateAlgorithmQuestlong : IWikiUpdaterAlgorithm {       public string UpdateWiki(string CurrentWiki) {           //Objects Required string SearchWiki = CurrentWiki.ToLower; StringBuilder Current = new StringBuilder(CurrentWiki); Dictionary Replacements = new Dictionary;

//Primatives string Template = "{{questtb"; int Position; int EndPosition; bool Continue; int StartQuestNumPos; int EndQuestNumPos; string[] QuestInfo;

Position = 0; Continue = true;

while (Continue) {               Position = SearchWiki.IndexOf(Template, Position); EndPosition = 0;

if (Position >= 0) {                   EndPosition = SearchWiki.IndexOf("}}", Position);

if (EndPosition > 0) {                       QuestInfo = CurrentWiki.Substring(Position, EndPosition - Position).Split('|');

if (!Replacements.ContainsKey(CurrentWiki.Substring(Position, EndPosition + 2 - Position))) {                           Replacements.Add(CurrentWiki.Substring(Position, EndPosition + 2 - Position), "{{Questlong|" + QuestInfo[1] + "|" + QuestInfo[2] + "|" + QuestInfo[3] + "}}"); }                   }                    Position = EndPosition; }               else {                   Continue = false; }           }

foreach (KeyValuePair Replacement in Replacements) {               Current.Replace(Replacement.Key, Replacement.Value); }

return Current.ToString; }       ///         /// Summary of the update ///        /// String public string UpdateSummary {           return "Update page from  to ."; }   } }