Ejemplo n.º 1
0
        public static StoryModel Create(IStoryReader reader)
        {
            var model = new StoryModel();

            model.Story = reader.Read();
            return(model.Story != null ? model : null);
        }
Ejemplo n.º 2
0
 public int SetPageNumberLabel(StoryModel model, int num)
 {
     if (num < this.PageNumber && model.MaxPage == PageNumber)
     {
         model.MaxPage--;
         PageNumber = num;
         if (num > model.MaxPage)
         {
             model.MaxPage = num;
         }
     }
     return(PageNumber);
 }
Ejemplo n.º 3
0
        bool FlagIsUsed(string expression)
        {
            string flag = StoryModel.ExtractFlagNameFromExpression(expression);

            for (int i = 0; i < Flags.Count; i++)
            {
                string n = StoryModel.ExtractFlagNameFromExpression(Flags[i]);
                if (n == flag)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns true if the given 'if' and 'not if' conditions are satisfied by the given list of flags.
        /// </summary>
        public static bool DoesArrayMeetConditions(List <string> ifConditions, List <string> notIfConditions, List <FlagValue> flags)
        {
            var success = false;

            for (var i = 0; i < ifConditions.Count && !success; i++)
            {
                success = !StoryModel.Test(ifConditions [i], flags);
            }
            for (var i = 0; i < notIfConditions.Count && !success; i++)
            {
                success = StoryModel.Test(notIfConditions [i], flags);
            }
            return(!success);
        }
Ejemplo n.º 5
0
        public void EditFlag(string flag, StoryModel model)
        {
            int index = Flags.IndexOf(flag);

            if (index == -1)
            {
                Flags.Add(flag);
                model.AddFlagToIndex(flag);
            }
            else
            {
                Flags.RemoveAt(index);
                model.CollateFlags();
            }
        }