//Plot Point is story entity without relationships public PlotPoint(PlotPointType type, StoryData world) : base("", world.getNewId(), type.Id, world) { _traits.Clear(); //Don't need name trait Utilities.SynchronizePlotPointWithType(type, this, world); }
public WindowPreconditionEditor(PlotFragment frag, PreconditionStatement currEntity, StoryData currStoryData) { InitializeComponent(); _currentStoryData = currStoryData; _currentEntity = currEntity; _parentPlotFragment = frag; _currentlySelectedConstraint = null; _currentlyDataBinding = false; //Find editing type if (currEntity is PreconditionStatementCharacter) { _editingMode = 0; } else if (currEntity is PreconditionStatementEnvironment) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(((PreconditionStatementPlotPoint)currEntity).MatchTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
public WindowPlotFragmentEditor(PlotFragment currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentGoal = currStoryData.findAuthorGoalById(currEntity.ParentAuthorGoalId); }
public AuthorGoal(string name, StoryData world) { _name = name; _goalId = world.getNewId(); _parameters = new List<Parameter>(); _plotFragments = new List<PlotFragment>(); }
private PlotPointType _ppType; //only valid if in pp editing mode #endregion Fields #region Constructors public WindowActionEditEntity(PlotFragment frag, ActionEditObject currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentPlotFragment = frag; _ppType = null; _currentlyDataBinding = false; //Find editing type if (_currentEntity.ObjectTypeId == currStoryData.CharTypeId) { _editingMode = 0; } else if (_currentEntity.ObjectTypeId == currStoryData.EnvTypeId) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(_currentEntity.ObjectTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
public WindowInteractionListEditor(StoryData world) { InitializeComponent(); _currentStoryData = world; dataBind(); }
//_newValue.Name => name of trait or relationship //_newValue.LiteralValueOrBoundVarName => literal value or variable bound value of trait or relationship strength //_newTarget.Name => name of relationship (should be same as _newValue.Name) //_newTarget.LiteralValueOrBoundVarName => character variable that is bound to new relationship public ActionEditObject(UInt64 parentPlotFragmentId, string varObjectName, UInt64 objectTypeId, ObjectEditingMode mode, StoryData world) : base(parentPlotFragmentId, world) { _varObjectName = varObjectName; _varObjectTypeId = objectTypeId; _mode = mode; //Find editing type if (objectTypeId == world.CharTypeId) //Character { _newValue = new Parameter("Name", TraitDataType.Text, false, world); _newTarget = new Parameter("", TraitDataType.Text, true, world); } else if (objectTypeId == world.EnvTypeId) //Environment { _newValue = new Parameter("Name", TraitDataType.Text, false, world); _newTarget = new Parameter("", TraitDataType.Text, true, world); } else //Plot Point { PlotPointType currType = world.findPlotPointTypeById(objectTypeId); _newValue = new Parameter(currType.Traits[0].Name, currType.Traits[0].Type, false, world); _newTarget = new Parameter("", TraitDataType.Text, true, world); } }
public PlotPointType(string name, StoryData world) { _name = name; _ppTypeId = world.getNewId(); _traits = new List<Trait>(); }
public RelationshipConstraint(TraitConstraint cons, StoryData world) : base(cons.ParentPlotFragmentId, cons.ParentPreconditionStatementId, cons.AllowedToSave, cons.MatchingEntityTypeId, world) { _constraintType = cons.ConstraintType; _comparisonValue = (Parameter)cons.ComparisonValue.Clone(); _saveAttribute = cons.ContainsSavedVariable; _savedVariable = (Trait)cons.SavedVariable.Clone(); }
public ActionCalculation(UInt64 parentPlotFragmentId, string varName, StoryData world) : base(parentPlotFragmentId, world) { _resultVar = new Trait(varName, TraitDataType.Number, world.getNewId(), world); _paramLeft = new Parameter("paramLeft", TraitDataType.Number, false, world); _paramRight = new Parameter("paramRight", TraitDataType.Number, false, world); _op = CalculationOperation.Add; }
public override void checkAndUpdateDependences(List<Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Delete Object Action not have parent Plot Fragment"); } //check for variables bound to object references List<string> names = null; if (_entityTypeId == world.CharTypeId) { names = parentFrag.getPreviouslyBoundCharacterVarNames(this); } else if (_entityTypeId == world.EnvTypeId) { names = parentFrag.getPreviouslyBoundEnvironmentVarNames(this); } else { PlotPointType currType = world.findPlotPointTypeById(_entityTypeId); if (currType != null) { names = parentFrag.getPreviouslyBoundPlotPointTypeVarNames(currType, this); } } if (!(names.Contains(_varNameForDeletion))) { throw new Exception("Delete Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + _varNameForDeletion + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } //check for any previous deletions of this variable - that would be BAD because another //deletion would cause this to fail in ABL foreach(Action act in parentFrag.Actions) { if(act is ActionDeleteEntity) { if( (act != this) && (((ActionDeleteEntity)act).VariableName == _varNameForDeletion) ) { throw new Exception("The Plot Fragment \"" + parentFrag.Name + "\" deletes the object saved in the variable \"" + _varNameForDeletion + "\" more than once, which is not allowed. ."); } } } return; }
public PlotFragment(string name, UInt64 parentAuthorGoalId, StoryData world) { _name = name; _plotFragId = world.getNewId(); _parentAuthorGoalId = parentAuthorGoalId; _precStatements = new List<PreconditionStatement>(); _actions = new List<Action>(); }
public WindowPlotPointTypeEditor(PlotPointType currentEntity, StoryData storyData) { InitializeComponent(); _currentEntity = currentEntity; _currentStoryData = storyData; _newList = new List<Trait>(); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); }
public PreconditionStatement(UInt64 parentPlotFragmentId, StoryData world) { _precId = world.getNewId(); _parentPlotFragmentId = parentPlotFragmentId; _storyObjectExists = true; _saveObjectVariableName = ""; _saveMatch = false; _constraints = new List<Constraint>(); }
public WindowSharedTraitsEditor(StoryEntity parentEntity, StoryData storyData) { InitializeComponent(); _parentEntity = parentEntity; _currentStoryData = storyData; newList = new List<Trait>(); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); }
// static Random random; public AblCodeGenerator(StoryData story) { // random = new Random(); _typeIdToTraitsRels = new Hashtable(); //maps entity type id's to HashSet<String> => name mappings for traits _story = story; _goalNames = new Hashtable(); _plotPointTypeNames = new Hashtable(); _interactivityDaemonNames = new List<string>(); _tw = new IndentingWriter(); }
public WindowActionCalculationEditor(PlotFragment parentPlotFragment, ActionCalculation calc, StoryData world) { InitializeComponent(); _currentEntity = calc; _parentPlotFragment = parentPlotFragment; _currentStoryData = world; textBoxNumericLeft.NullValue = 0.0; textBoxNumericRight.NullValue = 0.0; }
public WindowPlotPointEditor(PlotPoint existingPP, StoryData storyData) { InitializeComponent(); _pP = existingPP; _ppType = storyData.findPlotPointTypeById(existingPP.TypeId); _currentStoryData = storyData; this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); dataBind(); }
public WindowAuthorGoalEditor(AuthorGoal currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _newList = new List<Parameter>(); _isStartGoal = (_currentStoryData.StartGoalId == _currentEntity.Id); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); }
public override void checkAndUpdateDependences(List<Trait> previouslyBoundVars, StoryData world) { base.checkAndUpdateDependences(previouslyBoundVars, world); //Additionally, check that trait names exist in the class of object that this is constrained on //Check to make sure all trait or relationships exist on the object to be edited List<Trait> traitListToCompare = new List<Trait>(); PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (_matchingEntityTypeId == world.CharTypeId) { if (world.Characters.Count > 0) { traitListToCompare = world.Characters[0].Traits; } } else if (_matchingEntityTypeId == world.EnvTypeId) { if (world.Environments.Count > 0) { traitListToCompare = world.Environments[0].Traits; } } else { PlotPointType currType = world.findPlotPointTypeById(_matchingEntityTypeId); if (currType != null) { traitListToCompare = currType.Traits; } else { throw new Exception("A Trait constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a Plot Point type that no longer exists."); } } //look for trait we are editing if (null == Utilities.findTraitByNameAndType(traitListToCompare, _comparisonValue.Name, _comparisonValue.Type)) { throw new Exception("A Trait constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a trait with name \"" + _comparisonValue.Name + "\" and type \"" + Trait.TraitDataTypeToString(_comparisonValue.Type) + "\" that no longer exists."); } }
public StoryEntity(string name, UInt64 entityId, UInt64 entityTypeId, StoryData world) { _entityId = entityId; _entityTypeId = entityTypeId; _traits = new List <Trait>(); _relationships = new List <Relationship>(); //TODO eventually: Make this automatically pull all traits and relationships from //the entity type associated with this entity _traits.Add( new Trait("Name", TraitDataType.Text, name, 0, world) ); }
public ActionTextOutput(UInt64 parentPlotFragmentId, string textOutput, StoryData world) : base(parentPlotFragmentId, world) { _textOutput = textOutput; //if(_VariableMatcher == null) //{ //Matches anything between two outermost "<" and ">" symbols, in that order, //which could also mean other "<" or ">" symbols. This allows variables in the Wide Ruled //interface to have any type of text in them (even though ABL will need them reformatted anyway). // _VariableMatcher = new Regex("(?:[^<]*<)[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); //} }
public Constraint(UInt64 parentPlotFragmentId, UInt64 parentPrecondStatementId, bool allowedToSave, UInt64 matchingEntityTypeId, StoryData world) { _matchingEntityTypeId = matchingEntityTypeId; _constraintId = world.getNewId(); _parentPrecondStmtId = parentPrecondStatementId; _allowedToSave = allowedToSave; _parentPlotFragmentId = parentPlotFragmentId; _constraintType = ConstraintComparisonType.Equals; _comparisonValue = new Parameter("", TraitDataType.Text, false, world); _saveAttribute = false; _savedVariable = new Trait("", TraitDataType.Text, "", 0, world); _mustAlwaysBeTrue = false; }
public StoryEntity(string name, UInt64 entityId, UInt64 entityTypeId, StoryData world) { _entityId = entityId; _entityTypeId = entityTypeId; _traits = new List<Trait>(); _relationships = new List<Relationship>(); //TODO eventually: Make this automatically pull all traits and relationships from //the entity type associated with this entity _traits.Add( new Trait("Name", TraitDataType.Text, name, 0, world) ); }
public override void checkAndUpdateDependences(List<Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Create plot point action does not have parent Plot Fragment"); } if(world.findPlotPointTypeById(_newPP.TypeId) == null) { throw new Exception("Create Plot Point Action in Plot Fragment \"" + parentFrag.Name + "\" " + "uses a Plot Point Type which no longer exists."); } }
public WindowActionSubgoalEditor(bool interactionMode, PlotFragment frag, ActionSubgoal currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentPlotFragment = frag; _currentlySelectedParameter = null; //_previouslySlectedParameter = null; _validData = true; _interactionMode = interactionMode; txtBoxNumberInput.NullValue = 0.0; _currentEntity.syncParametersWithSubgoal(); dataBind(); }
// Copy trait and keep trait type id to identify it as the same trait elsewhere in the program public Trait(Trait anotherTrait, StoryData world) { switch (anotherTrait.Type) { case TraitDataType.TrueFalse: Constructor(anotherTrait.Name, anotherTrait.Type, false, anotherTrait.TypeId, world); break; case TraitDataType.Number: Constructor(anotherTrait.Name, anotherTrait.Type, 0.0, anotherTrait.TypeId, world); break; case TraitDataType.Text: Constructor(anotherTrait.Name, anotherTrait.Type, "", anotherTrait.TypeId, world); break; } }
public WindowMain() { InitializeComponent(); #if (DEBUG) DebugMenu.Visibility = Visibility.Visible; #endif CurrentStory = new StoryData(); _saveFileName = ""; this.WindowTitle = "(Untitled Story)"; this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); }
// Copy trait and keep trait type id to identify it as the same relationship elsewhere in the program public Relationship(Relationship anotherRel, StoryEntity originatingEntity, StoryData world) { UInt64 nullTargetId = 0; if (originatingEntity.GetType() == typeof(Character)) { nullTargetId = Character.getNoOneCharacter().Id; } else if (originatingEntity.GetType() == typeof(Environment)) { nullTargetId = Environment.getNoWhereEnvironment().Id; } Constructor(anotherRel.Name, originatingEntity.Id, nullTargetId, 0.0, anotherRel.TypeId, world); }
public Trait(string name, TraitDataType type, UInt64 traitTypeId, StoryData world) { switch (type) { case TraitDataType.TrueFalse: Constructor(name, type, false, traitTypeId, world); break; case TraitDataType.Number: Constructor(name, type, 0.0, traitTypeId, world); break; case TraitDataType.Text: Constructor(name, type, "", traitTypeId, world); break; } }
public override void checkAndUpdateDependences(List<Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Text Output Action does not have parent Plot Fragment"); } //Get all variable references from text //Check variable references from previous plot fragment preconditions and actions if (_VariableMatcher == null) { //Matches anything between two outermost "<" and ">" symbols, in that order, //which could also mean other "<" or ">" symbols. This allows variables in the Wide Ruled //interface to have any type of text in them (even though ABL will need them reformatted anyway). // _VariableMatcher = new Regex("(?:[^<]*<)[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); _VariableMatcher = new Regex("(?:[^<])[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); } MatchCollection varMatches = _VariableMatcher.Matches(_textOutput); foreach (Match varMatch in varMatches) { //Don't need to check var types. All primitive types can be converted to strings. bool foundIt = false; foreach (Trait traitItem in previouslyBoundVars) { if (traitItem.Name == varMatch.Value) { foundIt = true; break; } } if (!foundIt) { throw new Exception("Text Output Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + varMatch.Value + "\", \nwhich does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } }
public static StoryData DeSerializeStoryDataFromDisk(string filename) { StoryData result = null; Stream stream = File.Open(filename, FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); try { result = (StoryData)bformatter.Deserialize(stream); } finally { stream.Close(); } return(result); }
private void NewMenuItem_Click(object sender, RoutedEventArgs e) { if ( (_currentStoryData.AuthorGoals.Count > 0) || (_currentStoryData.Characters.Count > 0) || (_currentStoryData.Environments.Count > 0) || (_currentStoryData.PlotPointTypes.Count > 0) ) { MessageBoxResult result = Utilities.MakeYesNoWarningDialog("Creating a new Story will erase any data you haven't yet saved. Are you sure you want to create a new Story?", "Confirm New Story Creation", this); if (result == MessageBoxResult.No) { return; } } _saveFileName = ""; this.WindowTitle = "(Untitled Story)"; CurrentStory = new StoryData(); dataBindWindow(); }
public ActionSubgoal(UInt64 parentPlotFragmentId, UInt64 subgoalId, StoryData world) : base(parentPlotFragmentId, world) { _subGoalId = subgoalId; _parametersToPass = new List <Parameter>(); AuthorGoal subGoal = world.findAuthorGoalById(subgoalId); if (subGoal != null) { List <Parameter> parameters = subGoal.Parameters; foreach (Parameter param in parameters) { // Add all parameters from the subgoal, which will later be filled in // with literals or variables _parametersToPass.Add(new Parameter(param.Name, param.Type, false, world)); } } }
public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { //Convert to trait list first List <Trait> paramToTraitList = new List <Trait>(); foreach (Parameter param in _parameters) { previouslyBoundVars.Add(param); } //previouslyBoundVars.AddRange(paramToTraitList); foreach (PlotFragment frag in _plotFragments) { //New variable list for each fragment (with common parameter variables from parent Author Goal) List <Trait> fragSpecificTraitList = new List <Trait>(previouslyBoundVars.Count); fragSpecificTraitList.AddRange(previouslyBoundVars); frag.checkAndUpdateDependences(fragSpecificTraitList, world); } }
public static List <Character> getGlobalCharacterList(StoryData world) { List <Character> fullCharList = new List <Character>(); fullCharList.AddRange(world.Characters); //Go get all new characters created in plot fragment actions foreach (AuthorGoal goal in world.AuthorGoals) { foreach (PlotFragment frag in goal.PlotFragments) { foreach (Action act in frag.Actions) { if (act is ActionCreateCharacter) { fullCharList.Add(((ActionCreateCharacter)act).NewCharacter); } } } } return(fullCharList); }
public static List <Environment> getGlobalEnvironmentList(StoryData world) { List <Environment> fullEnvList = new List <Environment>(); fullEnvList.AddRange(world.Environments); //Go get all new characters created in plot fragment actions foreach (AuthorGoal goal in world.AuthorGoals) { foreach (PlotFragment frag in goal.PlotFragments) { foreach (Action act in frag.Actions) { if (act is ActionCreateEnvironment) { fullEnvList.Add(((ActionCreateEnvironment)act).NewEnvironment); } } } } return(fullEnvList); }
public static List <PlotPoint> getGlobalPlotPointList(PlotPointType type, StoryData world) { List <PlotPoint> fullPPList = new List <PlotPoint>(); //Go get all new characters created in plot fragment actions foreach (AuthorGoal goal in world.AuthorGoals) { foreach (PlotFragment frag in goal.PlotFragments) { foreach (Action act in frag.Actions) { if ((act is ActionCreatePlotPoint) && ((ActionCreatePlotPoint)act).NewPlotPoint.TypeId == type.Id) { fullPPList.Add(((ActionCreatePlotPoint)act).NewPlotPoint); } } } } return(fullPPList); }
public static void SynchronizeGlobalPlotPointsWithType(PlotPointType type, StoryData world) { List <PlotPoint> globalPlotPoints = getGlobalPlotPointList(type, world); foreach (PlotPoint currEntity in globalPlotPoints) { List <Trait> properList = new List <Trait>(); foreach (Trait newTrait in type.Traits) { // Trait oldTrait = currEntity.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) // { Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = currEntity.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // } // else // { // oldTrait.Name = newTrait.Name; // oldTrait.Type = newTrait.Type; // properList.Add(oldTrait); //} } currEntity.Traits = properList; } }
public static void removeRelationshipTargetReferencesFromStoryWorld(Character characterToWipe, StoryData world) { List <Character> globalChars = Utilities.getGlobalCharacterList(world); foreach (Character ch in globalChars) { foreach (Relationship rel in ch.Relationships) { if (rel.ToId == characterToWipe.Id) { rel.ToId = StoryData.NullCharacterId; } } } }
public static void setStoryData(StoryData world) { _storyWorld = world; }
public PreconditionStatementPlotPoint(UInt64 parentPlotFragmentId, PlotPointType type, StoryData world) : base(parentPlotFragmentId, world) { _plotPointTypeId = type.Id; }
public static void removeRelationshipTargetReferencesFromStoryWorld(Environment envToWipe, StoryData world) { List <Environment> globalEnvs = Utilities.getGlobalEnvironmentList(world); foreach (Environment env in globalEnvs) { foreach (Relationship rel in env.Relationships) { if (rel.ToId == envToWipe.Id) { rel.ToId = StoryData.NullEnvironmentId; } } } }
public override void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Edit Object Action not have parent Plot Fragment"); } //Check to make sure all trait or relationships exist on the object to be edited, for each //constraint List <Trait> traitListToCompare = null; PlotPointType currType = world.findPlotPointTypeById(_plotPointTypeId); if (currType != null) { traitListToCompare = currType.Traits; } else { throw new Exception("A Plot Point-matching Precondition Plot Fragment \"" + parentFrag.Name + "\" refers to a Plot Point type that no longer exists."); } foreach (Constraint cons in _constraints) { if (cons is TraitConstraint) { if (null == Utilities.findTraitByNameAndType(traitListToCompare, cons.ComparisonValue.Name, cons.ComparisonValue.Type)) { throw new Exception("A " + currType.Description + "-matching precondition statement in Plot Fragment \"" + parentFrag.Name + "\" refers to trait variable \"" + cons.ComparisonValue.Name + "\", \nwhich now has a different type or no longer exists."); } } } //Now do individual checks foreach (Constraint cons in _constraints) { cons.checkAndUpdateDependences(previouslyBoundVars, world); } }
public ActionCreateEnvironment(UInt64 parentPlotFragmentId, string envName, string varName, StoryData world) : base(parentPlotFragmentId, varName, world) { _newEntity = new Environment(envName, world.EnvTypeId, world); }
public WindowEnvironmentEditor(Environment currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; }
public WindowActionEditEntity(PlotFragment frag, ActionEditObject currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentPlotFragment = frag; _ppType = null; _currentlyDataBinding = false; //Find editing type if (_currentEntity.ObjectTypeId == currStoryData.CharTypeId) { _editingMode = 0; } else if (_currentEntity.ObjectTypeId == currStoryData.EnvTypeId) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(_currentEntity.ObjectTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Text Output Action does not have parent Plot Fragment"); } //Get all variable references from text //Check variable references from previous plot fragment preconditions and actions if (_VariableMatcher == null) { //Matches anything between two outermost "<" and ">" symbols, in that order, //which could also mean other "<" or ">" symbols. This allows variables in the Wide Ruled //interface to have any type of text in them (even though ABL will need them reformatted anyway). // _VariableMatcher = new Regex("(?:[^<]*<)[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); _VariableMatcher = new Regex("(?:[^<])[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); } MatchCollection varMatches = _VariableMatcher.Matches(_textOutput); foreach (Match varMatch in varMatches) { //Don't need to check var types. All primitive types can be converted to strings. bool foundIt = false; foreach (Trait traitItem in previouslyBoundVars) { if (traitItem.Name == varMatch.Value) { foundIt = true; break; } } if (!foundIt) { throw new Exception("Text Output Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + varMatch.Value + "\", \nwhich does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } }
public TraitConstraint(UInt64 parentPlotFragmentId, UInt64 parentPrecondStatementId, bool allowedToSave, UInt64 matchingEntityTypeId, StoryData world) : base(parentPlotFragmentId, parentPrecondStatementId, allowedToSave, matchingEntityTypeId, world) { }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { base.checkAndUpdateDependences(previouslyBoundVars, world); //Additionally, check that trait names exist in the class of object that this is constrained on //Check to make sure all trait or relationships exist on the object to be edited List <Trait> traitListToCompare = new List <Trait>(); PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (_matchingEntityTypeId == world.CharTypeId) { if (world.Characters.Count > 0) { traitListToCompare = world.Characters[0].Traits; } } else if (_matchingEntityTypeId == world.EnvTypeId) { if (world.Environments.Count > 0) { traitListToCompare = world.Environments[0].Traits; } } else { PlotPointType currType = world.findPlotPointTypeById(_matchingEntityTypeId); if (currType != null) { traitListToCompare = currType.Traits; } else { throw new Exception("A Trait constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a Plot Point type that no longer exists."); } } //look for trait we are editing if (null == Utilities.findTraitByNameAndType(traitListToCompare, _comparisonValue.Name, _comparisonValue.Type)) { throw new Exception("A Trait constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a trait with name \"" + _comparisonValue.Name + "\" and type \"" + Trait.TraitDataTypeToString(_comparisonValue.Type) + "\" that no longer exists."); } }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { base.checkAndUpdateDependences(previouslyBoundVars, world); //Additionally, check that trait names exist in the class of object that this is constrained on //Check to make sure all trait or relationships exist on the object to be edited PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); List <Relationship> relListToCompare = new List <Relationship>(); if (_matchingEntityTypeId == world.CharTypeId) { if (world.Characters.Count > 0) { relListToCompare = world.Characters[0].Relationships; } } else if (_matchingEntityTypeId == world.EnvTypeId) { if (world.Environments.Count > 0) { relListToCompare = world.Environments[0].Relationships; } } //look for trait we are editing if (null == Utilities.findRelationshipByName(relListToCompare, _comparisonValue.Name)) { throw new Exception("A Relationship constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a relationship with name \"" + _comparisonValue.Name + "\" that no longer exists."); } }
public RelationshipConstraint(UInt64 parentPlotFragmentId, UInt64 parentPrecondStatementId, bool allowedToSave, bool targetNameMode, UInt64 matchingEntityTypeId, StoryData world) : base(parentPlotFragmentId, parentPrecondStatementId, allowedToSave, matchingEntityTypeId, world) { _targetNameMode = targetNameMode; }
private UInt64 _entityTypeId; //The only character type id, only environment type id, // or one of the plot point type Ids public ActionDeleteEntity(UInt64 parentPlotFragmentId, string varName, UInt64 typeId, StoryData world) : base(parentPlotFragmentId, world) { _varNameForDeletion = varName; _entityTypeId = typeId; }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Delete Object Action not have parent Plot Fragment"); } //check for variables bound to object references List <string> names = null; if (_entityTypeId == world.CharTypeId) { names = parentFrag.getPreviouslyBoundCharacterVarNames(this); } else if (_entityTypeId == world.EnvTypeId) { names = parentFrag.getPreviouslyBoundEnvironmentVarNames(this); } else { PlotPointType currType = world.findPlotPointTypeById(_entityTypeId); if (currType != null) { names = parentFrag.getPreviouslyBoundPlotPointTypeVarNames(currType, this); } } if (!(names.Contains(_varNameForDeletion))) { throw new Exception("Delete Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + _varNameForDeletion + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } //check for any previous deletions of this variable - that would be BAD because another //deletion would cause this to fail in ABL foreach (Action act in parentFrag.Actions) { if (act is ActionDeleteEntity) { if ((act != this) && (((ActionDeleteEntity)act).VariableName == _varNameForDeletion) ) { throw new Exception("The Plot Fragment \"" + parentFrag.Name + "\" deletes the object saved in the variable \"" + _varNameForDeletion + "\" more than once, which is not allowed. ."); } } } return; }