コード例 #1
0
ファイル: Tease.cs プロジェクト: d3vi0n/TeaseMe
        private string GetTarget(TeaseAction action)
        {
            var possibilities = new List <string>();

            var match = Regex.Match(action.Target, @"(?<pre>.*)\((?<min>\d+)\.\.(?<max>\d+)\)(?<post>.*)");

            if (match.Success)
            {
                int min = Convert.ToInt32(match.Groups["min"].Value);
                int max = Convert.ToInt32(match.Groups["max"].Value);
                for (var i = min; i < max; i++)
                {
                    string pageId = String.Format("{0}{1}{2}", match.Groups["pre"].Value, i, match.Groups["post"].Value);
                    if (Pages.Exists(p => p.Id.Equals(pageId)) && AllowedToShowPage(pageId))
                    {
                        possibilities.Add(pageId);
                    }
                }
            }
            else
            {
                string pageId = action.Target;
                if (Pages.Exists(p => p.Id.Equals(pageId)) && AllowedToShowPage(pageId))
                {
                    possibilities.Add(pageId);
                }
            }
            if (possibilities.Count == 0)
            {
                throw new ArgumentException(String.Format("Page '{0}' does not exist or is already marked as seen.\n\nFor the author of this tease:\nUse the set/unset commands to to correct this situation.", action.Target));
            }
            return(possibilities[random.Next(possibilities.Count)]);
        }
コード例 #2
0
ファイル: Tease.cs プロジェクト: d3vi0n/TeaseMe
        public void ExecuteTeaseAction(TeaseAction action)
        {
            if (Settings.AutoSetPageWhenSeen)
            {
                SetFlags(currentPage.Id);
            }

            if (!String.IsNullOrEmpty(currentPage.SetFlags))
            {
                SetFlags(currentPage.SetFlags);
            }
            if (!String.IsNullOrEmpty(currentPage.UnsetFlags))
            {
                UnsetFlags(currentPage.UnsetFlags);
            }

            if (action != null)
            {
                if (!String.IsNullOrEmpty(action.SetFlags))
                {
                    SetFlags(action.SetFlags);
                }
                if (!String.IsNullOrEmpty(action.UnsetFlags))
                {
                    UnsetFlags(action.UnsetFlags);
                }

                var target = GetTarget(action);

                NavigateToPage(target);
            }
        }
コード例 #3
0
ファイル: Tease.cs プロジェクト: TakenagaT/TeaseMe
        public void ExecuteTeaseAction(TeaseAction action)
        {
            if (Settings.AutoSetPageWhenSeen)
            {
                SetFlags(currentPage.Id);
            }

            if (!String.IsNullOrEmpty(currentPage.SetFlags))
            {
                SetFlags(currentPage.SetFlags);
            }
            if (!String.IsNullOrEmpty(currentPage.UnsetFlags))
            {
                UnsetFlags(currentPage.UnsetFlags);
            }

            if (action != null)
            {
                if (!String.IsNullOrEmpty(action.SetFlags))
                {
                    SetFlags(action.SetFlags);
                }
                if (!String.IsNullOrEmpty(action.UnsetFlags))
                {
                    UnsetFlags(action.UnsetFlags);
                }

                var target = GetTarget(action);

                NavigateToPage(target);
            }
        }
コード例 #4
0
ファイル: Tease.cs プロジェクト: TakenagaT/TeaseMe
        private string GetTarget(TeaseAction action)
        {
            var possibilities = new List<string>();

            var match = Regex.Match(action.Target, @"(?<pre>.*)\((?<min>\d+)\.\.(?<max>\d+)\)(?<post>.*)");
            if (match.Success)
            {
                int min = Convert.ToInt32(match.Groups["min"].Value);
                int max = Convert.ToInt32(match.Groups["max"].Value);
                for (var i = min; i <= max; i++)
                {
                    string pageId = String.Format("{0}{1}{2}", match.Groups["pre"].Value, i, match.Groups["post"].Value);
                    if (Pages.Exists(p => p.Id.Equals(pageId)) && AllowedToShowPage(pageId))
                    {
                        possibilities.Add(pageId);
                    }
                }
            }
            else
            {
                if (Pages.Exists(p => p.Id.Equals(action.Target)))
                {
                    return action.Target;
                }
            }
            if (possibilities.Count == 0)
            {
                throw new ArgumentException(String.Format("Page '{0}' does not exist or is already marked as seen.\n\nFor the author of this tease:\nUse the set/unset commands to to correct this situation.", action.Target));
            }
            return possibilities[random.Next(possibilities.Count)];
        }
コード例 #5
0
ファイル: TeaseForm.cs プロジェクト: TakenagaT/TeaseMe
 private void ExecuteTeaseAction(TeaseAction teaseAction)
 {
     try
     {
         CurrentTease.ExecuteTeaseAction(teaseAction);
     }
     catch (Exception err)
     {
         MessageBox.Show("Error: " + err.Message);
     }
 }