Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions shared/src/main/scala/com/mogproject/mogami/core/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ case class Game(initialState: State = State.HIRATE,
lazy val status: GameStatus = {
if (currentState.isMated) {
if (lastMove.exists(m => m.isDrop && m.oldPtype == PAWN))
Illegal // uchifuzume
Uchifuzume
else
Mated
} else if (isPerpetualCheck) {
Illegal // perpetual check
PerpetualCheck
} else if (isRepetition) {
Drawn // Sennichite
} else {
Expand Down Expand Up @@ -116,7 +116,9 @@ object Game extends CsaFactory[Game] with SfenFactory[Game] {

case object Mated extends GameStatus

case object Illegal extends GameStatus
case object Uchifuzume extends GameStatus

case object PerpetualCheck extends GameStatus

case object Drawn extends GameStatus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class GameSpec extends FlatSpec with MustMatchers with GeneratorDrivenPropertyCh
"+1223GI",
"-2211OU",
"+2312GI"
)).get.status mustBe Illegal
)).get.status mustBe PerpetualCheck
Game.parseCsaString(Seq(
"P1 * * * * * * * * * ",
"P2 * * * * * * * * * ",
Expand All @@ -313,7 +313,7 @@ class GameSpec extends FlatSpec with MustMatchers with GeneratorDrivenPropertyCh
"-1827GI",
"+2819OU",
"-2718GI"
)).get.status mustBe Illegal
)).get.status mustBe PerpetualCheck
}
it must "return Illegal when uchifuzume" in {
Game.parseCsaString(Seq(
Expand All @@ -329,7 +329,7 @@ class GameSpec extends FlatSpec with MustMatchers with GeneratorDrivenPropertyCh
"P+00FU",
"+",
"+0012FU"
)).get.status mustBe Illegal
)).get.status mustBe Uchifuzume
}
it must "return Drawn when repetition" in {
Game.parseCsaString(Seq(
Expand Down