Skip to content

Commit

Permalink
Merge pull request #6696 from planetarium/feature/inventory-item-order
Browse files Browse the repository at this point in the history
fix inventory item order in pc shop
  • Loading branch information
eugene-doobu authored Jan 13, 2025
2 parents d550b47 + b9d3ca7 commit e8c1771
Showing 1 changed file with 76 additions and 2 deletions.
78 changes: 76 additions & 2 deletions nekoyume/Assets/_Scripts/UI/Module/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Nekoyume.Action;
using Nekoyume.Battle;
using Nekoyume.Game.Controller;
using Nekoyume.Helper;
Expand Down Expand Up @@ -807,8 +808,8 @@ public void SetAvatarInformation(
public void SetShop(Action<InventoryItem> clickItem)
{
_checkTradable = true;
SetAction(clickItem);
SetInventoryTab();
SetAction(clickItem, onClickTab: OnClickTapShop);
SetInventoryTab(onUpdateInventory: OnUpdateInventoryShop);
_toggleGroup.DisabledFunc = () => false;
}

Expand Down Expand Up @@ -1083,5 +1084,78 @@ public bool TryGetCellByIndex(int index, out InventoryCell cell)
}

#endregion

#region ShopEvents

private void OnClickTapShop(InventoryTabType tabType)
{
SortInventoryInShop(tabType);
}

private void OnUpdateInventoryShop(Inventory inventory, Nekoyume.Model.Item.Inventory nekoyumeInventory)
{
SortInventoryInShop(_activeTabType);
}

private void SortInventoryInShop(InventoryTabType tabType)
{
var data = GetModels(tabType);
if (tabType == InventoryTabType.Equipment)
{
data = data
.OrderByDescending(x => x.ItemBase is ITradableItem)
.ThenByDescending(x => x.ItemBase.Grade)
.ThenByDescending(x => CPHelper.GetCP(x.ItemBase as Equipment))
.ToList();
}

if (tabType == InventoryTabType.Consumable)
{
data = data
.OrderByDescending(x => x.ItemBase is ITradableItem)
.ThenByDescending(x => x.ItemBase.Grade)
.ToList();
}

if (tabType == InventoryTabType.Material)
{
data = data
.OrderByDescending(x => x.ItemBase is ITradableItem)
.ThenByDescending(x => x.ItemBase.Grade)
.ToList();
}

if (tabType == InventoryTabType.Costume)
{
var costumeSheet = Game.Game.instance.TableSheets.CostumeStatSheet;
data = data
.OrderByDescending(x => x.ItemBase is ITradableItem)
.ThenByDescending(x => x.ItemBase.Grade)
.ThenByDescending(x => CPHelper.GetCP(x.ItemBase as Costume, costumeSheet))
.ToList();
}

if (tabType == InventoryTabType.FungibleAsset)
{
var runeListSheet = Game.Game.instance.TableSheets.RuneListSheet;
data = data
.OrderByDescending(x => x.Tradable.Value)
.ThenByDescending(x => x.ItemBase is ITradableItem)
.ThenByDescending(x =>
{
if (!RuneFrontHelper.TryGetRuneData(x.FungibleAssetValue.Currency.Ticker, out var value))
{
return 0;
}

return runeListSheet.TryGetValue(value.id, out var row) ? row.Grade : 0;
})
.ToList();
}

scroll.UpdateData(data);
}

#endregion ShopEvents
}
}

0 comments on commit e8c1771

Please sign in to comment.