Rework shop to support multiple item types and add unified PlayerModel

Generalize the shop from selling only ModifierDefinition to any IShopItem
(modifiers + dice). Add purchase condition checks, hover tooltips, and
fixed prices. Introduce PlayerModel as a facade over CurrencyBank,
InventoryModel, and DiceCollection for centralized state and save/load.

New files:
- IShopItem interface for purchasable items
- ShopCatalog SO (unified catalog for all item types)
- ShopTooltipView (description on hover)
- PlayerModel (aggregates player state)
- DiceCollection (owned dice tracking)
- DiceCatalog SO (dice definition registry)
- DiceCollectionTests

Modified:
- ModifierDefinition/DieDefinitionSO implement IShopItem
- ShopModel/ShopView/ShopItemView/ShopController use IShopItem
- SaveData v3 with OwnedDiceIds
- GameController uses PlayerModel for save/load
- GameLifetimeScope registers new services

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 21:04:34 +07:00
parent 85d639aa70
commit fcceb0ce45
18 changed files with 576 additions and 54 deletions
+6 -7
View File
@@ -1,7 +1,6 @@
using UnityEngine;
using VContainer;
using YachtDice.Economy;
using YachtDice.Modifiers.Definition;
namespace YachtDice.Shop
{
@@ -9,14 +8,14 @@ namespace YachtDice.Shop
{
[SerializeField] private ShopView shopView;
private ModifierCatalog catalog;
private ShopCatalog catalog;
private CurrencyBank currencyBank;
private ShopModel model;
public ModifierCatalog Catalog => catalog;
public ShopCatalog Catalog => catalog;
[Inject]
public void Construct(ModifierCatalog catalog, CurrencyBank currencyBank, ShopModel model)
public void Construct(ShopCatalog catalog, CurrencyBank currencyBank, ShopModel model)
{
this.catalog = catalog;
this.currencyBank = currencyBank;
@@ -55,9 +54,9 @@ namespace YachtDice.Shop
shopView.Show();
}
private void HandleBuyClicked(ModifierDefinition def)
private void HandleBuyClicked(IShopItem item)
{
model.TryPurchase(def);
model.TryPurchase(item);
}
private void HandleCurrencyChanged(int newBalance)
@@ -66,7 +65,7 @@ namespace YachtDice.Shop
shopView.RefreshStates(catalog.All, model);
}
private void HandleItemPurchased(ModifierDefinition def)
private void HandleItemPurchased(IShopItem item)
{
shopView.RefreshStates(catalog.All, model);
}