@@ -55,6 +55,9 @@ public partial class ShopScene : Control
5555 private readonly int [ ] _priceByRarity = [ 100 , 90 , 80 , 70 , 60 , 50 , 9 ] ;
5656 const int NoteCost = 45 ;
5757
58+ private List < RelicTemplate > _shopRelics ;
59+ private List < Note > _shopNotes ;
60+
5861 public override void _Ready ( )
5962 {
6063 _bGroup = new ButtonGroup ( ) ;
@@ -105,21 +108,43 @@ private void UpdateMoneyLabel()
105108
106109 private void GenerateShopItems ( )
107110 {
108- var relics = Scribe . GetRandomRelics (
109- RelicOptions ,
110- StageProducer . CurRoom + 10 ,
111- StageProducer . PlayerStats . RarityOdds
112- ) ;
111+ _shopRelics = Scribe
112+ . GetRandomRelics (
113+ RelicOptions ,
114+ StageProducer . CurRoom + 10 ,
115+ StageProducer . PlayerStats . RarityOdds
116+ )
117+ . ToList ( ) ;
113118
114- var notes = Scribe . GetRandomRewardNotes ( NoteOptions , StageProducer . CurRoom + 10 ) ;
119+ _shopNotes = Scribe . GetRandomRewardNotes ( NoteOptions , StageProducer . CurRoom + 10 ) . ToList ( ) ;
115120
116- foreach ( var relic in relics )
121+ foreach ( var relic in _shopRelics )
117122 {
118123 int price = _priceByRarity [ ( int ) relic . Rarity ] ;
119124 AddShopItem ( _relicGrid , relic , price ) ;
120125 }
121126
122- foreach ( var note in notes )
127+ foreach ( var note in _shopNotes )
128+ {
129+ int price = NoteCost ;
130+ AddShopItem ( _noteGrid , note , price ) ;
131+ }
132+ }
133+
134+ private void RefreshShopPrices ( )
135+ {
136+ foreach ( var child in _noteGrid . GetChildren ( ) )
137+ child . QueueFree ( ) ;
138+ foreach ( var child in _relicGrid . GetChildren ( ) )
139+ child . QueueFree ( ) ;
140+
141+ foreach ( var relic in _shopRelics )
142+ {
143+ int price = _priceByRarity [ ( int ) relic . Rarity ] ;
144+ AddShopItem ( _relicGrid , relic , price ) ;
145+ }
146+
147+ foreach ( var note in _shopNotes )
123148 {
124149 int price = NoteCost ;
125150 AddShopItem ( _noteGrid , note , price ) ;
@@ -167,9 +192,11 @@ private void TryPurchase()
167192 case Note note :
168193 StageProducer . PlayerStats . AddNote ( note ) ;
169194 AddNoteToPossessions ( note ) ;
195+ _shopNotes . Remove ( note ) ;
170196 break ;
171197 case RelicTemplate relic :
172198 StageProducer . PlayerStats . AddRelic ( relic ) ;
199+ _shopRelics . Remove ( relic ) ;
173200 break ;
174201 }
175202
@@ -182,6 +209,8 @@ private void TryPurchase()
182209
183210 _currentItem = null ;
184211 _currentUItem = null ;
212+
213+ RefreshShopPrices ( ) ;
185214 }
186215
187216 private Control _lastFocused ;
0 commit comments