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
17 changes: 9 additions & 8 deletions shared/src/main/scala/com/mogproject/mogami/core/Ptype.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sealed abstract class Ptype(val id: Int) extends CsaLike with KifLike {

override def toKifString: String = Ptype.kifTable(id)

def toJapaneseNotationString: String = Ptype.japaneseNotationTable(id)

final def isBasic: Boolean = 8 <= id

final def isPromoted: Boolean = id < 8
Expand Down Expand Up @@ -66,6 +68,12 @@ object Ptype extends CsaTableFactory[Ptype] with KifTableFactory[Ptype] {
)

val kifTable: Seq[String] = Seq(
"N/A", "N/A", "と", "成香", "成桂", "成銀", "馬", "龍",
"玉", "金", "歩", "香", "桂", "銀", "角", "飛"
)

// 龍 -> 竜
val japaneseNotationTable: Seq[String] = Seq(
"N/A", "N/A", "と", "成香", "成桂", "成銀", "馬", "竜",
"玉", "金", "歩", "香", "桂", "銀", "角", "飛"
)
Expand All @@ -76,7 +84,7 @@ object Ptype extends CsaTableFactory[Ptype] with KifTableFactory[Ptype] {
)

val japaneseSimpleNames: Seq[String] = Seq(
"", "", "と", "杏", "圭", "全", "馬", "",
"", "", "と", "杏", "圭", "全", "馬", "",
"玉", "金", "歩", "香", "桂", "銀", "角", "飛"
)

Expand All @@ -94,13 +102,6 @@ object Ptype extends CsaTableFactory[Ptype] with KifTableFactory[Ptype] {
constructor(id - 2)
}

override def parseKifString(s: String): Option[Ptype] = {
if (s == "龍")
Some(PROOK)
else
super.parseKifString(s)
}

case object PPAWN extends Ptype(2)

case object PLANCE extends Ptype(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ case class Move(player: Player,
.getOrElse(MoveBuilderKifHand(to, oldPtype, elapsedTime)).toKifString

def toJapaneseNotationString: String =
isSameSquare.fold("同", to.toKifString) + oldPtype.toKifString + movement.map(_.kifString).getOrElse("") + promote.fold("成", couldPromote.fold("不成", ""))
isSameSquare.fold("同", to.toKifString) + oldPtype.toJapaneseNotationString + movement.map(_.kifString).getOrElse("") + promote.fold("成", couldPromote.fold("不成", ""))

def toWesternNotationString: String = {
val movementType = isDrop.fold("*", hasCapture.fold("x", "-"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class PieceSpec extends FlatSpec with MustMatchers with GeneratorDrivenPropertyC
"+p", "+l", "+n", "+s", "+b", "+r", "k", "g", "p", "l", "n", "s", "b", "r"
)
val kifPieces: Seq[String] = Seq(
" と", " 杏", " 圭", " 全", " 馬", " ", " 玉", " 金", " 歩", " 香", " 桂", " 銀", " 角", " 飛",
"vと", "v杏", "v圭", "v全", "v馬", "v竜", "v玉", "v金", "v歩", "v香", "v桂", "v銀", "v角", "v飛"
" と", " 杏", " 圭", " 全", " 馬", " ", " 玉", " 金", " 歩", " 香", " 桂", " 銀", " 角", " 飛",
"vと", "v杏", "v圭", "v全", "v馬", "v龍", "v玉", "v金", "v歩", "v香", "v桂", "v銀", "v角", "v飛"
)

"Piece#parseCsaString" must "succeed in normal cases" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PtypeSpec extends FlatSpec with MustMatchers with GeneratorDrivenPropertyC
val englishNames = Seq(
"K", "G", "P", "N", "S", "L", "B", "R", "+P", "+N", "+S", "+L", "+B", "+R")
val japaneseNames = Seq(
"玉", "金", "歩", "桂", "銀", "香", "角", "飛", "と", "圭", "全", "杏", "馬", "")
"玉", "金", "歩", "桂", "銀", "香", "角", "飛", "と", "圭", "全", "杏", "馬", "")
val promotedPtypes = Seq(
KING, GOLD, PPAWN, PKNIGHT, PSILVER, PLANCE, PBISHOP, PROOK, PPAWN, PKNIGHT, PSILVER, PLANCE, PBISHOP, PROOK)
val demotedPtypes = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ class StateSpec extends FlatSpec with MustMatchers with GeneratorDrivenPropertyC
" 9 8 7 6 5 4 3 2 1",
"+---------------------------+",
"|v杏v圭v全v金v玉v金v全v圭v杏|一",
"| ・v竜 ・ ・ ・ ・ ・v馬 ・|二",
"| ・v龍 ・ ・ ・ ・ ・v馬 ・|二",
"|vとvとvとvとvとvとvとvとvと|三",
"| ・ ・ ・ ・ ・ ・ ・ ・ ・|四",
"| ・ ・ ・ ・ ・ ・ ・ ・ ・|五",
"| ・ ・ ・ ・ ・ ・ ・ ・ ・|六",
"| と と と と と と と と と|七",
"| ・ 馬 ・ ・ ・ ・ ・ ・|八",
"| ・ 馬 ・ ・ ・ ・ ・ ・|八",
"| 杏 圭 全 金 玉 金 全 圭 杏|九",
"+---------------------------+",
"先手の持駒:なし"
Expand Down