Beispiel #1
0
        /*TODO Maybe use later, for now will not take a file name
         * //On submit of rando file name
         * bool OnEnterRandoFileName(string fileName)
         * {
         *  Console.WriteLine($"File name received: {fileName}");
         *  randoFileName = fileName;
         *
         *  //Pop up next input for which file slot to create this file in
         *  TextEntryPopup fileSlotPopup = InitTextEntryPopup(generateSeedButton.addedTo, "Which save slot would you like to start a rando seed?", (entry) => OnEnterRandoFileSlot(entry), 1, null, CharsetFlags.Number);
         *  fileSlotPopup.onBack += () =>
         *  {
         *      fileSlotPopup.gameObject.SetActive(false);
         *      generateSeedButton.textEntryPopup.gameObject.SetActive(true);
         *      generateSeedButton.textEntryPopup.StartCoroutine(generateSeedButton.textEntryPopup.BackWhenBackButtonReleased());
         *  };
         *  generateSeedButton.textEntryPopup.gameObject.SetActive(false);
         *
         *  //Initialize the file slot popup
         *  fileSlotPopup.Init(string.Empty);
         *  fileSlotPopup.gameObject.SetActive(true);
         *  fileSlotPopup.transform.SetParent(generateSeedButton.addedTo.transform.parent);
         *  generateSeedButton.addedTo.gameObject.SetActive(false);
         *  Canvas.ForceUpdateCanvases();
         *  fileSlotPopup.initialSelection.GetComponent<UIObjectAudioHandler>().playAudio = false;
         *  EventSystem.current.SetSelectedGameObject(fileSlotPopup.initialSelection);
         *  fileSlotPopup.initialSelection.GetComponent<UIObjectAudioHandler>().playAudio = true;
         *  return false;
         * }
         */

        ///On submit of rando file location
        bool OnEnterFileSlot(string fileSlot)
        {
            Console.WriteLine($"In Method: OnEnterFileSlot. Provided value: '{fileSlot}'");
            Console.WriteLine($"Received file slot number: {fileSlot}");
            int slot = Convert.ToInt32(fileSlot);

            if (slot < 1 || slot > 3)
            {
                Console.WriteLine($"Invalid slot number provided: {slot}");
                return(false);
            }

            //Load in mappings and save them to the state

            //Load encoded seed information
            string encodedSeedInfo = ItemRandomizerUtil.LoadMappingsFromFile(slot);

            Console.WriteLine($"File reading complete. Received the following encoded seed info: '{encodedSeedInfo}'");
            string decodedSeedInfo = ItemRandomizerUtil.DecryptSeedInfo(encodedSeedInfo);

            Console.WriteLine($"Decryption complete. Received the following seed info: '{decodedSeedInfo}'");

            SeedRO seedRO = ItemRandomizerUtil.ParseSeed(slot, decodedSeedInfo);

            randoStateManager.AddSeed(seedRO);

            //Save
            Save.seedData = randomizerSaveMethod.GenerateSaveData();

            return(true);
        }
Beispiel #2
0
        void SaveGameSelectionScreen_OnLoadGame(On.SaveGameSelectionScreen.orig_OnLoadGame orig, SaveGameSelectionScreen self, int slotIndex)
        {
            //slotIndex is 0-based, going to increment it locally to keep things simple.
            int fileSlot = slotIndex + 1;

            //Generate the mappings based on the seed for the game if a seed was generated.
            if (randoStateManager.HasSeedForFileSlot(fileSlot))
            {
                Console.WriteLine($"Seed exists for file slot {fileSlot}. Generating mappings.");

                //Load mappings
                randoStateManager.CurrentLocationToItemMapping = ItemRandomizerUtil.ParseLocationToItemMappings(randoStateManager.GetSeedForFileSlot(fileSlot));
                randoStateManager.CurrentLocationDialogtoRandomDialogMapping = DialogChanger.GenerateDialogMappingforItems();

                randoStateManager.IsRandomizedFile = true;
                randoStateManager.CurrentFileSlot  = fileSlot;
                //Log spoiler log
                randoStateManager.LogCurrentMappings();

                //We force a reload of all dialog when loading the game
                Manager <DialogManager> .Instance.LoadDialogs(Manager <LocalizationManager> .Instance.CurrentLanguage);
            }
            else
            {
                //This save file does not have a seed associated with it or is not a randomized file. Reset the mappings so everything is back to normal.
                Console.WriteLine($"This file slot ({fileSlot}) has no seed generated or is not a randomized file. Resetting the mappings and putting game items back to normal.");
                randoStateManager.ResetRandomizerState();
            }

            orig(self, slotIndex);
        }
