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.");
            }
        }
Example #2
0
        private void btGoalFragDelete_Click(object sender, RoutedEventArgs e)
        {
            Object itemToEdit = goalFragsTreeView.SelectedItem;

            if (itemToEdit == null)
            {
                return;
            }


            if (itemToEdit.GetType() == typeof(AuthorGoal))
            {
                if (Utilities.MakeYesNoWarningDialog("Are you sure you want to delete Author Goal \"" + ((AuthorGoal)itemToEdit).Name + "\" and all of its Plot Fragments?", "Confirm Deletion", this) == MessageBoxResult.No)
                {
                    return;
                }

                AuthorGoal goalToDelete = (AuthorGoal)itemToEdit;


                _currentStoryData.AuthorGoals.Remove(goalToDelete);

                clearDataElements();
                dataBindWindow();
            }
            else if (itemToEdit.GetType() == typeof(PlotFragment))
            {
                if (Utilities.MakeYesNoWarningDialog("Are you sure you want to delete Plot Fragment \"" + ((PlotFragment)itemToEdit).Name + "\"?", "Confirm Deletion", this) == MessageBoxResult.No)
                {
                    return;
                }
                AuthorGoal parentGoal = _currentStoryData.findAuthorGoalById(((PlotFragment)itemToEdit).ParentAuthorGoalId);
                parentGoal.PlotFragments.Remove((PlotFragment)itemToEdit);
                clearDataElements();
                dataBindWindow();
            }
            else if (itemToEdit.GetType() == typeof(ActionSubgoal))
            {
                //Find the parent plot fragment using its stored id, then use that plot fragment to look up
                //the parent author goal id, which is then used to get the actual AuthorGoal object (whew!)
                AuthorGoal goalToDelete = _currentStoryData.findAuthorGoalById(_currentStoryData.findPlotFragmentById(((ActionSubgoal)itemToEdit).ParentPlotFragmentId).ParentAuthorGoalId);


                if (Utilities.MakeYesNoWarningDialog("Are you sure you want to delete Author Goal \"" + ((AuthorGoal)goalToDelete).Name + "\" and all of its Plot Fragments?", "Confirm Deletion", this) == MessageBoxResult.No)
                {
                    return;
                }



                _currentStoryData.AuthorGoals.Remove(goalToDelete);

                clearDataElements();
                dataBindWindow();
            }
            else
            {
                return;
            }
        }
Example #3
0
        virtual 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 if variable to compare to exists
            if (_comparisonValue.ValueIsBoundToVariable)
            {
                if (null == Utilities.findTraitByNameAndType(previouslyBoundVars, (string)_comparisonValue.LiteralValueOrBoundVarName, _comparisonValue.Type))
                {
                    throw new Exception("A precondition statement in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to variable \"" + (string)_comparisonValue.LiteralValueOrBoundVarName +
                                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters or precondition statements.");
                }
            }

            //Add new variable to running list of bound vars
            if (_saveAttribute)
            {
                previouslyBoundVars.Add(_savedVariable);
            }
        }
        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;
        }
        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;
        }
