@@ -235,6 +235,11 @@ protected IEnumerator CleanUpCards()
235235
236236 protected IEnumerator SpawnAndPlaceCards ( List < CardInfo > cards , int numRows , int pageIndex , bool isDeckReview = false , bool forPositiveEffect = true )
237237 {
238+ if ( numRows < 1 ) {
239+ PatchPlugin . Logger . LogDebug ( $ "NumRows for PixelPlayableCardArray is 0, displaying no cards") ;
240+ yield break ;
241+ }
242+
238243 SetOverlayEnabled ( true ) ;
239244 SetBoardEnabled ( false ) ;
240245 displayedCards . ForEach ( delegate ( PixelPlayableCard x )
@@ -244,11 +249,6 @@ protected IEnumerator SpawnAndPlaceCards(List<CardInfo> cards, int numRows, int
244249 } ) ;
245250 displayedCards . Clear ( ) ;
246251
247- if ( numRows < 1 )
248- {
249- PatchPlugin . Logger . LogDebug ( $ "NumRows for PixelPlayableCardArray is 0, displaying no cards") ;
250- yield break ;
251- }
252252 // can only show 42 cards per page
253253 int maxPerPage = maxRows * maxCardsPerRow ;
254254 int startingIndex = maxPerPage * pageIndex ;
@@ -296,18 +296,17 @@ private void InitializeGamepadGrid()
296296 private PixelPlayableCard CreateAndPlaceCard ( CardInfo info , Vector3 cardPos )
297297 {
298298 PixelPlayableCard component = Instantiate ( gameObjectReference , base . transform ) ;
299+ component . transform . position = Vector3 . zeroVector ;
300+ component . SetInfo ( info ) ;
301+ component . SetFaceDown ( false , true ) ;
302+ component . SetEnabled ( enabled : false ) ;
299303
300304 PixelCardAnimationController controller = component . Anim as PixelCardAnimationController ;
301305 controller . cardRenderer . sortingGroupID = gameObjectReference . Anim . cardRenderer . sortingGroupID ;
302306 controller . cardbackRenderer . sortingGroupID = gameObjectReference . Anim . cardRenderer . sortingGroupID ;
303307 controller . cardRenderer . sortingOrder = - 9000 ;
304308 controller . cardbackRenderer . sortingOrder = - 8000 ;
305309
306- component . SetFaceDown ( false , true ) ;
307- component . SetInfo ( info ) ;
308- component . SetEnabled ( enabled : false ) ;
309- component . transform . position = Vector3 . zeroVector ;
310-
311310 gamepadGrid . Rows [ 0 ] . interactables . Add ( component ) ;
312311 displayedCards . Add ( component ) ;
313312 TweenInCard ( component . transform , cardPos ) ;
@@ -338,7 +337,15 @@ private void SetOverlayEnabled(bool enabled)
338337 }
339338 }
340339
341- private int GetNumRows ( int numCards ) => Mathf . Min ( maxRows , numCards / maxCardsPerRow ) ;
340+ private int GetNumRows ( int numCards ) {
341+ if ( numCards == 0 )
342+ return 0 ;
343+
344+ if ( numCards < maxCardsPerRow )
345+ return 1 ;
346+
347+ return Mathf . Min ( maxRows , numCards / maxCardsPerRow ) ;
348+ }
342349 private void SetCardsEnabled ( bool enabled ) => displayedCards . ForEach ( x => x . SetEnabled ( enabled ) ) ;
343350 private void SetBoardEnabled ( bool enabled )
344351 {
0 commit comments