Skip to content
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
45 changes: 37 additions & 8 deletions Scenes/ShopScene/Scripts/ShopScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public partial class ShopScene : Control
private readonly int[] _priceByRarity = [100, 90, 80, 70, 60, 50, 9];
const int NoteCost = 45;

private List<RelicTemplate> _shopRelics;
private List<Note> _shopNotes;

public override void _Ready()
{
_bGroup = new ButtonGroup();
Expand Down Expand Up @@ -105,21 +108,43 @@ private void UpdateMoneyLabel()

private void GenerateShopItems()
{
var relics = Scribe.GetRandomRelics(
RelicOptions,
StageProducer.CurRoom + 10,
StageProducer.PlayerStats.RarityOdds
);
_shopRelics = Scribe
.GetRandomRelics(
RelicOptions,
StageProducer.CurRoom + 10,
StageProducer.PlayerStats.RarityOdds
)
.ToList();

var notes = Scribe.GetRandomRewardNotes(NoteOptions, StageProducer.CurRoom + 10);
_shopNotes = Scribe.GetRandomRewardNotes(NoteOptions, StageProducer.CurRoom + 10).ToList();

foreach (var relic in relics)
foreach (var relic in _shopRelics)
{
int price = _priceByRarity[(int)relic.Rarity];
AddShopItem(_relicGrid, relic, price);
}

foreach (var note in notes)
foreach (var note in _shopNotes)
{
int price = NoteCost;
AddShopItem(_noteGrid, note, price);
}
}

private void RefreshShopPrices()
{
foreach (var child in _noteGrid.GetChildren())
child.QueueFree();
foreach (var child in _relicGrid.GetChildren())
child.QueueFree();

foreach (var relic in _shopRelics)
{
int price = _priceByRarity[(int)relic.Rarity];
AddShopItem(_relicGrid, relic, price);
}

foreach (var note in _shopNotes)
{
int price = NoteCost;
AddShopItem(_noteGrid, note, price);
Expand Down Expand Up @@ -167,9 +192,11 @@ private void TryPurchase()
case Note note:
StageProducer.PlayerStats.AddNote(note);
AddNoteToPossessions(note);
_shopNotes.Remove(note);
break;
case RelicTemplate relic:
StageProducer.PlayerStats.AddRelic(relic);
_shopRelics.Remove(relic);
break;
}

Expand All @@ -182,6 +209,8 @@ private void TryPurchase()

_currentItem = null;
_currentUItem = null;

RefreshShopPrices();
}

private Control _lastFocused;
Expand Down