Skip to content

Commit e71c008

Browse files
committed
show separate flavored/base 'owned' counts for flavored items
1 parent 9943061 commit e71c008

File tree

20 files changed

+52
-7
lines changed

20 files changed

+52
-7
lines changed

LookupAnything/Framework/Lookups/Items/ItemSubject.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ select name
388388
if (showInventoryFields && !isCrop)
389389
{
390390
// owned
391-
yield return new GenericField(I18n.Item_NumberOwned(), I18n.Item_NumberOwned_Summary(count: this.GameHelper.CountOwnedItems(item)));
391+
yield return new GenericField(I18n.Item_NumberOwned(), this.GetNumberOwnedText(item));
392392

393393
// times crafted
394394
RecipeModel[] recipes = this.GameHelper
@@ -902,6 +902,28 @@ bool IsBundleOpen(int id)
902902
}
903903
}
904904

905+
/// <summary>Get a text summary of the number of an item owned by the player.</summary>
906+
/// <param name="item">The item to count in the world.</param>
907+
private string GetNumberOwnedText(Item item)
908+
{
909+
// get counts
910+
int baseCount = this.GameHelper.CountOwnedItems(item, flavorSpecific: false);
911+
int flavoredCount = item is SObject
912+
? this.GameHelper.CountOwnedItems(item, flavorSpecific: true)
913+
: baseCount;
914+
915+
// show flavored + base count
916+
if (baseCount != flavoredCount)
917+
{
918+
ParsedItemData? baseData = ItemRegistry.GetData(item.QualifiedItemId);
919+
if (baseData != null)
920+
return I18n.Item_NumberOwnedFlavored_Summary(name: item.Name, count: flavoredCount, baseName: baseData.DisplayName, baseCount: baseCount);
921+
}
922+
923+
// show flavored count only
924+
return I18n.Item_NumberOwned_Summary(count: flavoredCount);
925+
}
926+
905927
/// <summary>Get the translated name for a bundle's area.</summary>
906928
/// <param name="bundle">The bundle.</param>
907929
private string GetTranslatedBundleArea(BundleModel bundle)

LookupAnything/GameHelper.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,13 @@ public IEnumerable<NPC> GetAllCharacters()
240240

