Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix inventory item order in pc shop #6696

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading