Skip to content

Commit

Permalink
Post-PR cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmedwards committed Jun 18, 2019
1 parent 4038ec2 commit c6572ce
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CoCEd/ViewModel/GameVM.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,17 @@ public void OnKeyItemAddedOrRemoved(string name, bool isOwned)
}
}

//Not sure how I can make the code better as I can't apply the same trick to chest without complicating the code further.
void UpdateInventory()
{
_inventory.Clear();
int count = IsRevamp ? 10 : 5; // max inventory slots are 5 in CoC and 10 in CoC-Revamp-Mod
if (GetObj("itemSlots") != null) //For serialized saves.
AmfObject itemSlots = IsRevamp ? GetObj("itemSlots") : null;
if (itemSlots != null) // for CoC-Revamp-Mod ≥v1.4.15
{
foreach (var pair in GetObj("itemSlots")) _inventory.Add(pair.ValueAsObject);
foreach (var pair in itemSlots) _inventory.Add(pair.ValueAsObject);
}
else //For legacy item slots used in Vanilla and Revamp 1.4.15-pre.
else // for CoC and CoC-Revamp-Mod <v1.4.15
{
int count = IsRevamp ? 10 : 5; // max inventory slots are 5 in CoC and 10 in CoC-Revamp-Mod
for (int i = 0; i < count; i++)
{
var slot = GetObj("itemSlot" + (i + 1));
Expand All @@ -246,7 +246,9 @@ void UpdateInventory()

AmfObject GetItemStorageObj()
{
var itemStorage = GetObj("itemStorage");
// The following line will return an object for CoC and CoC-Revamp-Mod <v1.4.15
// or null for CoC-Revamp-Mod ≥v1.4.15.
AmfObject itemStorage = GetObj("itemStorage");
return itemStorage != null ? itemStorage : GetObj("inventory").GetObj("itemStorage");
}

Expand Down

0 comments on commit c6572ce

Please sign in to comment.