/// <summary> /// Check through the mappings for any location that is represented by vanilla location item(since that is the key used to uniquely identify locations). /// </summary> /// <param name="vanillaLocationItem">EItem being used to look up location.</param> /// <param name="locationFromItem">Out parameter used to return the location found.</param> /// <returns>true if location was found, otherwise false(location item will be null in this case)</returns> public bool IsLocationRandomized(EItems vanillaLocationItem, out LocationRO locationFromItem) { bool isLocationRandomized = false; locationFromItem = null; //We'll check through notes first foreach (RandoItemRO note in RandomizerConstants.GetNotesList()) { if (note.Item.Equals(vanillaLocationItem)) { locationFromItem = new LocationRO(note.Name); if (CurrentLocationToItemMapping.ContainsKey(locationFromItem)) { isLocationRandomized = true; } else { //Then we know for certain it was not randomized. No reason to continue. locationFromItem = null; return(false); } } } //If it wasn't a note we'll look through the rest of the items if (!isLocationRandomized) { //Real quick, check Climbing Claws because it is special if (EItems.CLIMBING_CLAWS.Equals(vanillaLocationItem)) { locationFromItem = new LocationRO("Climbing_Claws"); return(true); } foreach (RandoItemRO item in RandomizerConstants.GetRandoItemList()) { if (item.Item.Equals(vanillaLocationItem)) { locationFromItem = new LocationRO(item.Name); if (CurrentLocationToItemMapping.ContainsKey(locationFromItem)) { isLocationRandomized = true; } else { //Then we know for certain it was not randomized. locationFromItem = null; return(false); } } } } //Return whether we found it or not. return(isLocationRandomized); }
void ProgressionManager_SetChallengeRoomAsCompleted(On.ProgressionManager.orig_SetChallengeRoomAsCompleted orig, ProgressionManager self, string roomKey) { //if this is a rando file, go ahead and give the item we expect to get if (randoStateManager.IsRandomizedFile) { LocationRO powerSealLocation = null; foreach (LocationRO location in RandomizerConstants.GetAdvancedRandoLocationList()) { if (location.LocationName.Equals(roomKey)) { powerSealLocation = location; } } if (powerSealLocation == null) { throw new RandomizerException($"Challenge room with room key '{roomKey}' was not found in the list of locations. This will need to be corrected for this challenge room to work."); } RandoItemRO challengeRoomRandoItem = RandomizerStateManager.Instance.CurrentLocationToItemMapping[powerSealLocation]; Console.WriteLine($"Challenge room '{powerSealLocation.PrettyLocationName}' completed. Providing rando item '{challengeRoomRandoItem}'."); //Handle timeshards if (EItems.TIME_SHARD.Equals(challengeRoomRandoItem.Item)) { Manager <InventoryManager> .Instance.CollectTimeShard(1); //Set this item to have been collected in the state manager randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Add(challengeRoomRandoItem); } else { //Before adding the item to the inventory, add this item to the override RandomizerStateManager.Instance.AddTempRandoItemOverride(challengeRoomRandoItem.Item); Manager <InventoryManager> .Instance.AddItem(challengeRoomRandoItem.Item, 1); //Now remove the override RandomizerStateManager.Instance.RemoveTempRandoItemOverride(challengeRoomRandoItem.Item); } //I want to try to have a dialog popup say what the player got. DialogSequence challengeSequence = ScriptableObject.CreateInstance <DialogSequence>(); challengeSequence.dialogID = "RANDO_ITEM"; challengeSequence.name = challengeRoomRandoItem.Item.ToString(); challengeSequence.choices = new List <DialogSequenceChoice>(); AwardItemPopupParams challengeAwardItemParams = new AwardItemPopupParams(challengeSequence, true); Manager <UIManager> .Instance.ShowView <AwardItemPopup>(EScreenLayers.PROMPT, challengeAwardItemParams, true); } //For now calling the orig method once we are done so the game still things we are collecting seals. We can change this later. orig(self, roomKey); }
/// <summary> /// Parses the mappings string from the seed to create the mappings collection for this seed. /// </summary> /// <param name="seed">Seed whos mappings we wish to parse.</param> /// <returns>Collection of mappings.</returns> public static Dictionary <LocationRO, RandoItemRO> ParseLocationToItemMappings(SeedRO seed) { //Prep Dictionary <LocationRO, RandoItemRO> mappings = new Dictionary <LocationRO, RandoItemRO>(); Dictionary <string, LocationRO> officialLocations = new Dictionary <string, LocationRO>(); Dictionary <string, RandoItemRO> officialItems = new Dictionary <string, RandoItemRO>(); //Fill official collections for easy searching foreach (LocationRO location in RandomizerConstants.GetRandoLocationList()) { officialLocations.Add(location.LocationName, location); } foreach (RandoItemRO item in RandomizerConstants.GetRandoItemList()) { officialItems.Add(item.Name, item); } foreach (RandoItemRO item in RandomizerConstants.GetNotesList()) { officialItems.Add(item.Name, item); } //loading for advanced seeds if (seed.Settings[SettingType.Difficulty].Equals(SettingValue.Advanced)) { //locations foreach (LocationRO location in RandomizerConstants.GetAdvancedRandoLocationList()) { officialLocations.Add(location.LocationName, location); } //items foreach (RandoItemRO item in RandomizerConstants.GetAdvancedRandoItemList()) { officialItems.Add(item.Name, item); } } //Split up all the mappings string[] mappingsArr = seed.MappingInfo.Split(','); foreach (string mappingStr in mappingsArr) { //Split off the location and item string string[] mappingArr = mappingStr.Split('~'); LocationRO location = null; RandoItemRO item = new RandoItemRO(); //Get the LocationRO and RandoItemRO from the list of known items if (officialLocations.ContainsKey(mappingArr[0])) { location = officialLocations[mappingArr[0]]; } else { //If for some reason something that could not be mapped to an official location, let's fail for now. throw new RandomizerException($"Location named '{mappingArr[0]}' could not be located in collection of official locations."); } if (officialItems.ContainsKey(mappingArr[1])) { item = officialItems[mappingArr[1]]; } else { //If for some reason something that could not be mapped to an official location, let's fail for now. throw new RandomizerException($"Item named '{mappingArr[1]}' could not be located in collection of official items."); } //We get here, then we are good. Save off this mapping and move on. mappings.Add(location, item); } Console.WriteLine("Mapping parsed successfully!"); return(mappings); }
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)); }