fix: expansion pack generation limit by adding a withReplacement setting and enabling it for set-based drafts.

This commit is contained in:
2025-12-17 01:45:27 +01:00
parent ca2efb5cd7
commit 97276979bf
5 changed files with 84 additions and 11 deletions

View File

@@ -63,3 +63,4 @@
- [Explicit Preview Suppression](./devlog/2025-12-17-025500_explicit_preview_suppression.md): Completed. Implemented strict `preventPreview` prop to enforce suppression logic reliably regardless of card overlap or DOM state.
- [Synchronized Display Boundaries](./devlog/2025-12-17-030000_synchronized_boundaries.md): Completed. Aligned "Art Crop" and "Preview Suppression" thresholds to 200px (50% slider value) for a unified UI behavior.
- [Squared Art Crops](./devlog/2025-12-17-030500_squared_art_crops.md): Completed. Enforced square aspect ratio for art-crop thumbnails to optimize visual density and stacking.
- [Fix Expansion Generation Limit](./devlog/2025-12-17-024500_fix_expansion_generation_limit.md): Completed. Implemented "Unlimited Pool" mode for expansion drafts to allow generating large numbers of packs from singleton set data.

View File

@@ -0,0 +1,22 @@
# Bug Fix: Pack Generation Limits in From Expansion Mode
## Issue
The user reported that when generating "1 Box" (36 packs) in "From Expansion" mode, only about 10 packs were generated.
This was caused by the pack generation algorithm treating the card pool as finite (consuming cards as they are picked). Since Scryfall data usually provides a singleton list (1 copy of each card), the pool of Commons would deplete rapidly (e.g., 10 packs * 10 commons = 100 commons), halting generation when unique commons ran out.
## Solution
Implemented a "Unlimited Pool" / "With Replacement" mode for pack generation.
- **Server (`PackGeneratorService.ts`)**: Added `withReplacement` flag to `PackGenerationSettings`.
- When enabled, the generator creates a FRESH copy of the shuffled pool for EACH pack.
- This simulates a "Retail Draft" or "Print Run" scenario where packs are independent samples from a large supply, rather than drawing from a fixed, finite Cube.
- Uniqueness is still enforced WITHIN each pack (no duplicate cards in the same pack).
- **Client (`CubeManager.tsx`)**: updated the payload to strictly enable `withReplacement: true` whenever `sourceMode` is set to "From Expansion" ("set").
## Files Modified
- `src/server/services/PackGeneratorService.ts`: Implemented replacement logic.
- `src/client/src/modules/cube/CubeManager.tsx`: Updated API call payload.
- `src/client/src/services/PackGeneratorService.ts`: Updated interface definitions.
## Status
- [x] Fix Implemented
- [x] Verified Logic