Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions shared/src/main/scala/com/mogproject/mogami/core/State.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,9 @@ case class State(turn: Player = BLACK, board: BoardType = Map.empty, hand: HandT

def checkCapacity: Boolean = getPieceCount.filterKeys(_.ptype == KING).forall(_._2 <= 1) && getUnusedPtypeCount.values.forall(_ >= 0)

def canAttack(from: Square, to: Square): Boolean = {
attackBBOnBoard(turn).get(from).exists(_.get(to))
}
def canAttack(from: Square, to: Square): Boolean = canAttack(Left(from), to)

def canAttack(from: MoveFrom, to: Square): Boolean = {
from match {
case Left(fr) => attackBBOnBoard(turn).get(fr).exists(_.get(to))
case Right(h) => attackBBInHand.get(h).exists(_.get(to))
}
}
def canAttack(from: MoveFrom, to: Square): Boolean = legalMovesBB.get(from).exists(_.get(to))

/**
* @note This method does not check the capability of the piece
Expand Down