Change comparisons relying on string.ToLower() to use StringComparison.OrdinalIgnoreCase.
parent
541fd42133
commit
4b2e31fadc
|
@ -12,7 +12,7 @@ namespace stardew_access.Features
|
||||||
|
|
||||||
public StaticTiles()
|
public StaticTiles()
|
||||||
{
|
{
|
||||||
if (MainClass.ModHelper == null)
|
if (MainClass.ModHelper is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -72,9 +72,9 @@ namespace stardew_access.Features
|
||||||
bool isLoaded = MainClass.ModHelper.ModRegistry.IsLoaded(uniqueModID);
|
bool isLoaded = MainClass.ModHelper.ModRegistry.IsLoaded(uniqueModID);
|
||||||
|
|
||||||
if (!isLoaded) continue; // Skip if the specified mod is not loaded
|
if (!isLoaded) continue; // Skip if the specified mod is not loaded
|
||||||
if (locationName.ToLower().Equals(locationNameInJson.ToLower())) return true;
|
if (locationName.Equals(locationNameInJson, StringComparison.OrdinalIgnoreCase)) return true;
|
||||||
}
|
}
|
||||||
else if (locationName.ToLower().Equals(location.Key.ToLower()))
|
else if (locationName.Equals(location.Key, StringComparison.OrdinalIgnoreCase))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,16 +82,12 @@ namespace stardew_access.Features
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? getStaticTileInfoAt(int x, int y)
|
public (string? name, CATEGORY category) GetTileFromSet(int x, int y, GameLocation currentLocation, HashSet<KeyValuePair<string, JToken?>> data)
|
||||||
{
|
{
|
||||||
return getStaticTileInfoAtWithCategory(x, y).name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public (string? name, CATEGORY category) GetTileFromSet(int x, int y, HashSet<KeyValuePair<string, JToken>> data) {
|
|
||||||
foreach (KeyValuePair<string, JToken?> location in data)
|
foreach (KeyValuePair<string, JToken?> location in data)
|
||||||
{
|
{
|
||||||
string locationName = location.Key;
|
string locationName = location.Key;
|
||||||
if (locationName.Contains("||") && MainClass.ModHelper != null)
|
if (locationName.Contains("||") && MainClass.ModHelper is not null)
|
||||||
{
|
{
|
||||||
// Mod Specific Tiles
|
// Mod Specific Tiles
|
||||||
// We can add tiles that only get detected when the specified mod is loaded.
|
// We can add tiles that only get detected when the specified mod is loaded.
|
||||||
|
@ -119,34 +115,34 @@ namespace stardew_access.Features
|
||||||
if (!isLoaded) continue; // Skip if the specified mod is not loaded
|
if (!isLoaded) continue; // Skip if the specified mod is not loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locationName.Contains("_") && locationName.ToLower().StartsWith("farm_"))
|
if (locationName.StartsWith("farm_", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
string farmType = locationName.Substring(locationName.LastIndexOf("_") + 1);
|
string farmType = locationName.Substring(locationName.LastIndexOf("_") + 1);
|
||||||
int farmTypeIndex = getFarmTypeIndex(farmType);
|
int farmTypeIndex = getFarmTypeIndex(farmType);
|
||||||
locationName = locationName.Remove(locationName.LastIndexOf("_"));
|
locationName = locationName.Remove(locationName.LastIndexOf("_"));
|
||||||
|
|
||||||
if (farmTypeIndex != Game1.whichFarm) continue; // Skip if current farm type does not matches
|
if (farmTypeIndex != Game1.whichFarm) continue; // Skip if current farm type does not matches
|
||||||
// if (Game1.whichModFarm != null) MainClass.DebugLog($"{farmType} {Game1.whichModFarm.MapName}");
|
// if (Game1.whichModFarm is not null) MainClass.DebugLog($"{farmType} {Game1.whichModFarm.MapName}");
|
||||||
if (farmTypeIndex != 7 || Game1.whichModFarm == null || !farmType.ToLower().Equals(Game1.whichModFarm.MapName.ToLower())) continue; // Not tested but should work
|
if (farmTypeIndex != 7 || Game1.whichModFarm is null || !farmType.Equals(Game1.whichModFarm.MapName, StringComparison.OrdinalIgnoreCase)) continue; // Not tested but should work
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locationName.ToLower().Equals("town_joja") && Game1.MasterPlayer.mailReceived.Contains("JojaMember"))
|
if (locationName.Equals("town_joja", StringComparison.OrdinalIgnoreCase) && Game1.MasterPlayer.mailReceived.Contains("JojaMember"))
|
||||||
{
|
{
|
||||||
locationName = "town";
|
locationName = "town";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Game1.currentLocation.Name.ToLower().Equals(locationName.ToLower())) continue;
|
if (!currentLocation.Name.Equals(locationName, StringComparison.OrdinalIgnoreCase)) continue;
|
||||||
if (location.Value == null) continue;
|
if (location.Value is null) continue;
|
||||||
|
|
||||||
foreach (var tile in ((JObject)location.Value))
|
foreach (var tile in ((JObject)location.Value))
|
||||||
{
|
{
|
||||||
if (tile.Value == null) continue;
|
if (tile.Value is null) continue;
|
||||||
|
|
||||||
JToken? tileXArray = tile.Value["x"];
|
JToken? tileXArray = tile.Value["x"];
|
||||||
JToken? tileYArray = tile.Value["y"];
|
JToken? tileYArray = tile.Value["y"];
|
||||||
JToken? tileType = tile.Value["type"];
|
JToken? tileType = tile.Value["type"];
|
||||||
|
|
||||||
if (tileXArray == null || tileYArray == null || tileType == null)
|
if (tileXArray is null || tileYArray is null || tileType is null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool isXPresent = false;
|
bool isXPresent = false;
|
||||||
|
@ -192,9 +188,16 @@ namespace stardew_access.Features
|
||||||
return (null, CATEGORY.Others);
|
return (null, CATEGORY.Others);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (string? name, CATEGORY category) getStaticTileInfoAtWithCategory(int x, int y) {
|
public string? getStaticTileInfoAt(int x, int y)
|
||||||
if (customTilesDataSet != null) return GetTileFromSet(x, y, customTilesDataSet);
|
{
|
||||||
if (staticTilesDataSet != null) return GetTileFromSet(x, y, staticTilesDataSet);
|
return getStaticTileInfoAtWithCategory(x, y).name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string? name, CATEGORY category) getStaticTileInfoAtWithCategory(int x, int y)
|
||||||
|
{
|
||||||
|
GameLocation currentLocation = Game1.currentLocation;
|
||||||
|
if (customTilesDataSet is not null) return GetTileFromSet(x, y, currentLocation, customTilesDataSet);
|
||||||
|
if (staticTilesDataSet is not null) return GetTileFromSet(x, y, currentLocation, staticTilesDataSet);
|
||||||
|
|
||||||
return (null, CATEGORY.Others);
|
return (null, CATEGORY.Others);
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,67 +547,67 @@ namespace stardew_access.Features
|
||||||
return (CATEGORY.Interactables, "Island Trader");
|
return (CATEGORY.Interactables, "Island Trader");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Game1.currentLocation.Name.ToLower().Equals("coop"))
|
else if (Game1.currentLocation.Name.Equals("coop", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (x >= 6 && x <= 9 && y == 3)
|
if (x >= 6 && x <= 9 && y == 3)
|
||||||
{
|
{
|
||||||
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
||||||
if (bench.name != null && bench.name.ToLower().Contains("hay"))
|
if (bench.name is not null && bench.name.Contains("hay", StringComparison.OrdinalIgnoreCase))
|
||||||
return (CATEGORY.Others, "Feeding Bench");
|
return (CATEGORY.Others, "Feeding Bench");
|
||||||
else
|
else
|
||||||
return (CATEGORY.Others, "Empty Feeding Bench");
|
return (CATEGORY.Others, "Empty Feeding Bench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Game1.currentLocation.Name.ToLower().Equals("big coop") || Game1.currentLocation.Name.ToLower().Equals("coop2"))
|
else if (Game1.currentLocation.Name.Equals("coop2", StringComparison.OrdinalIgnoreCase) || Game1.currentLocation.Name.Equals("big coop", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (x >= 6 && x <= 13 && y == 3)
|
if (x >= 6 && x <= 13 && y == 3)
|
||||||
{
|
{
|
||||||
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
||||||
if (bench.name != null && bench.name.ToLower().Contains("hay"))
|
if (bench.name is not null && bench.name.Contains("hay", StringComparison.OrdinalIgnoreCase))
|
||||||
return (CATEGORY.Others, "Feeding Bench");
|
return (CATEGORY.Others, "Feeding Bench");
|
||||||
else
|
else
|
||||||
return (CATEGORY.Others, "Empty Feeding Bench");
|
return (CATEGORY.Others, "Empty Feeding Bench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Game1.currentLocation.Name.ToLower().Equals("deluxe coop") || Game1.currentLocation.Name.ToLower().Equals("coop3"))
|
else if (Game1.currentLocation.Name.Equals("coop3", StringComparison.OrdinalIgnoreCase) || Game1.currentLocation.Name.Equals("deluxe coop", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (x >= 6 && x <= 17 && y == 3)
|
if (x >= 6 && x <= 17 && y == 3)
|
||||||
{
|
{
|
||||||
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
||||||
if (bench.name != null && bench.name.ToLower().Contains("hay"))
|
if (bench.name is not null && bench.name.Contains("hay", StringComparison.OrdinalIgnoreCase))
|
||||||
return (CATEGORY.Others, "Feeding Bench");
|
return (CATEGORY.Others, "Feeding Bench");
|
||||||
else
|
else
|
||||||
return (CATEGORY.Others, "Empty Feeding Bench");
|
return (CATEGORY.Others, "Empty Feeding Bench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Game1.currentLocation.Name.ToLower().Equals("barn"))
|
else if (Game1.currentLocation.Name.Equals("barn", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (x >= 8 && x <= 11 && y == 3)
|
if (x >= 8 && x <= 11 && y == 3)
|
||||||
{
|
{
|
||||||
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
||||||
if (bench.name != null && bench.name.ToLower().Contains("hay"))
|
if (bench.name != null && bench.name.Contains("hay", StringComparison.OrdinalIgnoreCase))
|
||||||
return (CATEGORY.Others, "Feeding Bench");
|
return (CATEGORY.Others, "Feeding Bench");
|
||||||
else
|
else
|
||||||
return (CATEGORY.Others, "Empty Feeding Bench");
|
return (CATEGORY.Others, "Empty Feeding Bench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Game1.currentLocation.Name.ToLower().Equals("big barn") || Game1.currentLocation.Name.ToLower().Equals("barn2"))
|
else if (Game1.currentLocation.Name.Equals("barn2", StringComparison.OrdinalIgnoreCase) || Game1.currentLocation.Name.Equals("big barn", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (x >= 8 && x <= 15 && y == 3)
|
if (x >= 8 && x <= 15 && y == 3)
|
||||||
{
|
{
|
||||||
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
||||||
if (bench.name != null && bench.name.ToLower().Contains("hay"))
|
if (bench.name is not null && bench.name.Contains("hay", StringComparison.OrdinalIgnoreCase))
|
||||||
return (CATEGORY.Others, "Feeding Bench");
|
return (CATEGORY.Others, "Feeding Bench");
|
||||||
else
|
else
|
||||||
return (CATEGORY.Others, "Empty Feeding Bench");
|
return (CATEGORY.Others, "Empty Feeding Bench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Game1.currentLocation.Name.ToLower().Equals("deluxe barn") || Game1.currentLocation.Name.ToLower().Equals("barn3"))
|
else if (Game1.currentLocation.Name.Equals("barn3", StringComparison.OrdinalIgnoreCase) || Game1.currentLocation.Name.Equals("deluxe barn", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (x >= 8 && x <= 19 && y == 3)
|
if (x >= 8 && x <= 19 && y == 3)
|
||||||
{
|
{
|
||||||
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
(string? name, CATEGORY category) bench = getObjectAtTile(x, y, true);
|
||||||
if (bench.name != null && bench.name.ToLower().Contains("hay"))
|
if (bench.name is not null && bench.name.Contains("hay", StringComparison.OrdinalIgnoreCase))
|
||||||
return (CATEGORY.Others, "Feeding Bench");
|
return (CATEGORY.Others, "Feeding Bench");
|
||||||
else
|
else
|
||||||
return (CATEGORY.Others, "Empty Feeding Bench");
|
return (CATEGORY.Others, "Empty Feeding Bench");
|
||||||
|
@ -917,11 +917,11 @@ namespace stardew_access.Features
|
||||||
}
|
}
|
||||||
else if (obj.IsSprinkler() && obj.heldObject.Value != null) // Detect the upgrade attached to the sprinkler
|
else if (obj.IsSprinkler() && obj.heldObject.Value != null) // Detect the upgrade attached to the sprinkler
|
||||||
{
|
{
|
||||||
if (MainClass.ModHelper != null && obj.heldObject.Value.Name.ToLower().Contains("pressure nozzle"))
|
if (MainClass.ModHelper is not null && obj.heldObject.Value.Name.Contains("pressure nozzle", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
toReturn.name = MainClass.ModHelper.Translation.Get("readtile.sprinkler.pressurenozzle", new { value = toReturn.name });
|
toReturn.name = MainClass.ModHelper.Translation.Get("readtile.sprinkler.pressurenozzle", new { value = toReturn.name });
|
||||||
}
|
}
|
||||||
else if (MainClass.ModHelper != null && obj.heldObject.Value.Name.ToLower().Contains("enricher"))
|
else if (MainClass.ModHelper is not null && obj.heldObject.Value.Name.Contains("enricher", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
toReturn.name = MainClass.ModHelper.Translation.Get("readtile.sprinkler.enricher", new { value = toReturn.name });
|
toReturn.name = MainClass.ModHelper.Translation.Get("readtile.sprinkler.enricher", new { value = toReturn.name });
|
||||||
}
|
}
|
||||||
|
@ -930,11 +930,11 @@ namespace stardew_access.Features
|
||||||
toReturn.name = $"{obj.heldObject.Value.DisplayName} {toReturn.name}";
|
toReturn.name = $"{obj.heldObject.Value.DisplayName} {toReturn.name}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((obj.Type == "Crafting" && obj.bigCraftable.Value) || obj.Name.ToLower().Equals("crab pot"))
|
else if ((obj.Type == "Crafting" && obj.bigCraftable.Value) || obj.Name.Equals("crab pot", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
foreach (string machine in trackable_machines)
|
foreach (string machine in trackable_machines)
|
||||||
{
|
{
|
||||||
if (obj.Name.ToLower().Contains(machine))
|
if (obj.Name.Contains(machine, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
toReturn.name = obj.DisplayName;
|
toReturn.name = obj.DisplayName;
|
||||||
toReturn.category = CATEGORY.Machines;
|
toReturn.category = CATEGORY.Machines;
|
||||||
|
@ -943,15 +943,15 @@ namespace stardew_access.Features
|
||||||
}
|
}
|
||||||
else if (correctNameAndCategory.name != null)
|
else if (correctNameAndCategory.name != null)
|
||||||
toReturn = correctNameAndCategory;
|
toReturn = correctNameAndCategory;
|
||||||
else if (obj.name.ToLower().Equals("stone"))
|
else if (obj.name.Equals("stone", StringComparison.OrdinalIgnoreCase))
|
||||||
toReturn.category = CATEGORY.Debris;
|
toReturn.category = CATEGORY.Debris;
|
||||||
else if (obj.name.ToLower().Equals("twig"))
|
else if (obj.name.Equals("twig", StringComparison.OrdinalIgnoreCase))
|
||||||
toReturn.category = CATEGORY.Debris;
|
toReturn.category = CATEGORY.Debris;
|
||||||
else if (obj.name.ToLower().Contains("quartz"))
|
else if (obj.name.Contains("quartz", StringComparison.OrdinalIgnoreCase))
|
||||||
toReturn.category = CATEGORY.MineItems;
|
toReturn.category = CATEGORY.MineItems;
|
||||||
else if (obj.name.ToLower().Contains("earth crystal"))
|
else if (obj.name.Contains("earth crystal", StringComparison.OrdinalIgnoreCase))
|
||||||
toReturn.category = CATEGORY.MineItems;
|
toReturn.category = CATEGORY.MineItems;
|
||||||
else if (obj.name.ToLower().Contains("frozen tear"))
|
else if (obj.name.Contains("frozen tear", StringComparison.OrdinalIgnoreCase))
|
||||||
toReturn.category = CATEGORY.MineItems;
|
toReturn.category = CATEGORY.MineItems;
|
||||||
|
|
||||||
if (toReturn.category == CATEGORY.Machines) // Fix for `Harvestable table` and `Busy nodes`
|
if (toReturn.category == CATEGORY.Machines) // Fix for `Harvestable table` and `Busy nodes`
|
||||||
|
@ -1030,7 +1030,7 @@ namespace stardew_access.Features
|
||||||
return ("Item box", CATEGORY.MineItems);
|
return ("Item box", CATEGORY.MineItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objName.ToLower().Contains("stone"))
|
if (objName.Contains("stone", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue