Skip to content

Commit

Permalink
feat: add Pawn rule and textual fix to Pawn specifications
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-derevyanchenko authored and mirko-felice committed Feb 20, 2023
1 parent 50ee6c3 commit be93e3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
@@ -0,0 +1,18 @@
/*
* MIT License
* Copyright (c) 2023 Cesario Jahrim Gabriele & Derevyanchenko Maxim & Felice Mirko & Kentpayeva Madina
*
* Full license description available at: https://github.com/jahrim/PPS-22-chess/blob/master/LICENSE
*/
package io.github.chess.model.rules.pawn

import io.github.chess.model.{Move, Position}
import io.github.chess.model.rules.ChessRule
import io.github.chess.model.Pawn

/** Implementation of the [[ChessRule]] that applies the rules of the [[Pawn]]. */
case class PawnRule() extends ChessRule:

override def findMoves(position: Position): Set[Move] =
ForwardOneRule().findMoves(position) ++
DoubleMoveRule().findMoves(position)
Expand Up @@ -24,8 +24,8 @@ class PawnRulesSpec extends AbstractSpec:
all(moves) should have(Symbol("to")(pawnNextPosition))
}

"Double move rule" should """let move the pawn only to the rank two steps ahead of the pawn's current position, "
without changing its file""" in {
"Double move rule" should "let move the pawn only to the rank two steps ahead of the pawn's current position, " +
"without changing its file" in {
val moves = doubleStepRule.findMoves(pawnInitialPosition)
moves should have size 1
all(moves) should have(Symbol("to")(pawnDoubleStepPosition))
Expand Down

0 comments on commit be93e3f

Please sign in to comment.