private static void CollectItemForBeatableSeedCheck(RandoItemRO itemToCollect, ref SamplePlayerRO player) { //Handle the various types of items switch (itemToCollect.Item) { case EItems.WINGSUIT: player.HasWingsuit = true; break; case EItems.GRAPLOU: player.HasRopeDart = true; break; case EItems.MAGIC_BOOTS: player.HasNinjaTabis = true; break; case EItems.KEY_OF_CHAOS: player.NoteCount++; break; case EItems.KEY_OF_COURAGE: player.NoteCount++; break; case EItems.KEY_OF_HOPE: player.NoteCount++; break; case EItems.KEY_OF_LOVE: player.NoteCount++; break; case EItems.KEY_OF_STRENGTH: player.NoteCount++; break; case EItems.KEY_OF_SYMBIOSIS: player.NoteCount++; break; default: //Some other item, just throw it in player.AdditionalItems.Add(itemToCollect); break; } }
/// <summary> /// Helped method from testing that a collection of mappings is indeed completeable. /// </summary> /// <param name="mappings">Mappings collection to test</param> /// <returns>true if seed was beatable, false otherwise.</returns> public static bool IsSeedBeatable(Dictionary <LocationRO, RandoItemRO> mappings) { //Create an player that will be used to track progress. SamplePlayerRO player = new SamplePlayerRO(false, false, false, 0, new List <RandoItemRO>()); //I'll want to start doing runs through the mappings to see if I am able to collect items. I'll keep doing this until I either get the 6 notes or I have no more checks I can do. while (player.NoteCount < 6) { //Create a copy of the mappings to mess with Dictionary <LocationRO, RandoItemRO> localMappings = new Dictionary <LocationRO, RandoItemRO>(mappings); bool collectedItemThisRound = false; //Run through locations, get any items we can foreach (LocationRO location in localMappings.Keys) { //Lets check additional items and get that over with first EItems[] additionalLocationRequiredItems = location.AdditionalRequiredItemsForCheck; if (!additionalLocationRequiredItems.Contains(EItems.NONE)) { { //There are additional items to check if (!HasAdditionalItemsForBeatableSeedCheck(additionalLocationRequiredItems, player)) { //Did not pass validations, move to next location. continue; } } } //Start the fun location checks if (location.IsWingsuitRequired) { //Wingsuit check if (!player.HasWingsuit) { continue; } } //Ropedart check if (location.IsRopeDartRequired) { if (!player.HasRopeDart) { continue; } } //Ninja Tabi check if (location.IsNinjaTabiRequired) { if (!player.HasNinjaTabis) { continue; } } //Checks that could use either rope dart or wingsuit if (location.IsEitherWingsuitOrRopeDartRequired) { if (!player.HasWingsuit && !player.HasRopeDart) { continue; } } //If we survived all of that nonsense, then we passed validations. The item is ours! CollectItemForBeatableSeedCheck(localMappings[location], ref player); collectedItemThisRound = true; mappings.Remove(location); } if (!collectedItemThisRound) { //This seed not beatable Console.WriteLine("\nSeed was deemed unbeatable."); //Print out all the items collected so far Console.WriteLine($"Note Count: {player.NoteCount}"); Console.WriteLine($"Collected Wingsuit: {player.HasWingsuit}"); Console.WriteLine($"Collected Ropedart: {player.HasRopeDart}"); Console.WriteLine($"Collected Ninja Tabis: {player.HasNinjaTabis}"); foreach (RandoItemRO additionalItem in player.AdditionalItems) { Console.WriteLine($"Additional Item Collected: {additionalItem}"); } //Print out remaining locations Console.WriteLine("\nRemaining location mappings:"); foreach (LocationRO location in mappings.Keys) { Console.WriteLine($"Location: '{location.PrettyLocationName}' | Item at location: '{mappings[location].Name}'"); } return(false); } } //We made it through the game with all 6 notes! Console.WriteLine("Mapping successfully verified. This seed is beatable."); return(true); }
private static bool HasAdditionalItemsForBeatableSeedCheck(EItems[] additionalLocationRequiredItems, SamplePlayerRO player) { bool hasAdditionalItems = true; //Check each item in the list of required items for this location foreach (EItems item in additionalLocationRequiredItems) { bool itemFound = false; //Check each item the player has foreach (RandoItemRO playerItem in player.AdditionalItems) { if (playerItem.Item.Equals(item)) { //We have this required item itemFound = true; break; } } if (!itemFound) { //We were missing at least one required item hasAdditionalItems = false; break; } } return(hasAdditionalItems); }