241241
/// <summary>Count how many of an item the player owns.</summary>
242242
/// <param name="item">The item to count.</param>
243-
public int CountOwnedItems(Item item)
243+
/// <param name="flavorSpecific">If the item has a preserved item, whether to only include items with the same preserved item.</param>
244+
public int CountOwnedItems(Item item, bool flavorSpecific)
244245
{
245246
return (
246247
from found in this.GetAllOwnedItems()
247248
let foundItem = found.Item
248-
where this.AreEquivalent(foundItem, item)
249+
where this.AreEquivalent(foundItem, item, flavorSpecific)
249250
let canStack = foundItem.canStackWith(foundItem)
250251
select canStack ? found.GetCount() : 1
251252
).Sum();
@@ -463,7 +464,7 @@ public IEnumerable<RecipeModel> GetRecipesForOutput(Item item)
463464
{
464465
return this
465466
.GetRecipes()
466-
.Where(recipe => this.AreEquivalent(item, recipe.TryCreateItem(item)));
467+
.Where(recipe => this.AreEquivalent(item, recipe.TryCreateItem(item), flavorSpecific: false));
467468
}
468469

469470
/// <summary>Get the recipes for a given machine.</summary>
@@ -686,13 +687,18 @@ public void ShowErrorMessage(string message)
686687
/// <summary>Get whether two items are the same type (ignoring flavor text like 'blueberry wine' vs 'cranberry wine').</summary>
687688
/// <param name="a">The first item to compare.</param>
688689
/// <param name="b">The second item to compare.</param>
689-
private bool AreEquivalent(Item? a, Item? b)
690+
/// <param name="flavorSpecific">Whether to only match items with the same preserved item.</param>
691+
private bool AreEquivalent(Item? a, Item? b, bool flavorSpecific)
690692
{
691693
return
692694
a != null
693695
&& b != null
694696
&& a.QualifiedItemId == b.QualifiedItemId
695-
&& (a as Chest)?.fridge.Value == (b as Chest)?.fridge.Value;
697+
&& (a as Chest)?.fridge.Value == (b as Chest)?.fridge.Value
698+
&& (
699+
!flavorSpecific
700+
|| (a as SObject)?.GetPreservedItemId() == (b as SObject)?.GetPreservedItemId()
701+
);
696702
}
697703

698704
/// <summary>Get all machine recipes, including those from mods like Producer Framework Mod.</summary>

LookupAnything/docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Added item links in item recipe, fish pond drop, and item drop fields (thanks to Mushmato!).
77
* Added support for Extra Machine Config mod's multiple output items (thanks to zombifier!).
88
* Added support for the upcoming Better Game Menu mod (thanks to KhloeLeclair!).
9+
* When you look up a flavored item like Sunflower Honey, the 'owned' field now also shows how many you own with the same flavor.
910
* Improved schedule data in NPC lookups:
1011
* The current position is now shown even if they have no schedule.
1112
* Added separate message when the NPC has a schedule but they're set to ignore it.

LookupAnything/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@
359359
"item.recipes-for-machine.same-as-input": "[Gleiches wie Eingabe]", // e.g. crystalarium produces same item that was put in
360360
"item.recipes-for-machine.too-complex": "Einige Maschinen-Regeln sind zu dynamisch, um sie anzuzeigen.",
361361
"item.number-owned.summary": "Du besitzt {{count}} davon",
362+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // TODO // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
362363
"item.number-crafted.summary": "Du hast bereits {{count}} davon hergestellt",
363364

364365

LookupAnything/i18n/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@
359359
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in
360360
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.",
361361
"item.number-owned.summary": "you own {{count}} of these",
362+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
362363
"item.number-crafted.summary": "you made {{count}} of these",
363364

364365

LookupAnything/i18n/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@
361361
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
362362
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
363363
"item.number-owned.summary": "{{count}} ud(s)",
364+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // TODO // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
364365
"item.number-crafted.summary": "creaste {{count}} de estos",
365366

366367

LookupAnything/i18n/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
364364
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
365365
"item.number-owned.summary": "vous en possédez {{count}}",
366+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // TODO // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
366367
"item.number-crafted.summary": "vous en avez fabriqué {{count}}",
367368

368369

LookupAnything/i18n/hu.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@
361361
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
362362
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
363363
"item.number-owned.summary": "ennyit birtokolsz ebből: {{count}}",
364+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // TODO // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
364365
"item.number-crafted.summary": "ennyit készítettél ebből: {{count}}",
365366

366367

LookupAnything/i18n/it.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@
358358
"item.recipes-for-machine.same-as-input": "[stesso oggetto]", // e.g. crystalarium produces same item that was put in
359359
"item.recipes-for-machine.too-complex": "Alcune regole della macchina sono troppo dinamiche per essere visualizzate.",
360360
"item.number-owned.summary": "Quantità posseduta: {{count}}",
361+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // TODO // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
361362
"item.number-crafted.summary": "Quantità fabbricata: {{count}}",
362363

363364

LookupAnything/i18n/ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@
360360
"item.recipes-for-machine.same-as-input": "原料と同じ", // e.g. crystalarium produces same item that was put in
361361
"item.recipes-for-machine.too-complex": "情報が多すぎるため表示することができない",
362362
"item.number-owned.summary": "{{count}}個持っている",
363+
"item.number-owned-flavored.summary": "you own {{count}} ({{name}}) or {{baseCount}} ({{baseName}}) of these", // TODO // e.g. "you own 5 (Sturgeon Roe) or 20 (Roe) of these"
363364
"item.number-crafted.summary": "{{count}}個作成した",
364365

365366

0 commit comments

Comments
 (0)