Beispiel #3
0
        public void TestGetMod()
        {
            CourierModuleMetadata mod = new CourierModuleMetadata();

            mod.Name          = "TheMessengerRandomizer";
            mod.VersionString = "3.5";
            Courier.Mods.Add(mod);

            string version = ItemRandomizerUtil.GetModVersion();

            Assert.AreEqual(mod.VersionString, version);
        }
Beispiel #4
0
        public override void Load()
        {
            Console.WriteLine("Randomizer loading and ready to try things!");

            //Initialize the randomizer state manager
            RandomizerStateManager.Initialize();
            randoStateManager = RandomizerStateManager.Instance;

            //Set up save data utility
            randomizerSaveMethod = new RandomizerSaveMethod();

            //Add Randomizer Version button
            versionButton = Courier.UI.RegisterSubMenuModOptionButton(() => "Messenger Randomizer: v" + ItemRandomizerUtil.GetModVersion(), null);

            //Add current seed number button
            seedNumButton = Courier.UI.RegisterSubMenuModOptionButton(() => "Current seed number: " + GetCurrentSeedNum(), null);

            //Add load seed file button
            loadRandomizerFileForFileSlotButton = Courier.UI.RegisterTextEntryModOptionButton(() => "Load Randomizer File For File Slot", (entry) => OnEnterFileSlot(entry), 1, () => "Which save slot would you like to start a rando seed?(1/2/3)", () => "1", CharsetFlags.Number);

            //Add windmill shuriken toggle button
            windmillShurikenToggleButton = Courier.UI.RegisterSubMenuModOptionButton(() => Manager <ProgressionManager> .Instance.useWindmillShuriken ? "Active Regular Shurikens" : "Active Windmill Shurikens", OnToggleWindmillShuriken);

            //Add teleport to HQ button
            teleportToHqButton = Courier.UI.RegisterSubMenuModOptionButton(() => "Teleport to HQ", OnSelectTeleportToHq);

            //Add teleport to Ninja Village button
            teleportToNinjaVillage = Courier.UI.RegisterSubMenuModOptionButton(() => "Teleport to Ninja Village", OnSelectTeleportToNinjaVillage);


            //Plug in my code :3
            On.InventoryManager.AddItem         += InventoryManager_AddItem;
            On.InventoryManager.GetItemQuantity += InventoryManager_GetItemQuantity;
            On.ProgressionManager.SetChallengeRoomAsCompleted += ProgressionManager_SetChallengeRoomAsCompleted;
            On.HasItem.IsTrue += HasItem_IsTrue;
            On.AwardNoteCutscene.ShouldPlay              += AwardNoteCutscene_ShouldPlay;
            On.CutsceneHasPlayed.IsTrue                  += CutsceneHasPlayed_IsTrue;
            On.SaveGameSelectionScreen.OnLoadGame        += SaveGameSelectionScreen_OnLoadGame;
            On.SaveGameSelectionScreen.OnNewGame         += SaveGameSelectionScreen_OnNewGame;
            On.NecrophobicWorkerCutscene.Play            += NecrophobicWorkerCutscene_Play;
            IL.RuxxtinNoteAndAwardAmuletCutscene.Play    += RuxxtinNoteAndAwardAmuletCutscene_Play;
            On.CatacombLevelInitializer.OnBeforeInitDone += CatacombLevelInitializer_OnBeforeInitDone;
            On.DialogManager.LoadDialogs_ELanguage       += DialogChanger.LoadDialogs_Elanguage;
            On.UpgradeButtonData.IsStoryUnlocked         += UpgradeButtonData_IsStoryUnlocked;
            //temp add
            On.PowerSeal.OnEnterRoom        += PowerSeal_OnEnterRoom;
            On.DialogSequence.GetDialogList += DialogSequence_GetDialogList;

            Console.WriteLine("Randomizer finished loading!");
        }
