Ejemplo n.º 1
0
        private static List <Exception> GetExceptions(IEnumerable <StamFile> files)
        {
            var exceptions = new List <Exception>();
            var scenes     = FileParseHelper.GetScenes(files).ToList();

            // Adventure-wide validation methods
            exceptions.Add(NoDuplicateScenesExist(scenes));
            exceptions.Add(OneEntrySceneExists(scenes));

            // Scene-specific validation methods
            foreach (var scene in scenes)
            {
                exceptions.Add(SceneHasDescription(scene));

                // Scene-wide action validation methods
                var actions = SceneParseHelper.GetSceneActions(scene).ToList();

                if (actions.Count <= 0)
                {
                    continue;
                }

                exceptions.Add(AllNextScenesExist(scenes, actions));
                exceptions.Add(AtLeastOneActionHasNextScene(scene, actions));
                exceptions.Add(DefaultActionIsValid(scene, actions));
                exceptions.Add(NoDuplicateActionAbbreviations(scene, actions));
                exceptions.Add(NoDuplicateActionDescriptions(scene, actions));
                exceptions.Add(SceneIsNotEndlessLoop(scene, actions));

                // Action-specific validation methods
                foreach (var action in actions)
                {
                    exceptions.Add(ActionHasDescription(scene, action));
                    exceptions.Add(ActionHasResultOrNextScene(scene, action));
                }
            }

            return(exceptions.Where(ex => ex != null).ToList());
        }
Ejemplo n.º 2
0
        private static void TestProject()
        {
            var projects = FileSystemHelper.GetStamProjects();
            var files    = ChooseProject(projects);

            if (files == null)
            {
                ShowMenu();
                return;
            }

            var isValid = ValidationHelper.ValidateFiles(files);

            if (!isValid)
            {
                ShowMenu();
                return;
            }

            var scenes = FileParseHelper.GetScenes(files).ToList();

            GameApplication.Init(scenes, null);
            ShowMenu();
        }
Ejemplo n.º 3
0
        private static void CreatePackage()
        {
            var projects = FileSystemHelper.GetStamProjects();
            var files    = ChooseProject(projects);

            if (files == null)
            {
                ShowMenu();
                return;
            }

            var isValid = ValidationHelper.ValidateFiles(files);

            if (!isValid)
            {
                ShowMenu();
                return;
            }

            var scenes = FileParseHelper.GetScenes(files).ToList();

            FileSystemHelper.WritePackage(scenes);
            ShowMenu();
        }