示例#1
0
        private static void RecordExpectedOutcome()
        {
            TestCase selected = PromptForTestCase();

            if (selected != null)
            {
                try
                {
                    using (Stream zcode = selected.GetZCode())
                    {
                        RecordingIO io = new RecordingIO(selected.InputFile);
                        ZMachine    zm = new ZMachine(zcode, io);
                        zm.PredictableRandom     = true;
                        zm.WritingCommandsToFile = true;

                        string output = RunAndCollectOutput(zm, io);
                        File.WriteAllText(selected.OutputFile, output);
                    }
                }
                finally
                {
                    selected.CleanUp();
                }
            }
        }
示例#2
0
 protected override void Run()
 {
     //Console.WriteLine("Specify game path:");
     //string fileName = string.Empty;
     try
     {
         //fileName = Console.ReadLine();
         //if (fileName == "ls")
         //{
         //    foreach (var dir in Directory.GetFiles("0:\\"))
         //    {
         //        Console.WriteLine($"0:\\{dir}");
         //    }
         //}
         //else
         //{
         var machine = new ZMachine(GameData);
         machine.Run();
         //}
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
示例#3
0
        static void Main(string[] args)
        {
            ZMachine zMachine = new ZMachine(new ConsoleIO());

            FileStream fs = File.OpenRead(@"zork1.dat");

            zMachine.LoadFile(fs);
            zMachine.Run();
        }
示例#4
0
 public static void Initialize(ZMachine aMachine)
 {
     _machine           = aMachine;
     DictionaryWordSize = aMachine.Story.Header.Version >= FileVersion.V4 ? 9 : 6;
     LoadAlphabets();
     LoadExtraChars();
     LoadTerminatingChars();
     LoadWordSeparators();
 }
示例#5
0
        static void Main(string[] args)
        {
            byte[] data;
            using (var reader = new FileStream("..\\..\\..\\..\\ZKernel\\ZORK1.DAT", FileMode.Open))
            {
                data = new byte[reader.Length];
                reader.Read(data, 0, data.Length);
                reader.Close();
                reader.Dispose();
            }

            var machine = new ZMachine(data);

            machine.Run();

            Console.ReadKey();
        }
示例#6
0
        private static bool?RunOneTest(TestCase test)
        {
            if (!File.Exists(test.InputFile) || !File.Exists(test.OutputFile))
            {
                Console.WriteLine("skipping (expected outcome not recorded).");
                return(null);
            }
            else
            {
                try
                {
                    using (Stream zcode = test.GetZCode())
                    {
                        ReplayIO io = new ReplayIO(test.InputFile);
                        ZMachine zm = new ZMachine(zcode, io);

                        zm.PredictableRandom       = true;
                        zm.ReadingCommandsFromFile = true;

                        string output         = RunAndCollectOutput(zm, io);
                        string expectedOutput = File.ReadAllText(test.OutputFile);

                        if (OutputDiffers(expectedOutput, output))
                        {
                            Console.WriteLine("failed!");
                            File.WriteAllText(test.FailureFile, output);
                            return(false);
                        }
                        else
                        {
                            Console.WriteLine("passed.");
                            return(true);
                        }
                    }
                }
                finally
                {
                    test.CleanUp();
                }
            }
        }
示例#7
0
        private static string RunAndCollectOutput(ZMachine zm, TestCaseIO io)
        {
            string output = null;

            try
            {
                zm.PredictableRandom = true;
                zm.Run();
                output = io.CollectOutput();
            }
            catch (Exception ex)
            {
                if (output == null)
                {
                    output = io.CollectOutput();
                }

                output += "\n\n*** Exception ***\n" + ex.ToString();
            }

            return(output);
        }
示例#8
0
 public Window(ZMachine.VM.Formatter formatter)
 {
     this.formatter = formatter;
     formatter.Window = this;
 }