Beispiel #5
0
        public void TestIsSeedBeatablePredeterminedBadSeed()
        {
            //Setup
            EItems[] noAdditionalRequirements = { EItems.NONE };
            EItems[] additionalRequirements   = { EItems.DEMON_KING_CROWN, EItems.FAIRY_BOTTLE };

            //Create location with no requirments
            LocationRO locationNoRequirements = new LocationRO("No requirements location", "No requirements location", noAdditionalRequirements, false, false, false);

            //Create location with Ropedart requirements
            LocationRO locationRopedartRequirements = new LocationRO("Ropedart location", "Ropedart location", noAdditionalRequirements, false, true, false);

            //Create location with Wingsuit requirements
            LocationRO locationWingsuitRequirements = new LocationRO("Wingsuit location", "Wingsuit location", noAdditionalRequirements, true, false, false);

            //Create location with Ninja Tabi requirements
            LocationRO locationTabiRequirements = new LocationRO("Ninja Tabi location", "Ninja Tabi location", noAdditionalRequirements, false, false, true);

            //Create location with either ropedart or wingsuit requirements
            LocationRO locationRopedartOrWingsuitRequirements = new LocationRO("Ropedart or Wingsuit location", "Ropedart or Wingsuit location", noAdditionalRequirements, false, false, false, true);

            //Create location with ropedart and wingsuit requirements
            LocationRO locationRopedartAndWingsuitRequirements = new LocationRO("Ropedart and Wingsuit location", "Ropedart and Wingsuit location", noAdditionalRequirements, true, true, false);

            //Create location with all key requirements
            LocationRO locationAllKeyRequirements  = new LocationRO("All key location", "All key location", noAdditionalRequirements, true, true, true);
            LocationRO locationAllKeyRequirements2 = new LocationRO("All key location2", "All key location2", noAdditionalRequirements, true, true, true);
            LocationRO locationAllKeyRequirements3 = new LocationRO("All key location3", "All key location3", noAdditionalRequirements, true, true, true);
            LocationRO locationAllKeyRequirements4 = new LocationRO("All key location4", "All key location4", noAdditionalRequirements, true, true, true);

            //Create location with only some additional requirements
            LocationRO locationAdditionalRequirements = new LocationRO("Additional location", "Additional location", additionalRequirements, false, false, false);

            //Create location with a key requirement and some additional requirements
            LocationRO locationKeyAndAdditionalRequirements = new LocationRO("Key and Additional location", "Key and Additional location", additionalRequirements, true, false, false);

            //Load up the mappings
            Dictionary <LocationRO, RandoItemRO> mappings = new Dictionary <LocationRO, RandoItemRO>();

            mappings.Add(locationRopedartRequirements, new RandoItemRO("Seashell", EItems.SEASHELL));
            mappings.Add(locationWingsuitRequirements, new RandoItemRO("Rope Dart", EItems.GRAPLOU));
            mappings.Add(locationRopedartOrWingsuitRequirements, new RandoItemRO("Ninja Tabi", EItems.MAGIC_BOOTS));
            mappings.Add(locationRopedartAndWingsuitRequirements, new RandoItemRO("Demon Crown", EItems.DEMON_KING_CROWN));
            mappings.Add(locationAllKeyRequirements, new RandoItemRO("Fairy", EItems.FAIRY_BOTTLE));
            mappings.Add(locationAdditionalRequirements, new RandoItemRO("KEY_OF_CHAOS", EItems.KEY_OF_CHAOS));
            mappings.Add(locationKeyAndAdditionalRequirements, new RandoItemRO("KEY_OF_COURAGE", EItems.KEY_OF_COURAGE));
            mappings.Add(locationTabiRequirements, new RandoItemRO("KEY_OF_HOPE", EItems.KEY_OF_HOPE));
            mappings.Add(locationAllKeyRequirements2, new RandoItemRO("KEY_OF_LOVE", EItems.KEY_OF_LOVE));
            mappings.Add(locationAllKeyRequirements3, new RandoItemRO("KEY_OF_STRENGTH", EItems.KEY_OF_STRENGTH));
            mappings.Add(locationAllKeyRequirements4, new RandoItemRO("KEY_OF_SYMBIOSIS", EItems.KEY_OF_SYMBIOSIS));

            //Logging
            Console.WriteLine($"\nStatic Bad Seed. Mappings are as follows:\n");

            foreach (LocationRO location in mappings.Keys)
            {
                Console.WriteLine($"Location '{location.PrettyLocationName}' contains item '{mappings[location]}'");
            }

            //Validate that this seed is not beatable
            Assert.IsFalse(ItemRandomizerUtil.IsSeedBeatable(mappings));
        }