Example #6
0
        override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world)
        {
            PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId);

            if (parentFrag == null)
            {
                throw new Exception("Calculation Action not have parent Plot Fragment");
            }


            if (ParamLeft.ValueIsBoundToVariable)
            {
                bool foundVar = false;
                foreach (Trait traitItem in previouslyBoundVars)
                {
                    if (
                        (traitItem.Name == (string)ParamLeft.LiteralValueOrBoundVarName) &&
                        (traitItem.Type == ParamLeft.Type)
                        )
                    {
                        foundVar = true;
                        break;
                    }
                }
                if (!foundVar)
                {
                    throw new Exception("Calculation Action in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to variable \"" + (string)ParamLeft.LiteralValueOrBoundVarName +
                                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                }
            }

            if (ParamRight.ValueIsBoundToVariable)
            {
                bool foundVar = false;
                foreach (Trait traitItem in previouslyBoundVars)
                {
                    if (
                        (traitItem.Name == (string)ParamRight.LiteralValueOrBoundVarName) &&
                        (traitItem.Type == ParamRight.Type)
                        )
                    {
                        foundVar = true;
                        break;
                    }
                }
                if (!foundVar)
                {
                    throw new Exception("Calculation Action in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to variable \"" + (string)ParamRight.LiteralValueOrBoundVarName +
                                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                }
            }

            previouslyBoundVars.Add(_resultVar);
        }
        //Create object actions for charcters and environments do not reference any variables,
        //only the "edit object" action can do that
        //The exception is the plot point creator, which can have an error if the plot point type is
        //missing
        override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world)
        {
            PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId);

            if (parentFrag == null)
            {
                throw new Exception("Create object action does not have parent Plot Fragment");
            }
            return;
        }
        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 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 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);
            }
        }
Example #11
0
        override public 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.");
            }
        }
        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.");
            }
        }
Example #13
0
        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 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 = world.Environments[0].Traits;
            List<Relationship> relListToCompare = world.Environments[0].Relationships;

            foreach (Constraint cons in _constraints)
            {
                if (cons is TraitConstraint)
                {
                    if (null == Utilities.findTraitByNameAndType(traitListToCompare, cons.ComparisonValue.Name, cons.ComparisonValue.Type))
                    {
                        throw new Exception("An Environment-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.");

                    }
                }
                else if (cons is RelationshipConstraint)
                {
                    if (null == Utilities.findRelationshipByName(relListToCompare, cons.ComparisonValue.Name))
                    {
                        throw new Exception("An Environment-matching precondition statement in Plot Fragment \"" +
                          parentFrag.Name + "\" refers to a relationship 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);
            }
        }
Example #15
0
        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;
            string        objectTypeString = "";

            if (_varObjectTypeId == world.CharTypeId)
            {
                names            = parentFrag.getPreviouslyBoundCharacterVarNames(this);
                objectTypeString = "Character";
            }
            else if (_varObjectTypeId == world.EnvTypeId)
            {
                names            = parentFrag.getPreviouslyBoundEnvironmentVarNames(this);
                objectTypeString = "Environment";
            }
            else
            {
                PlotPointType currType = world.findPlotPointTypeById(_varObjectTypeId);
                if (currType != null)
                {
                    names            = parentFrag.getPreviouslyBoundPlotPointTypeVarNames(currType, this);
                    objectTypeString = currType.Description;
                }
                else
                {
                    throw new Exception("Edit Plot Point Action in Plot Fragment \"" + parentFrag.Name + "\" " +
                                        "uses a Plot Point Type which no longer exists.");
                }
            }
            if (!(names.Contains(_varObjectName)))
            {
                throw new Exception("Edit Object Action in Plot Fragment \"" +
                                    parentFrag.Name + "\" refers to saved " + objectTypeString + " \"" + _varObjectName +
                                    "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
            }

            //make sure variable for relationship target edit exists
            if ((_mode == ObjectEditingMode.RelationshipTarget) && !(names.Contains((string)_newTarget.LiteralValueOrBoundVarName)))
            {
                throw new Exception("Edit Object Action in Plot Fragment \"" +
                                    parentFrag.Name + "\" refers to saved " + objectTypeString + " \"" + (string)_newTarget.LiteralValueOrBoundVarName +
                                    "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
            }



            //Check for bound primitive variables when saving trait or relationship strength
            if (
                ((_mode == ObjectEditingMode.RelationshipStrength) || (_mode == ObjectEditingMode.Trait)) &&
                (_newValue.ValueIsBoundToVariable == true)
                )
            {
                bool foundIt = false;
                foreach (Trait traitItem in previouslyBoundVars)
                {
                    if (
                        (traitItem.Name == (string)_newValue.LiteralValueOrBoundVarName) &&
                        (traitItem.Type == _newValue.Type)
                        )
                    {
                        foundIt = true;
                        break;
                    }
                }

                if (!foundIt)
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to variable \"" + (string)_newValue.LiteralValueOrBoundVarName +
                                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                }
            }

            //Check to make sure all trait or relationships exist on the object to be edited
            List <Trait>        traitListToCompare = new List <Trait>();
            List <Relationship> relListToCompare   = new List <Relationship>();

            if (_varObjectTypeId == world.CharTypeId)
            {
                if (world.Characters.Count > 0)
                {
                    traitListToCompare = world.Characters[0].Traits;
                    relListToCompare   = world.Characters[0].Relationships;
                }
            }
            else if (_varObjectTypeId == world.EnvTypeId)
            {
                if (world.Environments.Count > 0)
                {
                    traitListToCompare = world.Environments[0].Traits;
                    relListToCompare   = world.Environments[0].Relationships;
                }
            }
            else
            {
                PlotPointType currType = world.findPlotPointTypeById(_varObjectTypeId);
                if (currType != null)
                {
                    traitListToCompare = currType.Traits;
                }
                else
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to a Plot Point type that no longer exists.");
                }
            }

            if (_mode == ObjectEditingMode.Trait)
            {
                //look for trait we are editing
                if (null == Utilities.findTraitByNameAndType(traitListToCompare, _newValue.Name, _newValue.Type))
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to a trait with name \"" +
                                        _newValue.Name + "\" and type \"" +
                                        Trait.TraitDataTypeToString(_newValue.Type) +
                                        "\" that no longer exists.");
                }
            }
            else
            {
                //look for relationship we are editing
                if (null == Utilities.findRelationshipByName(relListToCompare, _newValue.Name))
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                                        parentFrag.Name + "\" refers to a relationship with name \"" +
                                        _newValue.Name + " that no longer exists.");
                }
            }

            //No new variables to add to the binding list, so we can just exit after all the error checks
        }
        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
            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.");
            }
        }
