mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 19:28:25 +00:00
docs: update chess implementation status
- Mark ChessViewModel, navigation, relay subscriptions as complete - Update file structure to reflect KMP commons migration - Update checklist with completed items - Revise next steps to focus on FAB and badge display Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
de2ebb2f7b
commit
c2f035acc0
@@ -45,7 +45,22 @@
|
|||||||
- PGN generation
|
- PGN generation
|
||||||
- Position mismatch recovery
|
- Position mismatch recovery
|
||||||
|
|
||||||
### 5. Feed Integration
|
### 5. ChessViewModel (amethyst/ui/screen/loggedIn/chess/)
|
||||||
|
- **ChessViewModel.kt**: Full game state management & event publishing
|
||||||
|
- `activeGames: StateFlow<Map<String, LiveChessGameState>>` - Active games by ID
|
||||||
|
- `challenges: StateFlow<List<Note>>` - Incoming/outgoing challenges
|
||||||
|
- `badgeCount: StateFlow<Int>` - Notification count
|
||||||
|
- `createChallenge()` - Create open or directed challenges
|
||||||
|
- `acceptChallenge()` - Accept challenge and start game
|
||||||
|
- `publishMove()` - Send moves to relays
|
||||||
|
- `resign()` / `offerDraw()` - End game actions
|
||||||
|
- **Relay subscriptions** via `LocalCache.live.newEventBundles`
|
||||||
|
- Auto-handles incoming moves, acceptances, endings, challenges
|
||||||
|
|
||||||
|
- **ChessViewModelFactory.kt**: ViewModel factory with Account injection
|
||||||
|
- **ChessGameScreen.kt**: Wrapper connecting ViewModel to LiveChessGameScreen UI
|
||||||
|
|
||||||
|
### 6. Feed Integration
|
||||||
**Chess Feed Filter** (TopNavFilterState.kt:130-142):
|
**Chess Feed Filter** (TopNavFilterState.kt:130-142):
|
||||||
- Shows Kind 64 (completed games)
|
- Shows Kind 64 (completed games)
|
||||||
- Shows Kind 30064 (challenges - open & directed)
|
- Shows Kind 30064 (challenges - open & directed)
|
||||||
@@ -62,57 +77,7 @@
|
|||||||
|
|
||||||
## 🚧 Remaining Work
|
## 🚧 Remaining Work
|
||||||
|
|
||||||
### Priority 1: Navigation & Game Flow
|
### Priority 1: FAB & Challenge Creation
|
||||||
**Files to create:**
|
|
||||||
1. **ChessViewModel.kt** (amethyst/ui/screen/loggedIn/chess/)
|
|
||||||
```kotlin
|
|
||||||
class ChessViewModel(account: Account) {
|
|
||||||
val activeGames: StateFlow<List<LiveChessGameState>>
|
|
||||||
val challenges: StateFlow<List<LiveChessGameChallengeEvent>>
|
|
||||||
val badgeCount: StateFlow<Int> // For in-app notifications
|
|
||||||
|
|
||||||
fun createChallenge(opponentPubkey: String?, color: Color)
|
|
||||||
fun acceptChallenge(challengeEventId: String)
|
|
||||||
fun publishMove(gameId: String, move: ChessMoveEvent)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Navigation Routes** (ui/navigation/routes/)
|
|
||||||
- Add `LiveChessGame(gameId: String)` route
|
|
||||||
- Wire up from challenge card click
|
|
||||||
- Pass LiveChessGameState to screen
|
|
||||||
|
|
||||||
3. **ChessGameScreen.kt** (amethyst/ui/screen/loggedIn/chess/)
|
|
||||||
- Wrapper around `LiveChessGameScreen` composable
|
|
||||||
- Connects ViewModel to UI
|
|
||||||
- Handles move publishing callback
|
|
||||||
|
|
||||||
### Priority 2: Event Publishing & Subscriptions
|
|
||||||
**Files to modify:**
|
|
||||||
1. **ChessViewModel.kt** - Add relay operations:
|
|
||||||
```kotlin
|
|
||||||
// Subscribe to game events
|
|
||||||
fun subscribeToGame(gameId: String) {
|
|
||||||
// Listen for Kind 30066 (moves) with d tag = gameId
|
|
||||||
// Listen for Kind 30067 (game end) with d tag = gameId
|
|
||||||
}
|
|
||||||
|
|
||||||
// Publish events
|
|
||||||
suspend fun publishChallenge(challenge: ChessGameChallenge) {
|
|
||||||
val event = LiveChessGameChallengeEvent.build(...)
|
|
||||||
account.sendEvent(event)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Event Handlers** - Process incoming events:
|
|
||||||
```kotlin
|
|
||||||
fun handleOpponentMove(moveEvent: LiveChessMoveEvent) {
|
|
||||||
val game = activeGames.find { it.gameId == moveEvent.gameId() }
|
|
||||||
game?.applyOpponentMove(moveEvent.san(), moveEvent.fen())
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Priority 3: FAB & Challenge Creation
|
|
||||||
**Files to modify:**
|
**Files to modify:**
|
||||||
1. **HomeScreen.kt** or chess-specific screen
|
1. **HomeScreen.kt** or chess-specific screen
|
||||||
```kotlin
|
```kotlin
|
||||||
@@ -169,25 +134,25 @@
|
|||||||
|
|
||||||
## 📋 Implementation Checklist
|
## 📋 Implementation Checklist
|
||||||
|
|
||||||
### Phase 1: Basic Playability
|
### Phase 1: Basic Playability ✅ COMPLETE
|
||||||
- [ ] Create ChessViewModel
|
- [x] Create ChessViewModel
|
||||||
- [ ] Add navigation route for LiveChessGameScreen
|
- [x] Add navigation route for LiveChessGameScreen (Route.ChessGame exists)
|
||||||
- [ ] Create ChessGameScreen wrapper
|
- [x] Create ChessGameScreen wrapper
|
||||||
- [ ] Wire up NewGameDialog → ViewModel.createChallenge()
|
- [x] Wire up NewGameDialog → ViewModel.createChallenge()
|
||||||
- [ ] Implement event publishing (challenges, moves, game end)
|
- [x] Implement event publishing (challenges, moves, game end)
|
||||||
- [ ] Test: Create challenge, see it in feed
|
- [ ] Test: Create challenge, see it in feed
|
||||||
|
|
||||||
### Phase 2: Two-Player Functionality
|
### Phase 2: Two-Player Functionality ✅ COMPLETE
|
||||||
- [ ] Implement relay subscriptions for game events
|
- [x] Implement relay subscriptions for game events
|
||||||
- [ ] Wire up move synchronization (publish/receive)
|
- [x] Wire up move synchronization (publish/receive)
|
||||||
- [ ] Handle challenge acceptance flow
|
- [x] Handle challenge acceptance flow
|
||||||
- [ ] Test: Play complete game between two accounts
|
- [ ] Test: Play complete game between two accounts
|
||||||
|
|
||||||
### Phase 3: Polish
|
### Phase 3: Polish (IN PROGRESS)
|
||||||
- [ ] Add FAB to chess feed
|
- [ ] Add FAB to chess feed
|
||||||
- [ ] Implement badge counts
|
- [ ] Implement badge counts display in nav
|
||||||
- [ ] Add "Accept Challenge" button to incoming challenge cards
|
- [x] Add "Accept Challenge" button to incoming challenge cards
|
||||||
- [ ] Add "View Game" navigation from challenge/game-end cards
|
- [x] Add "View Game" navigation from challenge/game-end cards
|
||||||
- [ ] Handle edge cases (network errors, position desync, abandoned games)
|
- [ ] Handle edge cases (network errors, position desync, abandoned games)
|
||||||
|
|
||||||
### Phase 4: Persistence (Optional)
|
### Phase 4: Persistence (Optional)
|
||||||
@@ -256,8 +221,8 @@ AmethystMultiplatform/
|
|||||||
│ └── src/jvmAndroid/kotlin/.../nip64Chess/
|
│ └── src/jvmAndroid/kotlin/.../nip64Chess/
|
||||||
│ └── ChessEngine.jvmAndroid.kt ✅ kchesslib impl
|
│ └── ChessEngine.jvmAndroid.kt ✅ kchesslib impl
|
||||||
│
|
│
|
||||||
├── commons/ # Shared UI (Android/Desktop)
|
├── commons/ # Shared UI (Android/Desktop) - KMP
|
||||||
│ └── src/main/java/.../commons/chess/
|
│ └── src/commonMain/kotlin/.../commons/chess/
|
||||||
│ ├── ChessBoard.kt ✅ Static board
|
│ ├── ChessBoard.kt ✅ Static board
|
||||||
│ ├── InteractiveChessBoard.kt ✅ Click-to-move
|
│ ├── InteractiveChessBoard.kt ✅ Click-to-move
|
||||||
│ ├── ChessGameViewer.kt ✅ PGN playback
|
│ ├── ChessGameViewer.kt ✅ PGN playback
|
||||||
@@ -273,8 +238,13 @@ AmethystMultiplatform/
|
|||||||
│ │ └── NoteCompose.kt ✅ Event dispatching
|
│ │ └── NoteCompose.kt ✅ Event dispatching
|
||||||
│ ├── ui/screen/
|
│ ├── ui/screen/
|
||||||
│ │ ├── TopNavFilterState.kt ✅ Chess filter (3 kinds)
|
│ │ ├── TopNavFilterState.kt ✅ Chess filter (3 kinds)
|
||||||
│ │ └── loggedIn/chess/ ⏳ TODO: ViewModels, screens
|
│ │ └── loggedIn/chess/
|
||||||
│ └── ui/navigation/routes/ ⏳ TODO: Navigation
|
│ │ ├── ChessViewModel.kt ✅ State & event publishing
|
||||||
|
│ │ ├── ChessViewModelFactory.kt ✅ ViewModel factory
|
||||||
|
│ │ ├── ChessGameScreen.kt ✅ Game screen wrapper
|
||||||
|
│ │ └── dal/ChessFeedFilter.kt ✅ Feed filter
|
||||||
|
│ └── ui/navigation/routes/
|
||||||
|
│ └── Route.ChessGame ✅ Navigation route
|
||||||
│
|
│
|
||||||
└── docs/
|
└── docs/
|
||||||
└── live-chess-implementation-status.md ✅ This file
|
└── live-chess-implementation-status.md ✅ This file
|
||||||
@@ -282,16 +252,15 @@ AmethystMultiplatform/
|
|||||||
|
|
||||||
## 🚀 Next Steps
|
## 🚀 Next Steps
|
||||||
|
|
||||||
**To make chess fully playable**, implement in this order:
|
**To complete the chess feature**, implement:
|
||||||
|
|
||||||
1. **ChessViewModel** - Game state management & event publishing
|
1. ~~**ChessViewModel**~~ ✅ - Game state management & event publishing
|
||||||
2. **Navigation** - Route to LiveChessGameScreen
|
2. ~~**Navigation**~~ ✅ - Route to LiveChessGameScreen
|
||||||
3. **Event Subscriptions** - Listen for opponent moves
|
3. ~~**Event Subscriptions**~~ ✅ - Listen for opponent moves
|
||||||
4. **FAB** - Add "New Game" button to chess feed
|
4. **FAB** - Add "New Game" button to chess feed
|
||||||
5. **Test** - Play a complete game between two test accounts
|
5. **Badge Display** - Show badge count in navigation
|
||||||
|
6. **Test** - Play a complete game between two test accounts
|
||||||
The foundation is complete and tested. The remaining work is "wiring" - connecting the chess engine and UI to Amethyst's existing relay/ViewModel infrastructure.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Status**: Core chess functionality fully implemented. Integration layer partially complete. Estimated 4-6 hours of focused work to reach playable state.
|
**Status**: Core chess functionality fully implemented. ViewModel and relay subscriptions complete. Ready for FAB/badge polish and end-to-end testing.
|
||||||
|
|||||||
Reference in New Issue
Block a user