コード例 #1
0
        private static void DeserializeDescriptionFile(string descriptionTxt, ScenarioPackage package)
        {
            var descriptionSections = FileReader.ReadSections(descriptionTxt);
            var headerSection       = descriptionSections["header"];
            var descriptionSection  = descriptionSections["description"];

            package.Title            = headerSection.Lines.FirstOrDefault();
            package.DescriptionLines = descriptionSection.Lines;

            var winConditionSection    = descriptionSections["wincondition"];
            var winConditionDictionary = FileReader.ReadDictionary(winConditionSection);

            package.WinCondition = new WinCondition
            {
                Description = winConditionDictionary["description"],
            };

            var test       = winConditionDictionary["test"];
            var conditions = test.Split(new[] { "||" }, StringSplitOptions.None);

            foreach (var condition in conditions)
            {
                package.WinCondition.Matches.Add(new WinConditionMatch
                {
                    NegateMatch = condition[0] == '!',
                    MatchLine   = condition.Substring(1).Trim()
                });
            }
        }
コード例 #2
0
        public Scenario(ScenarioPackage scenarioPackage)
        {
            Title            = scenarioPackage.Title;
            DescriptionLines = scenarioPackage.DescriptionLines;

            foreach (var process in scenarioPackage.Processes)
            {
                Console.WriteLine("Attaching " + process.Name);

                var p = process.Process;
                p.Memory.SetMemoryToDefault();
                this.Processes.Add(process.Name, p);
            }

            this.WinCondition = scenarioPackage.WinCondition;

            foreach (var drive in scenarioPackage.Drives)
            {
                Console.WriteLine($"Attaching drive {drive.DriveId}");
                Console.WriteLine($"Coord range {drive.AllCoordinates.First()} ->  {drive.AllCoordinates.Last()}");

                drive.SetMemoryToDefault();
                this.Disks.Add(drive);
            }
        }
コード例 #3
0
        private static void DeserializeProgramsFile(string programsTxt, ScenarioPackage package)
        {
            var groups = FileReader.ReadArray(programsTxt);

            foreach (var group in groups)
            {
                var sections = FileReader.ReadSections(@group);


                var metadataSection = sections["metadata"];
                var programMetadata = FileReader.ReadDictionary(metadataSection.Lines);
                var programName     = programMetadata["name"];
                var prompt          = programMetadata["prompt"];
                var instruction     = programMetadata["instruction"];

                var sourceSection = sections["source"];
                IReadOnlyCollection <CpuCommand> commands;
                try
                {
                    commands = FileReader.ReadCpuCommands(sourceSection.Lines);
                }
                catch (Exception e)
                {
                    Console.WriteLine("program contents was: ");
                    foreach (var line in sourceSection.Lines)
                    {
                        Console.WriteLine(line);
                    }

                    throw;
                }


                var memorySection = sections["memory"];
                var memory        = FileReader.ReadAddressableRegion(memorySection.Lines, null);

                package.Processes.Add(new ScenarioProcess
                {
                    Name    = programName,
                    Process = new Process
                    {
                        Memory      = memory,
                        Prompt      = prompt,
                        Instruction = instruction,
                        Source      = new CpuProgram
                        {
                            AllCommands = commands.ToList()
                        }
                    }
                });
            }
        }
コード例 #4
0
        public static ScenarioPackage Deserialize(string programsTxt, string descriptionTxt, string disksTxt)
        {
            var package = new ScenarioPackage();

            DeserializeProgramsFile(programsTxt, package);

            if (descriptionTxt != null)
            {
                DeserializeDescriptionFile(descriptionTxt, package);
            }

            if (disksTxt != null)
            {
                DeserializeDisksFile(disksTxt, package);
            }

            return(package);
        }
コード例 #5
0
        private static void DeserializeDisksFile(string disksTxt, ScenarioPackage package)
        {
            int i          = 0;
            var driveArray = FileReader.ReadArray(disksTxt).ToList();

            foreach (var driveDefinition in driveArray)
            {
                var sections        = FileReader.ReadSections(driveDefinition);
                var contentsSection = sections["contents"];
                var metadataSection = sections["metadata"];

                var metadata = FileReader.ReadDictionary(metadataSection);

                var memorySetup = FileReader.ReadAddressableRegion(contentsSection, i++);
                memorySetup.ReadOnly   = metadata["readonly"] == "true";
                memorySetup.VolumeName = metadata["name"];

                package.Drives.Add(memorySetup);
            }
        }
コード例 #6
0
 public SqlOpenSearchConstraint(ScenarioPackage package) : base(package)
 {
 }
コード例 #7
0
 public HelloWorldScenario(ScenarioPackage package) : base(package)
 {
 }
コード例 #8
0
 public LateralThinkingScenario(ScenarioPackage package) : base(package)
 {
 }
コード例 #9
0
 public WhatsThePasswordScenario(ScenarioPackage package) : base(package)
 {
 }
コード例 #10
0
 public SqlReplaceEntireQuery(ScenarioPackage package) : base(package)
 {
 }
コード例 #11
0
 public SqlFakeGotoLabel(ScenarioPackage package) : base(package)
 {
 }
コード例 #12
0
 public ExploitNextAddressCheck(ScenarioPackage package) : base(package)
 {
 }
コード例 #13
0
 public SqlForUsingMemoryAddress(ScenarioPackage package) : base(package)
 {
 }
コード例 #14
0
 public SqlScenario3(ScenarioPackage package) : base(package)
 {
 }
コード例 #15
0
 public DereferencingScenario(ScenarioPackage package) : base(package)
 {
 }