Esempio n. 1
0
        // update multiple files on 2nd pass
        private static void FinalOps(int seed, string seedString, SpoilerFile spoilerFile)
        {
            Debug.WriteLine("final ops start");
            while (true)
            {
                try
                {
                    // free roam rewards
                    if (Properties.Settings.Default.StorySkip)
                    {
                        var battleSource = new FileSource(Globals.BattlePath);
                        var fieldSource  = new FileSource(Globals.FieldPath);
                        Reward.SetRewards(battleSource, fieldSource, seed);
                        battleSource.Encode();
                        fieldSource.Encode();
                    }
                    break;
                }
                catch (Exception x)
                {
                    if (x is IOException || x is UnauthorizedAccessException || x is FileNotFoundException)
                    {
                        if (HandleFileException(Globals.BattlePath) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            // save spoiler file
            if (Properties.Settings.Default.SpoilerFile)
            {
                // strip illegal chars from filename
                var invalidChars = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
                var regex        = new Regex(string.Format("[{0}]", Regex.Escape(invalidChars)));
                File.WriteAllText("spoilers." + regex.Replace(seedString, "_") + ".txt", spoilerFile.ToString());
            }
            Debug.WriteLine("final ops end");
        }
Esempio n. 2
0
        // update multiple files on 2nd pass
        private static void FinalOps(int seed, string seedString, SpoilerFile spoilerFile, State settings)
        {
            Debug.WriteLine("final ops start");
            while (true)
            {
                try
                {
                    // weapon shuffle
                    if (settings.UpgradeEnable)
                    {
                        var mainSource = new FileSource(Globals.MainPath);
                        var menuSource = new FileSource(Globals.MenuPath);

                        var shuffle = WeaponShuffle.Randomise(seed, settings);
                        if (settings.SpoilerFile)
                        {
                            spoilerFile.AddWeapons(mainSource, shuffle);
                        }
                        WeaponShuffle.Apply(menuSource, shuffle);

                        menuSource.Encode();
                    }

                    // free roam rewards
                    if (settings.FreeRoam || settings.BossEnable)
                    {
                        var battleSource = new FileSource(Globals.BattlePath);
                        var fieldSource  = new FileSource(Globals.FieldPath);

                        if (settings.FreeRoam)
                        {
                            Reward.SetRewards(battleSource, fieldSource, seed);
                        }
                        if (settings.BossEnable)
                        {
                            Boss.ApplyEdeaFix(battleSource, fieldSource);
                        }

                        battleSource.Encode();
                        fieldSource.Encode();
                    }
                    break;
                }
                catch (Exception x)
                {
                    if (x is IOException || x is UnauthorizedAccessException || x is FileNotFoundException)
                    {
                        if (HandleFileException(Globals.BattlePath) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            // save spoiler file
            if (settings.SpoilerFile)
            {
                // strip illegal chars from filename

                File.WriteAllText("spoilers." + SanitizeFileName(seedString) + ".txt", spoilerFile.ToString());
            }
            Debug.WriteLine("final ops end");
        }