public static StoryModel Create(IStoryReader reader) { var model = new StoryModel(); model.Story = reader.Read(); return(model.Story != null ? model : null); }
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); }
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); }
/// <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); }
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(); } }