Example #17
0
        public virtual 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 if variable to compare to exists
            if (_comparisonValue.ValueIsBoundToVariable)
            {
                if (null == Utilities.findTraitByNameAndType(previouslyBoundVars, (string)_comparisonValue.LiteralValueOrBoundVarName, _comparisonValue.Type))
                {
                    throw new Exception("A precondition statement in Plot Fragment \"" +
                           parentFrag.Name + "\" refers to variable \"" + (string)_comparisonValue.LiteralValueOrBoundVarName +
                           "\", \nwhich has a different type or does not exist in any previous Author Goal parameters or precondition statements.");
                }

            }

            //Add new variable to running list of bound vars
            if (_saveAttribute)
            {
                previouslyBoundVars.Add(_savedVariable);
            }
        }
        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;
            string objectTypeString = "";
            if (_varObjectTypeId == world.CharTypeId)
            {
                names = parentFrag.getPreviouslyBoundCharacterVarNames(this);
                objectTypeString = "Character";

            }
            else if (_varObjectTypeId == world.EnvTypeId)
            {

                names = parentFrag.getPreviouslyBoundEnvironmentVarNames(this);
                objectTypeString = "Environment";
            }
            else
            {
                PlotPointType currType = world.findPlotPointTypeById(_varObjectTypeId);
                if (currType != null)
                {
                    names = parentFrag.getPreviouslyBoundPlotPointTypeVarNames(currType, this);
                    objectTypeString = currType.Description;
                }
                else
                {
                    throw new Exception("Edit Plot Point Action in Plot Fragment \"" + parentFrag.Name + "\" " +
                        "uses a Plot Point Type which no longer exists.");
                }

            }
            if (!(names.Contains(_varObjectName)))
            {
                throw new Exception("Edit Object Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to saved " + objectTypeString + " \"" + _varObjectName +
                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
            }

            //make sure variable for relationship target edit exists
            if ((_mode == ObjectEditingMode.RelationshipTarget) && !(names.Contains((string)_newTarget.LiteralValueOrBoundVarName)))
            {
                throw new Exception("Edit Object Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to saved " + objectTypeString + " \"" + (string)_newTarget.LiteralValueOrBoundVarName +
                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
            }

            //Check for bound primitive variables when saving trait or relationship strength
            if(
                ((_mode == ObjectEditingMode.RelationshipStrength) || (_mode == ObjectEditingMode.Trait)) &&
                (_newValue.ValueIsBoundToVariable == true)
              )
            {
                bool foundIt = false;
                foreach (Trait traitItem in previouslyBoundVars)
                {

                    if (
                        (traitItem.Name == (string)_newValue.LiteralValueOrBoundVarName) &&
                        (traitItem.Type == _newValue.Type)
                        )
                    {
                        foundIt = true;
                        break;
                    }

                }

                if (!foundIt)
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to variable \"" + (string)_newValue.LiteralValueOrBoundVarName +
                        "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                }
            }

            //Check to make sure all trait or relationships exist on the object to be edited
            List<Trait> traitListToCompare = new List<Trait>();
            List<Relationship> relListToCompare = new List<Relationship>();

            if (_varObjectTypeId == world.CharTypeId)
            {
                if(world.Characters.Count > 0)
                {
                    traitListToCompare = world.Characters[0].Traits;
                    relListToCompare = world.Characters[0].Relationships;
                }

            }
            else if (_varObjectTypeId == world.EnvTypeId)
            {

                if (world.Environments.Count > 0)
                {
                    traitListToCompare = world.Environments[0].Traits;
                    relListToCompare = world.Environments[0].Relationships;
                }
            }
            else
            {
                PlotPointType currType = world.findPlotPointTypeById(_varObjectTypeId);
                if (currType != null)
                {
                    traitListToCompare = currType.Traits;
                }
                else
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to a Plot Point type that no longer exists.");
                }

            }

            if(_mode == ObjectEditingMode.Trait)
            {
                //look for trait we are editing
                if (null == Utilities.findTraitByNameAndType(traitListToCompare, _newValue.Name, _newValue.Type))
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to a trait with name \"" +
                        _newValue.Name + "\" and type \"" +
                        Trait.TraitDataTypeToString(_newValue.Type) +
                        "\" that no longer exists.");
                }

            }
            else
            {
                //look for relationship we are editing
                if (null == Utilities.findRelationshipByName(relListToCompare, _newValue.Name))
                {
                    throw new Exception("Edit Object Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to a relationship with name \"" +
                        _newValue.Name + " that no longer exists.");
                }
            }

            //No new variables to add to the binding list, so we can just exit after all the error checks
        }
        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 override void checkAndUpdateDependences(List<Trait> previouslyBoundVars, StoryData world)
        {
            PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId);
            if (parentFrag == null)
            {
                throw new Exception("Calculation Action not have parent Plot Fragment");
            }

            if (ParamLeft.ValueIsBoundToVariable)
            {

                bool foundVar = false;
                foreach (Trait traitItem in previouslyBoundVars)
                {
                    if (
                        (traitItem.Name == (string)ParamLeft.LiteralValueOrBoundVarName) &&
                        (traitItem.Type == ParamLeft.Type)
                        )
                    {
                        foundVar = true;
                        break;
                    }

                }
                if (!foundVar)
                {
                    throw new Exception("Calculation Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to variable \"" + (string)ParamLeft.LiteralValueOrBoundVarName +
                       "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                }

            }

            if (ParamRight.ValueIsBoundToVariable)
            {

                bool foundVar = false;
                foreach (Trait traitItem in previouslyBoundVars)
                {
                    if (
                        (traitItem.Name == (string)ParamRight.LiteralValueOrBoundVarName) &&
                        (traitItem.Type == ParamRight.Type)
                        )
                    {
                        foundVar = true;
                        break;
                    }

                }
                if (!foundVar)
                {
                    throw new Exception("Calculation Action in Plot Fragment \"" +
                        parentFrag.Name + "\" refers to variable \"" + (string)ParamRight.LiteralValueOrBoundVarName +
                       "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                }

            }

            previouslyBoundVars.Add(_resultVar);
        }
Example #21
0
        public override void checkAndUpdateDependences(List<Trait> previouslyBoundVars, StoryData world)
        {
            PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId);
            if (parentFrag == null)
            {
                throw new Exception("Pursue Subgoal Action does not have parent Plot Fragment");
            }

            AuthorGoal goalToPursue = world.findAuthorGoalById(_subGoalId);
            if (goalToPursue == null)
            {
                //clear out parameter list
                //_parametersToPass.Clear();

                throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal which does not exist.");
            }

            if (goalToPursue.PlotFragments.Count == 0)
            {
                throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal which has no child plot fragments that fulfill it." +
                "\nAll goals which are used during story creation must have at least one Plot Fragment associated with them before generation can begin.");
            }

            //Check variable references from previous plot fragment preconditions and actions

            foreach (Parameter param in _parametersToPass)
            {
                if(param.ValueIsBoundToVariable)
                {
                    bool foundIt = false;
                    foreach (Trait traitItem in previouslyBoundVars)
                    {

                        if (
                            (traitItem.Name == (string)param.LiteralValueOrBoundVarName) &&
                            (traitItem.Type == param.Type)
                            )
                        {
                            foundIt = true;
                            break;
                        }

                    }

                    if (!foundIt)
                    {
                        throw new Exception("Pursue Subgoal Action in Plot Fragment \"" +
                            parentFrag.Name + "\" refers to variable \"" + param.LiteralValueOrBoundVarName +
                            "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                    }
                }
            }

            bool dataUpdated = syncParametersWithSubgoal();

            if (dataUpdated)
            {

                throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal that has had its parameters changed.\n" +
                "Wide Ruled has corrected the changes, but you should look at the Action to make sure the newly updated parameters have the correct value.");
            }
        }
Example #22
0
 public PlotFragment findPlotFragmentById(UInt64 id)
 {
     return(_storyWorld.findPlotFragmentById(id));
 }
Example #23
0
        override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world)
        {
            PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId);

            if (parentFrag == null)
            {
                throw new Exception("Pursue Subgoal Action does not have parent Plot Fragment");
            }


            AuthorGoal goalToPursue = world.findAuthorGoalById(_subGoalId);

            if (goalToPursue == null)
            {
                //clear out parameter list
                //_parametersToPass.Clear();

                throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal which does not exist.");
            }

            if (goalToPursue.PlotFragments.Count == 0)
            {
                throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal which has no child plot fragments that fulfill it." +
                                    "\nAll goals which are used during story creation must have at least one Plot Fragment associated with them before generation can begin.");
            }


            //Check variable references from previous plot fragment preconditions and actions

            foreach (Parameter param in _parametersToPass)
            {
                if (param.ValueIsBoundToVariable)
                {
                    bool foundIt = false;
                    foreach (Trait traitItem in previouslyBoundVars)
                    {
                        if (
                            (traitItem.Name == (string)param.LiteralValueOrBoundVarName) &&
                            (traitItem.Type == param.Type)
                            )
                        {
                            foundIt = true;
                            break;
                        }
                    }

                    if (!foundIt)
                    {
                        throw new Exception("Pursue Subgoal Action in Plot Fragment \"" +
                                            parentFrag.Name + "\" refers to variable \"" + param.LiteralValueOrBoundVarName +
                                            "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions .");
                    }
                }
            }


            bool dataUpdated = syncParametersWithSubgoal();

            if (dataUpdated)
            {
                throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal that has had its parameters changed.\n" +
                                    "Wide Ruled has corrected the changes, but you should look at the Action to make sure the newly updated parameters have the correct value.");
            }
        }