Exemple #1
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the zone key for a location.</summary>
        /// <param name="location">The location to check.</param>
        /// <param name="range">The range within which chests should be accessible.</param>
        private string GetZone(GameLocation location, ChestRange range)
        {
            switch (range)
            {
            case ChestRange.Unlimited:
                return("*");

            case ChestRange.CurrentWorldArea:
                if (location is MineShaft mine)
                {
                    return(mine.mineLevel <= 120 ? "Mine" : "SkullCave");    // match entrance name
                }
                return(this.WorldAreaZones.TryGetValue(location, out string zone)
                        ? zone
                        : location.Name);

            case ChestRange.CurrentLocation:
                return(location.Name);

            case ChestRange.None:
                return(null);

            default:
                throw new NotSupportedException($"Unknown range '{range}'.");
            }
        }
Exemple #2
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="worldAreas">The predefined world areas for <see cref="ChestRange.CurrentWorldArea"/>.</param>
        /// <param name="range">The range within which chests should be accessible.</param>
        /// <param name="currentLocation">The player's current location.</param>
        public RangeHandler(IDictionary <string, HashSet <string> >?worldAreas, ChestRange range, GameLocation currentLocation)
        {
            this.Range = range;

            this.WorldAreaZones = new(() => this.GetWorldAreaZones(worldAreas));
            this.CurrentZone    = this.GetZone(currentLocation, range);
        }
Exemple #3
0
        /// <summary>Get the range for the current context.</summary>
        private RangeHandler GetCurrentRange()
        {
            ChestRange range = this.IsDisabledLocation(Game1.currentLocation)
                ? ChestRange.None
                : this.Config.Range;

            return(new RangeHandler(this.Data.WorldAreas, range, Game1.currentLocation));
        }
Exemple #4
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="worldAreas">The predefined world areas for <see cref="ChestRange.CurrentWorldArea"/>.</param>
        /// <param name="range">The range within which chests should be accessible.</param>
        /// <param name="currentLocation">The player's current location.</param>
        public RangeHandler(IDictionary <string, HashSet <string> > worldAreas, ChestRange range, GameLocation currentLocation)
        {
            this.Range = range;

            if (range == ChestRange.CurrentWorldArea)
            {
                this.WorldAreaZones = this.GetWorldAreaZones(worldAreas);
            }
            this.CurrentZone = this.GetZone(currentLocation, range);
        }
Exemple #5
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the zone key for a location.</summary>
        /// <param name="location">The location to check.</param>
        /// <param name="range">The range within which chests should be accessible.</param>
        private string?GetZone(GameLocation location, ChestRange range)
        {
            switch (range)
            {
            case ChestRange.Unlimited:
                return("*");

            case ChestRange.CurrentWorldArea:
                return(location switch
                {
                    MineShaft mine => mine.mineLevel <= 120 ? "Mine" : "SkullCave",
                    VolcanoDungeon => "VolcanoDungeon",
                    _ => this.WorldAreaZones.Value.TryGetValue(location, out string?zone) ? zone : location.Name
                });