Beispiel #1
0
        private void CreateRom(RandomizerDifficulty difficulty)
        {
            int parsedSeed;

            if (!int.TryParse(seedV11.Text, out parsedSeed))
            {
                MessageBox.Show("Seed must be numeric or blank.", "Seed Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WriteOutputV11("Seed must be numeric or blank.");
            }
            else
            {
                var           romLocations = RomLocationsFactory.GetRomLocations(difficulty);
                RandomizerLog log          = null;

                if (createSpoilerLog.Checked)
                {
                    log = new RandomizerLog(string.Format(romLocations.SeedFileString, parsedSeed));
                }

                seedV11.Text = string.Format(romLocations.SeedFileString, parsedSeed);
                var randomizerV11 = new RandomizerV11(parsedSeed, romLocations, log);
                randomizerV11.CreateRom(filenameV11.Text);

                var outputString = new StringBuilder();

                outputString.AppendFormat("Done!{0}{0}{0}Seed: ", Environment.NewLine);
                outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                outputString.AppendFormat(" ({0} Difficulty){1}{1}", romLocations.DifficultyName, Environment.NewLine);

                WriteOutputV11(outputString.ToString());
            }
        }
Beispiel #2
0
        private void CreateSpoilerLog(RandomizerDifficulty difficulty)
        {
            int parsedSeed;

            if (!int.TryParse(seed.Text, out parsedSeed))
            {
                MessageBox.Show("Seed must be numeric or blank.", "Seed Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WriteOutput("Seed must be numeric or blank.");
            }
            else
            {
                var           romPlms = RomLocationsFactory.GetRomLocations(difficulty);
                RandomizerLog log     = new RandomizerLog(string.Format(romPlms.SeedFileString, parsedSeed));

                seed.Text = string.Format(romPlms.SeedFileString, parsedSeed);

                try
                {
                    var randomizer = new Randomizer(parsedSeed, romPlms, log);

                    WriteOutput(CreateRomThread(randomizer, new RandomizerOptions {
                        SpoilerOnly = true, Difficulty = difficulty
                    }));
                }
                catch (RandomizationException ex)
                {
                    WriteOutput(ex.ToString());
                }
            }
        }
Beispiel #3
0
        private void CreateSpoilerLog(RandomizerDifficulty difficulty)
        {
            if (!int.TryParse(seedField.StringValue, out int parsedSeed))
            {
                var alert = new NSAlert
                {
                    MessageText     = "Seed Error",
                    InformativeText = "Seed must be numeric or blank.",
                    AlertStyle      = NSAlertStyle.Warning
                };
                alert.BeginSheet(this.View.Window);
                WriteOutput("Seed must be numeric or blank.", true);
            }
            else
            {
                var romPlms = RomLocationsFactory.GetRomLocations(difficulty);
                var log     = new RandomizerLog(string.Format(romPlms.SeedFileString, parsedSeed));

                seedField.StringValue = string.Format(romPlms.SeedFileString, parsedSeed);

                try
                {
                    var randomizer = new Randomizer(parsedSeed, romPlms, log);

                    WriteOutput(CreateRomThread(randomizer, new RandomizerOptions {
                        SpoilerOnly = true, Difficulty = difficulty
                    }));
                }
                catch (RandomizationException ex)
                {
                    WriteOutput(ex.ToString(), true);
                }
            }
        }
        private void CreateRom(RandomizerDifficulty difficulty)
        {
            int parsedSeed;

            if (!int.TryParse(seed.Text, out parsedSeed))
            {
                MessageBox.Show("Seed must be numeric or blank.", "Seed Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WriteOutput("Seed must be numeric or blank.");
            }
            else
            {
                var           romPlms = RomLocationsFactory.GetRomLocations(difficulty);
                RandomizerLog log     = null;

                if (createSpoilerLog.Checked)
                {
                    log = new RandomizerLog(string.Format(romPlms.SeedFileString, parsedSeed));
                }

                seed.Text = string.Format(romPlms.SeedFileString, parsedSeed);

                try
                {
                    var randomizer = new Randomizer(parsedSeed, romPlms, log);
                    randomizer.CreateRom(new RandomizerOptions {
                        Filename = filename.Text, SramTrace = sramTrace.Checked
                    });

                    var outputString = new StringBuilder();

                    outputString.AppendFormat("Done!{0}{0}{0}Seed: ", Environment.NewLine);
                    outputString.AppendFormat(romPlms.SeedFileString, parsedSeed);
                    outputString.AppendFormat(" ({0} Difficulty){1}{1}", romPlms.DifficultyName, Environment.NewLine);

                    WriteOutput(outputString.ToString());
                }
                catch (RandomizationException ex)
                {
                    WriteOutput(ex.ToString());
                }
            }
        }
Beispiel #5
0
        private void CreateSpoilerLog(RandomizerDifficulty difficulty)
        {
            int parsedSeed;

            if (!int.TryParse(seedV11.Text, out parsedSeed))
            {
                MessageBox.Show("Seed must be numeric or blank.", "Seed Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WriteOutputV11("Seed must be numeric or blank.");
            }
            else
            {
                var           romPlms = RomLocationsFactory.GetRomLocations(difficulty);
                RandomizerLog log     = new RandomizerLog(string.Format(romPlms.SeedFileString, parsedSeed));

                seedV11.Text = string.Format(romPlms.SeedFileString, parsedSeed);

                var randomizer = new RandomizerV11(parsedSeed, romPlms, log);
                WriteOutputV11(randomizer.CreateRom(filenameV11.Text, true));
            }
        }
Beispiel #6
0
        private void bulkCreate_Click(object sender, EventArgs e)
        {
            if (!filename.Text.Contains("<seed>"))
            {
                MessageBox.Show("Bulk create requires \"<seed>\" be in the file name.", "Filename Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WriteOutput("Bulk create requires \"<seed>\" be in the file name.");
            }
            else
            {
                ClearOutput();

                SetSeedBasedOnDifficulty();

                var difficulty = GetRandomizerDifficulty();

                if (difficulty == RandomizerDifficulty.None)
                {
                    return;
                }

                if (difficulty == RandomizerDifficulty.Casual)
                {
                    WriteCasualMessage();
                }

                int successCount = 0;
                int failCount    = 0;

                for (int seedNum = 0; seedNum < bulkCreateCount.Value; seedNum++)
                {
                    int           parsedSeed   = new SeedRandom().Next(10000000);
                    var           romLocations = RomLocationsFactory.GetRomLocations(difficulty);
                    RandomizerLog log          = null;

                    var outputString = new StringBuilder();
                    outputString.Append("Creating Seed: ");
                    outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                    outputString.AppendFormat(" ({0} Difficulty){1}", romLocations.DifficultyName, Environment.NewLine);
                    WriteOutput(outputString.ToString());

                    if (createSpoilerLog.Checked)
                    {
                        log = new RandomizerLog(string.Format(romLocations.SeedFileString, parsedSeed));
                    }

                    seed.Text = string.Format(romLocations.SeedFileString, parsedSeed);

                    try
                    {
                        int complexity = CreateRom(romLocations, log, GetOptions(), parsedSeed);

                        outputString = new StringBuilder();
                        outputString.AppendFormat("Completed Seed: ");
                        outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                        if (showComplexity.Checked)
                        {
                            outputString.AppendFormat(" ({0} Difficulty - Complexity {2}){1}{1}", romLocations.DifficultyName, Environment.NewLine, complexity);
                        }
                        else
                        {
                            outputString.AppendFormat(" ({0} Difficulty){1}{1}", romLocations.DifficultyName, Environment.NewLine);
                        }
                        WriteOutput(outputString.ToString());

                        successCount++;
                    }
                    catch (RandomizationException ex)
                    {
                        outputString = new StringBuilder();
                        outputString.AppendFormat("FAILED Creating Seed: ");
                        outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                        outputString.AppendFormat(" ({0} Difficulty) - {1}{2}{2}", romLocations.DifficultyName, ex.Message, Environment.NewLine);
                        WriteOutput(outputString.ToString());

                        failCount++;
                        seedNum--;

                        if (failCount >= 3)
                        {
                            WriteOutput(string.Format("Stopping bulk creation after {0} failures.{1}", failCount, Environment.NewLine));
                        }
                    }
                }

                WriteOutput(string.Format("Completed! {0} successful", successCount));
                if (failCount > 0)
                {
                    WriteOutput(string.Format(", {0} failed. ", failCount));
                }
            }

            SaveRandomizerSettings();
        }
Beispiel #7
0
        private void create_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(seed.Text))
            {
                SetSeedBasedOnDifficulty();
            }

            ClearOutput();

            var options = GetOptions();

            if (options.Difficulty == RandomizerDifficulty.None)
            {
                options.NoRandomization = true;
                var randomizer = new Randomizer(0, new RomLocationsNoRandomization(), null);
                randomizer.CreateRom(options);
                WriteOutput("Non-randomized rom created.");

                return;
            }

            int parsedSeed;

            if (!int.TryParse(seed.Text, out parsedSeed))
            {
                MessageBox.Show("Seed must be numeric or blank.", "Seed Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WriteOutput("Seed must be numeric or blank.");
            }
            else
            {
                try
                {
                    var           romLocations = RomLocationsFactory.GetRomLocations(options.Difficulty);
                    RandomizerLog log          = null;

                    if (createSpoilerLog.Checked)
                    {
                        log = new RandomizerLog(string.Format(romLocations.SeedFileString, parsedSeed));
                    }

                    seed.Text = string.Format(romLocations.SeedFileString, parsedSeed);

                    if (options.Difficulty == RandomizerDifficulty.Casual)
                    {
                        WriteCasualMessage();
                    }

                    int complexity = CreateRom(romLocations, log, options, parsedSeed);

                    var outputString = new StringBuilder();

                    outputString.AppendFormat("Done!{0}{0}{0}Seed: ", Environment.NewLine);
                    outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                    if (showComplexity.Checked)
                    {
                        outputString.AppendFormat(" ({0} Difficulty - Complexity {2}){1}{1}", romLocations.DifficultyName, Environment.NewLine, complexity);
                    }
                    else
                    {
                        outputString.AppendFormat(" ({0} Difficulty){1}{1}", romLocations.DifficultyName, Environment.NewLine);
                    }

                    WriteOutput(outputString.ToString());
                }
                catch (RandomizationException ex)
                {
                    WriteOutput(ex.ToString());
                }
            }

            SaveRandomizerSettings();
        }
Beispiel #8
0
        void GenerateRandomizedROM(Foundation.NSObject sender)
        {
            if (string.IsNullOrWhiteSpace(seedField.StringValue))
            {
                SetSeedBasedOnDifficulty();
            }

            ClearOutput();

            var options = GetOptions();

            if (options.Difficulty == RandomizerDifficulty.None)
            {
                options.NoRandomization = true;
                var randomizer = new Randomizer(0, new RomLocationsNoRandomization(), null);
                randomizer.CreateRom(options);
                WriteOutput("Non-randomized rom created.");

                return;
            }


            if (!int.TryParse(seedField.StringValue, out int parsedSeed))
            {
                var alert = new NSAlert
                {
                    MessageText     = "Seed Error",
                    InformativeText = "Seed must be numeric or blank.",
                    AlertStyle      = NSAlertStyle.Warning
                };

                alert.BeginSheet(this.View.Window);

                WriteOutput("Seed must be numeric or blank.", true);
            }
            else
            {
                try
                {
                    var           romLocations = RomLocationsFactory.GetRomLocations(options.Difficulty);
                    RandomizerLog log          = null;

                    if (spoilerLogCheck.State == NSCellStateValue.On)
                    {
                        log = new RandomizerLog(string.Format(romLocations.SeedFileString, parsedSeed));
                    }

                    seedField.StringValue = string.Format(romLocations.SeedFileString, parsedSeed);

                    if (options.Difficulty == RandomizerDifficulty.Casual)
                    {
                        WriteCasualMessage();
                    }

                    var complexity = CreateRom(romLocations, log, options, parsedSeed);

                    var outputString = new StringBuilder();

                    outputString.AppendFormat("Done!{0}{0}{0}Seed: ", Environment.NewLine);
                    outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                    if (complexityCheck.State == NSCellStateValue.On)
                    {
                        outputString.AppendFormat(" ({0} Difficulty - Complexity {2}){1}{1}", romLocations.DifficultyName, Environment.NewLine, complexity);
                    }
                    else
                    {
                        outputString.AppendFormat(" ({0} Difficulty){1}{1}", romLocations.DifficultyName, Environment.NewLine);
                    }

                    WriteOutput(outputString.ToString());
                }
                catch (RandomizationException ex)
                {
                    WriteOutput(ex.ToString(), true);
                }
            }

            SaveRandomizerSettings();
        }
Beispiel #9
0
        void GenerateMultipleROMs(Foundation.NSObject sender)
        {
            NSAlert alert;

            if (!filename.Contains("<seed>"))
            {
                alert = new NSAlert
                {
                    MessageText     = "Filename Error",
                    InformativeText = "Bulk create requires \"<seed>\" be in the file name.",
                    AlertStyle      = NSAlertStyle.Critical
                };
                alert.BeginSheet(this.View.Window);
                WriteOutput("Bulk create requires \"<seed>\" be in the file name.", true);
            }
            else
            {
                ClearOutput();

                SetSeedBasedOnDifficulty();

                var difficulty = GetRandomizerDifficulty();

                if (difficulty == RandomizerDifficulty.None)
                {
                    return;
                }

                if (difficulty == RandomizerDifficulty.Casual)
                {
                    WriteCasualMessage();
                }

                int successCount = 0;
                int failCount    = 0;

                for (int seedNum = 0; seedNum < bulkStepper.IntValue; seedNum++)
                {
                    var           parsedSeed   = new SeedRandom().Next(10000000);
                    var           romLocations = RomLocationsFactory.GetRomLocations(difficulty);
                    RandomizerLog log          = null;

                    var outputString = new StringBuilder();
                    outputString.Append("Creating Seed: ");
                    outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                    outputString.AppendFormat(" ({0} Difficulty){1}", romLocations.DifficultyName, Environment.NewLine);
                    WriteOutput(outputString.ToString());

                    if (spoilerLogCheck.State == NSCellStateValue.On)
                    {
                        log = new RandomizerLog(string.Format(romLocations.SeedFileString, parsedSeed));
                    }

                    seedField.StringValue = string.Format(romLocations.SeedFileString, parsedSeed);

                    try
                    {
                        var complexity = CreateRom(romLocations, log, GetOptions(), parsedSeed);

                        outputString = new StringBuilder();
                        outputString.AppendFormat("Completed Seed: ");
                        outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                        if (complexityCheck.State == NSCellStateValue.On)
                        {
                            outputString.AppendFormat(" ({0} Difficulty - Complexity {2}){1}{1}", romLocations.DifficultyName, Environment.NewLine, complexity);
                        }
                        else
                        {
                            outputString.AppendFormat(" ({0} Difficulty){1}{1}", romLocations.DifficultyName, Environment.NewLine);
                        }
                        WriteOutput(outputString.ToString());

                        successCount++;
                    }
                    catch (RandomizationException ex)
                    {
                        outputString = new StringBuilder();
                        outputString.AppendFormat("FAILED Creating Seed: ");
                        outputString.AppendFormat(romLocations.SeedFileString, parsedSeed);
                        outputString.AppendFormat(" ({0} Difficulty) - {1}{2}{2}", romLocations.DifficultyName, ex.Message, Environment.NewLine);
                        WriteOutput(outputString.ToString());

                        failCount++;
                        seedNum--;

                        if (failCount >= 3)
                        {
                            WriteOutput(string.Format("Stopping bulk creation after {0} failures.{1}", failCount, Environment.NewLine), true);
                        }
                    }
                }

                var finishedString = new NSMutableAttributedString(string.Format("Completed! {0} successful", successCount));

                if (failCount > 0)
                {
                    finishedString.Append(new NSAttributedString(", "));
                    finishedString.Append(new NSAttributedString(string.Format("{0} failed. ", failCount), null, NSColor.Red));
                }
                else
                {
                    finishedString.Append(new NSAttributedString("."));
                }

                WriteOutput(finishedString);
                alert = new NSAlert
                {
                    MessageText     = "Bulk Creation Complete",
                    InformativeText = finishedString.Value,
                    AlertStyle      = failCount > 0 ? NSAlertStyle.Informational : NSAlertStyle.Warning
                };
                alert.BeginSheet(this.View.Window);
            }

            SaveRandomizerSettings();
        }