Initial Commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# PROJ001: Initial Project Setup and Logic Refactoring (Node.js Migration)
|
||||
|
||||
## Status: COMPLETED
|
||||
|
||||
### Achievements
|
||||
- **Architecture**: Pivoted from .NET to a **Node.js Monolith** structure to natively support real-time state synchronization via Socket.IO.
|
||||
- **Frontend Infrastructure**: Configured **React** 19 + **Vite** + **Tailwind CSS** (v3) in `src/client`.
|
||||
- **Backend Infrastructure**: Initialized **Express** server with **Socket.IO** in `src/server` for handling API requests and multiplayer draft state.
|
||||
- **Refactoring**: Successfully ported legacy `gemini-generated.js` logic into specialized TypeScript services:
|
||||
- `CardParserService.ts`: Regex-based list parsing.
|
||||
- `ScryfallService.ts`: Data fetching with caching.
|
||||
- `PackGeneratorService.ts`: Pack creation logic.
|
||||
- **UI Implementation**: Developed `CubeManager`, `PackCard`, and `StackView` components.
|
||||
- **Cleanup**: Removed all .NET artifacts and dependencies.
|
||||
- **Tooling**: Updated `Makefile` for unified Node.js development commands.
|
||||
|
||||
### How to Run
|
||||
- **Install**: `make install` (or `cd src && npm install`)
|
||||
- **Run Development**: `make dev` (Runs Server and Client concurrently)
|
||||
- **Build**: `make build`
|
||||
|
||||
### Manual Verification Steps
|
||||
1. **Run**: `make dev`
|
||||
2. **Access**: Open `http://localhost:5173` (Client).
|
||||
3. **Test**:
|
||||
- Click "Load Demo List" in the Cube Manager.
|
||||
- Verify cards are fetched from Scryfall.
|
||||
- Click "Generate Pools".
|
||||
- Verify packs are generated and visible in Stack/Grid views.
|
||||
|
||||
### Next Steps
|
||||
- Implement `DraftSession` state management in `src/server`.
|
||||
- Define Socket.IO events for lobby creation and player connection.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Migration to Node.js Backend
|
||||
|
||||
## Objective
|
||||
Convert the project from a .NET backend to a Node.js (TypeScript) backend and remove the .NET infrastructure.
|
||||
|
||||
## Plan
|
||||
|
||||
### Phase 1: Structure Initialization
|
||||
- [ ] Initialize `src` as a Node.js project (`package.json`, `tsconfig.json`).
|
||||
- [ ] Create directory structure:
|
||||
- [ ] `src/server`: Backend logic.
|
||||
- [ ] `src/client`: Move existing React frontend here.
|
||||
- [ ] `src/shared`: Shared interfaces/types.
|
||||
|
||||
### Phase 2: React Frontend Migration
|
||||
- [ ] Move `src/MtgDraft.Web/Client` contents to `src/client/src`.
|
||||
- [ ] Move configuration files (`vite.config.ts`, `tailwind.config.js`, etc.) to `src/client` root or adjust as needed.
|
||||
- [ ] Ensure frontend builds and runs via Vite (dev server).
|
||||
|
||||
### Phase 3: Node.js Backend Implementation
|
||||
- [ ] Set up Express/Fastify server in `src/server/index.ts`.
|
||||
- [ ] Configure Socket.IO foundations.
|
||||
- [ ] Configure build scripts to build client and server.
|
||||
|
||||
### Phase 4: Verification
|
||||
- [ ] Verify application runs with `npm run dev`.
|
||||
|
||||
### Phase 5: Cleanup
|
||||
- [ ] Delete `MtgDraft.*` folders.
|
||||
@@ -0,0 +1,30 @@
|
||||
# Implementation of Core Functionalities
|
||||
|
||||
## Status
|
||||
Completed
|
||||
|
||||
## Description
|
||||
Implemented the core functionalities based on the reference `gemini-generated.js` file, refactoring the monolithic logic into a modular architecture.
|
||||
|
||||
## Changes
|
||||
1. **Services**:
|
||||
- Created `CardParserService` for parsing bulk text lists.
|
||||
- Created `ScryfallService` for fetching card data with caching and batching.
|
||||
- Created `PackGeneratorService` for generating booster packs with various rules (Peasant, Standard, Chaos).
|
||||
|
||||
2. **Modules**:
|
||||
- **CubeManager**: Implemented the Draft Preparation Phase UI (Input, Filters, Generation).
|
||||
- **TournamentManager**: Implemented the Tournament Bracket generation logic and UI.
|
||||
|
||||
3. **Components**:
|
||||
- `PackCard`: card component with List, Grid, and Stack views.
|
||||
- `StackView`: 3D card stack visualization.
|
||||
- `TournamentPackView`: "Blind Mode" / Box view for generated packs.
|
||||
|
||||
4. **Architecture**:
|
||||
- Created `App.tsx` as the main shell with Tab navigation (Draft vs Bracket).
|
||||
- Integrated all components into the main entry point.
|
||||
|
||||
## Next Steps
|
||||
- Integrate Socket.IO for real-time draft synchronization (Multiplayer).
|
||||
- Implement the "Live Draft" interface.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Bug Fix: React Render Error and Pack Generation Stability
|
||||
|
||||
## Issue
|
||||
User reported "root.render(" error visible on page and "Generate Packs" button ineffective.
|
||||
|
||||
## Diagnosis
|
||||
1. **main.tsx**: Found nested `root.render( <StrictMode> root.render(...) )` call. This caused runtime errors and visible artifact text.
|
||||
2. **CubeManager.tsx**: Service classes (`ScryfallService`, `PackGeneratorService`) were instantiated inside the functional component body without `useMemo`. This caused recreation on every render, leading to cache loss (`ScryfallService` internal cache) and potential state inconsistencies.
|
||||
3. **Pack Generation**: Double-clicking or rapid state updates caused "phantom" generation runs with empty pools, resetting the packs list to 0 immediately after success.
|
||||
|
||||
## Resolution
|
||||
1. **Fixed main.tsx**: Removed the nested `root.render` call.
|
||||
2. **Refactored CubeManager.tsx**:
|
||||
* Memoized all services using `useMemo`.
|
||||
* Added `loading` state to `generatePacks` to prevent double-submissions.
|
||||
* Wrapped generation logic in `setTimeout` to allow UI updates and `try/catch` for robustness.
|
||||
|
||||
## Status
|
||||
Verified via browser subagent (logs confirmed 241 packs generated). UI now prevents race conditions.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Bug Fix: Card Parser Robustness
|
||||
|
||||
## User Request
|
||||
"The problem is that if the scryfall id is missing, no card is retrieved so no card is generated, instead the system should be able to retrieve cards and generate packs even without scryfall id"
|
||||
|
||||
## Diagnosis
|
||||
The `CardParserService` currently performs basic name extraction. It fails to strip set codes and collector numbers common in export formats (e.g., MTG Arena exports like `1 Shock (M20) 160`).
|
||||
This causes `ScryfallService` to search for "Shock (M20) 160" as an exact name, which fails. The system relies on successful Scryfall matches to populate the card pool; without matches, the pool is empty, and generation produces 0 packs.
|
||||
|
||||
## Implementation Plan
|
||||
1. **Refactor `CardParserService.ts`**:
|
||||
* Enhance regex to explicitly handle and strip:
|
||||
* Parentheses containing text (e.g., `(M20)`).
|
||||
* Collector numbers at the end of lines.
|
||||
* Set codes in square brackets if present.
|
||||
* Maintain support for `Quantity Name` format.
|
||||
* Ensure exact name cleanup to maximize Scryfall "exact match" hits.
|
||||
|
||||
2. **Verification**:
|
||||
* Create a test input imitating Arena export.
|
||||
* Verify via browser subagent that cards are fetched and packs are generated.
|
||||
|
||||
## Update Central
|
||||
Update `CENTRAL.md` with this task.
|
||||
Reference in New Issue
Block a user