Exemplo n.º 1
0
        public IActionResult Randomize()
        {
            var vm = new RandomizeViewModel {
                File  = null,
                Seed  = Blob.Random(4).ToHex(),
                Flags = Flags.FromJson(System.IO.File.ReadAllText(Path.Combine(Startup.GetPresetsDirectory(), "default.json")))
            };

            vm.FlagsInput = Flags.EncodeFlagsText(vm.Flags);

            return(View(vm));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Randomize(RandomizeViewModel viewModel)
        {
            // Easier to just early return here and not have to verify viewModel.File != null repeatedly.
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            if (viewModel.File.Length < 256 * 1024 || viewModel.File.Length > (256 + 8) * 1024)
            {
                ModelState.AddModelError("File", "Unexpected file length, FF1 ROM should be close to 256 kB.");
            }

            var rom = await FF1Rom.CreateAsync(viewModel.File.OpenReadStream());

            if (!rom.Validate())
            {
                ModelState.AddModelError("File", "File does not appear to be a valid FF1 NES ROM.");
            }

            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            rom.Randomize(Blob.FromHex(viewModel.Seed), viewModel.Flags);

            var filename  = viewModel.File.FileName;
            var pathIndex = filename.LastIndexOfAny(new[] { '\\', '/' });

            filename = pathIndex == -1 ? filename : filename.Substring(pathIndex + 1);

            var extensionIndex = filename.LastIndexOf('.');
            var newFilename    = extensionIndex == -1 ? filename : filename.Substring(0, extensionIndex);

            newFilename = $"{newFilename}_{viewModel.Seed}_{Flags.EncodeFlagsText(viewModel.Flags)}.nes";

            Response.StatusCode    = 200;
            Response.ContentLength = rom.TotalLength;
            Response.ContentType   = "application/octet-stream";
            Response.Headers.Add("Content-Disposition", $"attachment; filename=\"{newFilename}\"");

            await rom.SaveAsync(Response.Body);

            Response.Body.Close();

            return(new EmptyResult());
        }
Exemplo n.º 3
0
        public IActionResult Randomize()
        {
            var vm = new RandomizeViewModel {
                File  = null,
                Seed  = Blob.Random(4).ToHex(),
                Flags = new Flags {
                    Treasures     = true,
                    NPCItems      = true,
                    NPCFetchItems = false,

                    Shops            = true,
                    MagicShops       = false,
                    MagicLevels      = true,
                    MagicPermissions = false,

                    Rng = true,

                    EnemyScripts       = false,
                    EnemySkillsSpells  = true,
                    EnemyStatusAttacks = true,

                    OrdealsPillars = true,
                    TitansTrove    = true,

                    MapOpenProgression = false,

                    IncentivizeFreeNPCs   = true,
                    IncentivizeFetchNPCs  = false,
                    IncentivizeFetchItems = false,

                    IncentivizeMarsh          = true,
                    IncentivizeMarshKeyLocked = false,
                    IncentivizeVolcano        = false,
                    IncentivizeConeria        = true,
                    IncentivizeEarth          = true,
                    IncentivizeIceCave        = true,
                    IncentivizeOrdeals        = true,
                    IncentivizeSeaShrine      = false,
                    IncentivizeSkyPalace      = false,

                    IncentivizeTail     = true,
                    IncentivizeMasamune = true,
                    IncentivizeOpal     = true,
                    IncentivizeRibbon   = true,
                    IncentivizeRibbon2  = false,
                    Incentivize65K      = false,
                    IncentivizeBad      = false,

                    IncentivizeDefCastArmor    = false,
                    IncentivizeOffCastArmor    = false,
                    IncentivizeOtherCastArmor  = false,
                    IncentivizeDefCastWeapon   = false,
                    IncentivizeOffCastWeapon   = false,
                    IncentivizeOtherCastWeapon = false,

                    EarlySarda       = true,
                    EarlySage        = true,
                    CrownlessOrdeals = true,

                    FreeBridge  = false,
                    FreeAirship = false,
                    EasyMode    = false,

                    NoPartyShuffle    = true,
                    SpeedHacks        = true,
                    IdentifyTreasures = true,
                    Dash   = true,
                    BuyTen = true,

                    HouseMPRestoration   = true,
                    WeaponStats          = true,
                    ChanceToRun          = true,
                    SpellBugs            = true,
                    EnemyStatusAttackBug = true,

                    ForcedPartyMembers = 0,
                    PriceScaleFactor   = 3.0,
                    EnemyScaleFactor   = 1.5,
                    ExpMultiplier      = 2.5,
                    ExpBonus           = 250,

                    FunEnemyNames     = false,
                    PaletteSwap       = false,
                    TeamSteak         = false,
                    ModernBattlefield = false,
                    Music             = MusicShuffle.None
                }
            };

            vm.FlagsInput = vm.Flags.GetString();

            return(View(vm));
        }
Exemplo n.º 4
0
        public IActionResult Randomize()
        {
            var vm = new RandomizeViewModel {
                File  = null,
                Seed  = Blob.Random(4).ToHex(),
                Flags = new Flags {
                    Treasures = true,
                    NPCItems  = true,

                    IncentivizeKingConeria = true,
                    IncentivizePrincess    = true,
                    IncentivizeMatoya      = false,
                    IncentivizeBikke       = true,
                    IncentivizeElfPrince   = false,
                    IncentivizeAstos       = true,
                    IncentivizeNerrick     = false,
                    IncentivizeSmith       = true,
                    IncentivizeSarda       = true,
                    IncentivizeCanoeSage   = true,
                    IncentivizeCubeBot     = true,
                    IncentivizeFairy       = false,
                    IncentivizeLefein      = true,
                    IncentivizeMarsh       = true,
                    IncentivizeVolcano     = true,
                    IncentivizeConeria     = false,
                    IncentivizeEarth       = true,
                    IncentivizeIceCave     = false,
                    IncentivizeOrdeals     = true,
                    IncentivizeSeaShrine   = true,

                    IncentivizeBridge        = true,
                    IncentivizeLute          = true,
                    IncentivizeShip          = true,
                    IncentivizeCrown         = true,
                    IncentivizeCrystal       = false,
                    IncentivizeHerb          = false,
                    IncentivizeKey           = true,
                    IncentivizeTnt           = false,
                    IncentivizeCanal         = true,
                    IncentivizeRuby          = true,
                    IncentivizeRod           = true,
                    IncentivizeCanoe         = true,
                    IncentivizeFloater       = true,
                    IncentivizeTail          = true,
                    IncentivizeBottle        = false,
                    IncentivizeOxyale        = true,
                    IncentivizeSlab          = true,
                    IncentivizeChime         = true,
                    IncentivizeCube          = true,
                    IncentivizeAdamant       = true,
                    IncentivizeXcalber       = false,
                    IncentivizeMasamune      = true,
                    IncentivizeRibbon        = false,
                    IncentivizeRibbon2       = false,
                    IncentivizePowerGauntlet = true,
                    IncentivizeWhiteShirt    = true,
                    IncentivizeBlackShirt    = false,
                    IncentivizeOpal          = true,
                    Incentivize65K           = false,
                    IncentivizeBad           = false,

                    Shops            = true,
                    MagicShops       = false,
                    MagicLevels      = true,
                    MagicPermissions = false,
                    Rng                       = true,
                    EnemyScripts              = true,
                    EnemySkillsSpells         = true,
                    EnemyStatusAttacks        = true,
                    EnemyFormationsUnrunnable = true,
                    EnemyFormationsSurprise   = true,

                    EarlyRod          = true,
                    EarlyCanoe        = true,
                    EarlyOrdeals      = true,
                    EarlyBridge       = true,
                    NoPartyShuffle    = true,
                    SpeedHacks        = true,
                    IdentifyTreasures = true,
                    Dash               = true,
                    BuyTen             = true,
                    WaitWhenUnrunnable = true,

                    HouseMPRestoration   = true,
                    WeaponStats          = true,
                    ChanceToRun          = true,
                    SpellBugs            = true,
                    EnemyStatusAttackBug = true,

                    FunEnemyNames     = true,
                    PaletteSwap       = true,
                    TeamSteak         = true,
                    ModernBattlefield = true,
                    Music             = MusicShuffle.None,

                    ForcedPartyMembers = 1,
                    PriceScaleFactor   = 3.0,
                    EnemyScaleFactor   = 1.5,
                    ExpMultiplier      = 3.0,
                    ExpBonus           = 100,
                    EasyMode           = false,

                    Ordeals            = true,
                    MapConeriaDwarves  = true,
                    MapVolcanoIceRiver = true,
                    MapTitansTrove     = true
                }
            };

            vm.FlagsInput = vm.Flags.GetString();

            return(View(vm));
        }