Skip to content

Commit 76d194b

Browse files
authored
Merge pull request #134 from Mind-Sports-Games/dev
Dev to Master Deploy Backgammon Start Player change plus other small items
2 parents 347ceba + 5aec467 commit 76d194b

File tree

6 files changed

+45
-23
lines changed

6 files changed

+45
-23
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ libraryDependencies += "io.lettuce" % "lettuce-core"
1919
libraryDependencies += "io.netty" % "netty-handler" % nettyVersion
2020
libraryDependencies += "io.netty" % "netty-codec-http" % nettyVersion
2121
libraryDependencies += "io.netty" % "netty-transport-native-epoll" % nettyVersion classifier "linux-x86_64"
22-
libraryDependencies += "org.playstrategy" %% "strategygames" % "10.2.1-pstrat164"
22+
libraryDependencies += "org.playstrategy" %% "strategygames" % "10.2.1-pstrat166"
2323
libraryDependencies += "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion
2424
libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % akkaVersion
2525
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.3"

src/main/scala/Fens.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ object Fens {
4444
}
4545

4646
// a game finishes
47-
def finish(gameId: Game.Id, winner: Option[PlayerIndex]) =
47+
def finish(gameId: Game.Id, winner: Option[PlayerIndex], playerScores: List[String]) =
4848
games.computeIfPresent(
4949
gameId,
5050
(_, watched) => {
51-
watched.clients foreach { _ ! ClientIn.Finish(gameId, winner) }
51+
watched.clients foreach { _ ! ClientIn.Finish(gameId, winner, playerScores) }
5252
null
5353
}
5454
)

src/main/scala/LilaHandler.scala

