Example #1
0
        // update battle archive
        private static void BattleOps(int seed, SpoilerFile spoilerFile, State settings)
        {
            Debug.WriteLine("battle ops start");
            while (true)
            {
                try
                {
                    CreateOrRestoreArchiveBackup(Globals.BattlePath);
                    var battleSource = new FileSource(Globals.BattlePath);

                    // boss shuffle
                    if (settings.BossEnable)
                    {
                        var bossMap = Boss.Randomise(seed, settings);
                        if (settings.SpoilerFile)
                        {
                            spoilerFile.AddBosses(bossMap);
                        }
                        Boss.Apply(battleSource, bossMap);
                    }

                    // loot shuffle
                    var drops  = settings.LootDrops;
                    var steals = settings.LootSteals;
                    var draws  = settings.LootDraws;

                    if (drops || steals || draws)
                    {
                        var shuffle = LootShuffle.Randomise(battleSource, seed, settings);
                        if (settings.SpoilerFile)
                        {
                            spoilerFile.AddLoot(shuffle, drops, steals, draws);
                        }
                    }

                    if (settings.BossEnable || drops || steals || draws)
                    {
                        battleSource.Encode();
                    }

                    break;
                }
                catch (Exception x)
                {
                    if (x is IOException || x is UnauthorizedAccessException || x is FileNotFoundException)
                    {
                        if (HandleFileException(Globals.BattlePath) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            Debug.WriteLine("battle ops end");
        }
Example #2
0
        // update battle archive
        private static void BattleOps(int seed, SpoilerFile spoilerFile)
        {
            Debug.WriteLine("battle ops start");
            while (true)
            {
                try
                {
                    CreateOrRestoreArchiveBackup(Globals.BattlePath);
                    var battleSource = new FileSource(Globals.BattlePath);

                    // boss shuffle/rebalance
                    if (Properties.Settings.Default.BossShuffle)
                    {
                        var shuffle = Boss.Shuffle(battleSource, Properties.Settings.Default.BossRebalance, seed);
                        if (Properties.Settings.Default.SpoilerFile)
                        {
                            spoilerFile.AddBosses(shuffle);
                        }
                    }

                    // loot shuffle
                    if (Properties.Settings.Default.LootShuffle)
                    {
                        var shuffle = LootShuffle.Randomise(battleSource, seed);
                        if (Properties.Settings.Default.SpoilerFile)
                        {
                            spoilerFile.AddLoot(shuffle);
                        }
                    }

                    if (Properties.Settings.Default.BossShuffle || Properties.Settings.Default.LootShuffle)
                    {
                        battleSource.Encode();
                    }

                    break;
                }
                catch (Exception x)
                {
                    if (x is IOException || x is UnauthorizedAccessException || x is FileNotFoundException)
                    {
                        if (HandleFileException(Globals.BattlePath) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            Debug.WriteLine("battle ops end");
        }