perf(core): reduce inter-service HTTP calls from 11 to 4 per move
- Add `postMoveStatus` batch method to `RuleSet` trait (default impl composes individual calls; `RuleSetRestAdapter` overrides with single HTTP round-trip) - Collapse 5 sequential rule checks in `GameEngine.executeMove` into one `postMoveStatus` call - Add `POST /api/rules/post-move-status` endpoint to rule-service - Add `exportCombined` to `IoServiceClient` and `POST /io/export/combined` endpoint to io-service, replacing two separate FEN/PGN HTTP calls - Fix `statusOf` to pattern-match on `WinReason` from `ctx.result` instead of making a redundant `isCheckmate` HTTP call - Remove duplicate `legalMoves` pre-validation in `GameResource.makeMove`; engine already validates and fires `InvalidMoveEvent` - Add `scalafix:off` guards for pre-existing `var`/`return` usage in `DefaultRules` hot-path code - Apply spotless formatting to previously unformatted files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package de.nowchess.api.rules
|
||||
|
||||
final case class PostMoveStatus(
|
||||
isCheckmate: Boolean,
|
||||
isStalemate: Boolean,
|
||||
isInsufficientMaterial: Boolean,
|
||||
isCheck: Boolean,
|
||||
isThreefoldRepetition: Boolean,
|
||||
)
|
||||
@@ -39,3 +39,15 @@ trait RuleSet:
|
||||
* promotion. Updates castling rights, en passant square, half-move clock, turn, and move history.
|
||||
*/
|
||||
def applyMove(context: GameContext)(move: Move): GameContext
|
||||
|
||||
/** Batch status check after a move is applied. Replaces individual isCheckmate/isStalemate/isInsufficientMaterial/
|
||||
* isCheck/isThreefoldRepetition calls with a single round-trip. Override for remote implementations.
|
||||
*/
|
||||
def postMoveStatus(context: GameContext): PostMoveStatus =
|
||||
PostMoveStatus(
|
||||
isCheckmate = isCheckmate(context),
|
||||
isStalemate = isStalemate(context),
|
||||
isInsufficientMaterial = isInsufficientMaterial(context),
|
||||
isCheck = isCheck(context),
|
||||
isThreefoldRepetition = isThreefoldRepetition(context),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user