@@ -6,7 +6,7 @@ import scala.util.chaining._
6
6
import play .api .libs .json ._
7
7
import strategygames .format .{ FEN , Forsyth , Uci , UciCharPair }
8
8
import strategygames .opening .{ FullOpening , FullOpeningDB }
9
- import strategygames .{ Game , GameLogic , MoveMetrics , Pocket , PocketData , Pos , Role , Situation }
9
+ import strategygames .{ Game , GameFamily , GameLogic , MoveMetrics , Pocket , PocketData , Pos , Role , Situation }
10
10
import strategygames .variant .Variant
11
11
import strategygames .draughts
12
12
import com .typesafe .scalalogging .Logger
@@ -39,9 +39,13 @@ object Chess {
39
39
captures = fullCaptureFields,
40
40
partialCaptures = req.fullCapture.getOrElse(false )
41
41
).toOption.flatMap { case (game, move) =>
42
- // Get the san of the last action
43
- game.actionStrs.flatten.lastOption.map { san =>
42
+ // Get the game record notation ( san/sgf) of the last action
43
+ game.actionStrs.flatten.lastOption.map { lastAction =>
44
44
{
45
+ val gameRecordNotation =
46
+ if (isSgf(req.variant))
47
+ strategygames.format.sgf.Dumper (req.variant, Vector (Vector (lastAction)))
48
+ else lastAction
45
49
val movable = game.situation.playable(false )
46
50
val captLen = (game.situation, req.dest) match {
47
51
case (Situation .Draughts (sit), Pos .Draughts (dest)) =>
@@ -75,7 +79,7 @@ object Chess {
75
79
case _ => false
76
80
}
77
81
),
78
- san
82
+ gameRecordNotation
79
83
),
80
84
req.path,
81
85
req.chapterId,
@@ -128,15 +132,25 @@ object Chess {
128
132
g.drop(req.role, req.pos)
129
133
.toOption
130
134
.flatMap({ case (game, drop) =>
131
- // Get the san of the last action
132
- game.actionStrs.flatten.lastOption map { san =>
133
- makeNode(
134
- game,
135
- Uci .WithSan (req.variant.gameLogic, Uci (req.variant.gameLogic, drop), san),
136
- req.path,
137
- req.chapterId,
138
- if (game.situation.playable(false )) game.situation.destinations else Map .empty
139
- )
135
+ // Get the game record notation (san/sgf) of the last action
136
+ game.actionStrs.flatten.lastOption map { lastAction =>
137
+ {
138
+ val gameRecordNotation =
139
+ if (isSgf(req.variant))
140
+ strategygames.format.sgf.Dumper (req.variant, Vector (Vector (lastAction)))
141
+ else lastAction
142
+ makeNode(
143
+ game,
144
+ Uci .WithSan (
145
+ req.variant.gameLogic,
146
+ Uci (req.variant.gameLogic, drop),
147
+ gameRecordNotation
148
+ ),
149
+ req.path,
150
+ req.chapterId,
151
+ if (game.situation.playable(false )) game.situation.destinations else Map .empty
152
+ )
153
+ }
140
154
}
141
155
})
142
156
.getOrElse(ClientIn .StepFailure )
@@ -274,6 +288,12 @@ object Chess {
274
288
)
275
289
}
276
290
291
+ private def isSgf (variant : Variant ): Boolean = {
292
+ variant.gameLogic == GameLogic .FairySF () || variant.gameLogic == GameLogic
293
+ .Go () || variant.gameLogic == GameLogic
294
+ .Backgammon () || (variant.gameFamily == GameFamily .LinesOfAction ())
295
+ }
296
+
277
297
// TODO: push this into strategygames. So much copy/paste from lila.socket.AnaDests
278
298
// this continues until `object json`
279
299
private val initialChessDests = " iqy muC gvx ltB bqs pxF jrz nvD ksA owE"
0 commit comments