Files
NowChessSystems/modules/rule/src/main/scala/de/nowchess/rules/RuleSet.scala
T
Janis 60e43027fa refactor(rule): update RuleSet to use GameContext
Replace Situation parameter with GameContext across all RuleSet methods
to align with the new game state abstraction. Updated imports to use the
api module's types (GameContext, Square, Move).

StandardRules will need to be updated in Task 3 to implement the new
interface signature and use api types instead of maichess.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-03 12:57:45 +02:00

34 lines
1.2 KiB
Scala

package de.nowchess.rules
import de.nowchess.api.game.GameContext
import de.nowchess.api.board.Square
import de.nowchess.api.move.Move
/** Extension point for chess rule variants (standard, Chess960, etc.).
* All rule queries are stateless: given a GameContext, return the answer.
*/
trait RuleSet:
/** All pseudo-legal moves for the piece on `square` (ignores check). */
def candidateMoves(context: GameContext, square: Square): List[Move]
/** Legal moves for `square`: candidates that don't leave own king in check. */
def legalMoves(context: GameContext, square: Square): List[Move]
/** All legal moves for the side to move. */
def allLegalMoves(context: GameContext): List[Move]
/** True if the side to move's king is in check. */
def isCheck(context: GameContext): Boolean
/** True if the side to move is in check and has no legal moves. */
def isCheckmate(context: GameContext): Boolean
/** True if the side to move is not in check and has no legal moves. */
def isStalemate(context: GameContext): Boolean
/** True if neither side has enough material to checkmate. */
def isInsufficientMaterial(context: GameContext): Boolean
/** True if halfMoveClock >= 100 (50-move rule). */
def isFiftyMoveRule(context: GameContext): Boolean