Skip to content

Commit 3e2f3be

Browse files
fix: get rid of autoEndTurn in Move
1 parent 8e3b9dc commit 3e2f3be

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

src/main/scala/Game.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ object Game {
12781278
sys.error("Can't diceroll in Abalone")
12791279

12801280
def undo(metrics: MoveMetrics = MoveMetrics()): Validated[String, (Game, Undo)] =
1281-
sys.error("Can't undo in abalone")
1281+
sys.error("Can't undo in abalone") // @TODO: might want to be able to undo, actually
12821282

12831283
def endTurn(metrics: MoveMetrics = MoveMetrics()): Validated[String, (Game, EndTurn)] =
12841284
sys.error("Can't endTurn in abalone")

src/main/scala/Move.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ object Move {
358358
Pos.Abalone(m.dest),
359359
Situation.Abalone(m.situationBefore),
360360
Board.Abalone(m.after),
361-
m.autoEndTurn,
361+
false,
362362
None, // capture. @TODO: Could be the pos of the piece that was on targetSquare described by the move (because line moves (and by extension, pushes) are basically just marbles jumping over other ones)
363363
None,
364364
None,

src/main/scala/abalone/Move.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ case class Move(
99
dest: Pos,
1010
situationBefore: Situation,
1111
after: Board,
12-
autoEndTurn: Boolean,
1312
capture: Option[Pos] = None,
1413
promotion: Option[PromotableRole] = None,
1514
metrics: MoveMetrics = MoveMetrics()
@@ -19,8 +18,8 @@ case class Move(
1918

2019
override def finalizeAfter: Board = {
2120
val board = after.updateHistory({ h1 => h1.copy(
22-
lastTurn = if (autoEndTurn) h1.currentTurn :+ toUci else h1.lastTurn,
23-
currentTurn = if (autoEndTurn) List() else h1.currentTurn :+ toUci,
21+
lastTurn = h1.currentTurn :+ toUci,
22+
currentTurn = List(),
2423
score = if (captures) h1.score.add(situationBefore.player) else h1.score,
2524
halfMoveClock =
2625
if (captures) 0

src/main/scala/abalone/variant/Variant.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ abstract class Variant private[variant] (
9696
Map(pos ->
9797
pos.neighboursAsDirs.flatMap(d => d(pos)).filterNot(situation.board.pieces.contains(_))
9898
.map(landingSquare =>
99-
Move(piece, pos, landingSquare, situation, boardAfter(situation, pos, landingSquare), false)
99+
Move(piece, pos, landingSquare, situation, boardAfter(situation, pos, landingSquare))
100100
)
101101
)
102102
}.toMap
@@ -106,7 +106,7 @@ abstract class Variant private[variant] (
106106
val opponentPieces = situation.board.piecesOf(!situation.player)
107107

108108
def createMove(category: String, orig: Pos, dest: Pos, directions: Directions = List()): (String, Move) =
109-
(category, Move(Piece(situation.player, Role.defaultRole), orig, dest, situation, boardAfter(situation, orig, dest, directions), true, if (category == "pushout") Some(dest) else None))
109+
(category, Move(Piece(situation.player, Role.defaultRole), orig, dest, situation, boardAfter(situation, orig, dest, directions), if (category == "pushout") Some(dest) else None))
110110

111111
def generateSideMoves(lineOfMarbles: List[Pos], direction: Direction): List[(String, Move)] = {
112112
def canMoveTowards(pos: Pos, direction: Direction): Boolean = situation.board.isEmptySquare(direction(pos))

src/test/scala/abalone/AbaloneForsythTest.scala

-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,4 @@ class AbaloneForsythTest extends AbaloneTest with ValidatedMatchers {
4242
Forsyth>>(game4.situation) must_== FEN("1S1ss/SSSsss/1SS1ss1/3S4/4s4/3s4/1ss1SS1/s1sSSS/1s1SS 0 0 w 3 1")
4343
}
4444
}
45-
46-
4745
}

src/test/scala/abalone/AbaloneVariantTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import strategygames.{Score, Status}
88

99
class AbaloneVariantTest extends AbaloneTest with ValidatedMatchers {
1010

11-
// @TODO: use new type of tests Lakin did
11+
// @TODO: use new type of tests Lakin did - named "asymmetric"
1212

1313
"custom basic position" should {
1414
val fen = format.FEN("5/6/7/8/4sssS1/4S3/7/6/5 0 0 b 0 0")

0 commit comments

Comments
 (0)