+6-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ final class LilaHandler(
127127
val versioned = ClientIn.RoundVersioned(version, flags, tpe, data)
128128
History.round.add(gameId, versioned)
129129
publish(_ room gameId, versioned)
130-
if (tpe == "move" || tpe == "drop") Fens.move(gameId, data, flags.moveBy)
130+
if (
131+
List("move", "drop", "lift", "undo", "endturn", "pass", "diceroll", "selectSquares").contains(tpe)
132+
)
133+
Fens.move(gameId, data, flags.moveBy)
131134
case TellRoom(roomId, payload) => publish(_ room roomId, ClientIn.Payload(payload))
132135
case RoundResyncPlayer(fullId) =>
133136
publish(_ room RoomId(fullId.gameId), ClientIn.RoundResyncPlayer(fullId.playerId))
@@ -147,9 +150,9 @@ final class LilaHandler(
147150
friendList.startPlaying(u)
148151
publish(_ userTv u, ClientIn.Resync)
149152
}
150-
case GameFinish(gameId, winner, users) =>
153+
case GameFinish(gameId, winner, playerScores, users) =>
151154
users foreach friendList.stopPlaying
152-
Fens.finish(gameId, winner)
155+
Fens.finish(gameId, winner, playerScores)
153156
case Pong(pingAt) => Monitor.ping.record("round", pingAt)
154157
case LilaBoot =>
155158
logger.info("#################### LILA BOOT ####################")

src/main/scala/ipc/ClientIn.scala

+12-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object ClientIn {
6363
.obj(
6464
"id" -> gameId.value,
6565
"lm" -> position.lastUci,
66-
"fen" -> position.fenWithPlayerIndex
66+
"fen" -> position.fen.value
6767
)
6868
.add("p1" -> position.clock.map(_.p1))
6969
.add("p2" -> position.clock.map(_.p2))
@@ -74,8 +74,17 @@ object ClientIn {
7474
)
7575
}
7676

77-
case class Finish(gameId: Game.Id, winner: Option[PlayerIndex]) extends ClientIn {
78-
def write = cliMsg("finish", Json.obj("id" -> gameId.value, "win" -> winner.map(_.letter.toString)))
77+
case class Finish(gameId: Game.Id, winner: Option[PlayerIndex], playerScores: List[String])
78+
extends ClientIn {
79+
def write = cliMsg(
80+
"finish",
81+
Json.obj(
82+
"id" -> gameId.value,
83+
"win" -> winner.map(_.letter.toString),
84+
"p1Score" -> playerScores.headOption,
85+
"p2Score" -> playerScores.lift(1)
86+
)
87+
)
7988
}
8089

8190
case class Mlat(millis: Double) extends ClientIn {

src/main/scala/ipc/LilaOut.scala

+23-11
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,20 @@ object LilaOut {
8585
flags: RoundEventFlags,
8686
tpe: String,
8787
data: JsonString
88-
) extends RoundOut
89-
case class RoundTourStanding(tourId: Tour.ID, data: JsonString) extends RoundOut
90-
case class RoundResyncPlayer(fullId: Game.FullId) extends RoundOut
91-
case class RoundGone(fullId: Game.FullId, v: Boolean) extends RoundOut
92-
case class RoundGoneIn(fullId: Game.FullId, seconds: Int) extends RoundOut
93-
case class RoundBotOnline(gameId: Game.Id, playerIndex: PlayerIndex, v: Boolean) extends RoundOut
94-
case class GameStart(users: List[User.ID]) extends RoundOut
95-
case class GameFinish(gameId: Game.Id, winner: Option[PlayerIndex], users: List[User.ID]) extends RoundOut
96-
case class TvSelect(gameId: Game.Id, speed: Speed, json: JsonString) extends RoundOut
88+
) extends RoundOut
89+
case class RoundTourStanding(tourId: Tour.ID, data: JsonString) extends RoundOut
90+
case class RoundResyncPlayer(fullId: Game.FullId) extends RoundOut
91+
case class RoundGone(fullId: Game.FullId, v: Boolean) extends RoundOut
92+
case class RoundGoneIn(fullId: Game.FullId, seconds: Int) extends RoundOut
93+
case class RoundBotOnline(gameId: Game.Id, playerIndex: PlayerIndex, v: Boolean) extends RoundOut
94+
case class GameStart(users: List[User.ID]) extends RoundOut
95+
case class GameFinish(
96+
gameId: Game.Id,
97+
winner: Option[PlayerIndex],
98+
playerScores: List[String],
99+
users: List[User.ID]
100+
) extends RoundOut
101+
case class TvSelect(gameId: Game.Id, speed: Speed, json: JsonString) extends RoundOut
97102

98103
// racer
99104

@@ -289,8 +294,15 @@ object LilaOut {
289294

290295
case "r/start" => Some(GameStart(commas(args).toList))
291296
case "r/finish" =>
292-
get(args, 3) { case Array(gameId, winner, users) =>
293-
Some(GameFinish(Game.Id(gameId), readOptionalPlayerIndex(winner), commas(users).toList))
297+
get(args, 4) { case Array(gameId, winner, playerScores, users) =>
298+
Some(
299+
GameFinish(
300+
Game.Id(gameId),
301+
readOptionalPlayerIndex(winner),
302+
commas(playerScores).toList,
303+
commas(users).toList
304+
)
305+
)
294306
}
295307

296308
// tv

src/main/scala/model.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,4 @@ case class UserTv(value: User.ID) extends AnyVal with StringValue
171171

172172
// NOTE: byoyomi - Shogi removed this stuff, but we definitely need it.
173173
case class Clock(p1: Int, p2: Int, p1Pending: Int, p2Pending: Int, p1Delay: Int, p2Delay: Int)
174-
case class Position(lastUci: Uci, fen: FEN, clock: Option[Clock], turnPlayerIndex: PlayerIndex) {
175-
def fenWithPlayerIndex = s"$fen ${turnPlayerIndex.letter}"
176-
}
174+
case class Position(lastUci: Uci, fen: FEN, clock: Option[Clock], turnPlayerIndex: PlayerIndex)

0 commit comments

Comments
 (0)