diff --git a/modules/game/src/main/Game.scala b/modules/game/src/main/Game.scala index c47f6de7c6584..058599037b122 100644 --- a/modules/game/src/main/Game.scala +++ b/modules/game/src/main/Game.scala @@ -66,7 +66,9 @@ case class Game( def opponent(c: Color): Player = player(!c) - lazy val firstColor = Color.fromSente(sentePlayer before gotePlayer) + // View handicap games from the handicap receiver's perspective + // View other games from the dominant (title/rating) player's perspective + lazy val firstColor = if (isHandicap) !startColor else Color.fromSente(sentePlayer before gotePlayer) def firstPlayer = player(firstColor) def secondPlayer = player(!firstColor) diff --git a/modules/game/src/main/Player.scala b/modules/game/src/main/Player.scala index 29fe0fc4e5926..d90917180d998 100644 --- a/modules/game/src/main/Player.scala +++ b/modules/game/src/main/Player.scala @@ -14,6 +14,7 @@ case class Player( color: Color, engineConfig: Option[EngineConfig] = None, isBot: Boolean = false, + hasTitle: Boolean = false, isWinner: Option[Boolean] = None, isOfferingDraw: Boolean = false, lastDrawOffer: Option[Int] = None, @@ -82,11 +83,13 @@ case class Player( } def before(other: Player) = - ((rating, id), (other.rating, other.id)) match { - case ((Some(a), _), (Some(b), _)) if a != b => a > b - case ((Some(_), _), (None, _)) => true - case ((None, _), (Some(_), _)) => false - case ((_, a), (_, b)) => a < b + ((isHuman, hasTitle, rating, id), (other.isHuman, other.hasTitle, other.rating, other.id)) match { + case ((a, _, _, _), (b, _, _, _)) if a != b => a > b + case ((_, a, _, _), (_, b, _, _)) if a != b => a > b + case ((_, _, Some(a), _), (_, _, Some(b), _)) if a != b => a > b + case ((_, _, Some(_), _), (_, _, None, _)) => true + case ((_, _, None, _), (_, _, Some(_), _)) => false + case ((_, _, _, a), (_, _, _, b)) => a < b } def ratingAfter = rating map (_ + ~ratingDiff) @@ -119,7 +122,8 @@ object Player { userId: User.ID, rating: Int, provisional: Boolean, - isBot: Boolean + isBot: Boolean, + hasTitle: Boolean ): Player = Player( id = IdGenerator.player(color), @@ -128,7 +132,8 @@ object Player { userId = userId.some, rating = rating.some, provisional = provisional, - isBot = isBot + isBot = isBot, + hasTitle = hasTitle ) def make( @@ -143,7 +148,8 @@ object Player { userId = u.id, rating = perf.intRating, provisional = perf.glicko.provisional, - isBot = u.isBot + isBot = u.isBot, + hasTitle = u.hasTitle ) } @@ -167,6 +173,7 @@ object Player { val aiLevel = "ai" val aiEngine = "a" val isBot = "b" + val hasTitle = "t" val isOfferingDraw = "od" val lastDrawOffer = "ld" val proposeTakebackAt = "ta" @@ -222,6 +229,7 @@ object Player { ) ), isBot = r boolD isBot, + hasTitle = r boolD hasTitle, isWinner = win, isOfferingDraw = r boolD isOfferingDraw, lastDrawOffer = r intO lastDrawOffer, @@ -242,6 +250,7 @@ object Player { aiLevel -> p.aiLevel, aiEngine -> p.aiEngine.map(_.code), isBot -> w.boolO(p.isBot), + hasTitle -> w.boolO(p.hasTitle), isOfferingDraw -> w.boolO(p.isOfferingDraw), lastDrawOffer -> p.lastDrawOffer, isOfferingPause -> w.boolO(p.isOfferingPause), diff --git a/modules/tournament/src/main/AutoPairing.scala b/modules/tournament/src/main/AutoPairing.scala index 427cbea978f5a..38f2a1f3052e6 100644 --- a/modules/tournament/src/main/AutoPairing.scala +++ b/modules/tournament/src/main/AutoPairing.scala @@ -52,7 +52,7 @@ final class AutoPairing( } private def makePlayer(color: Color, player: Player) = - GamePlayer.make(color, player.userId, player.rating, provisional = player.provisional, isBot = false) + GamePlayer.make(color, player.userId, player.rating, provisional = player.provisional, isBot = false, hasTitle = false) private def usernameOf(userId: User.ID) = lightUserApi.sync(userId).fold(userId)(_.name) diff --git a/project/plugins.sbt b/project/plugins.sbt index 578d968ac4a64..669dff565b491 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.4") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.6.0") // addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.0.7")