Skip to content

Commit

Permalink
Further change rating change display
Browse files Browse the repository at this point in the history
  • Loading branch information
outkine committed Mar 31, 2024
1 parent 91ab7f5 commit 66b4651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions app/views/battle/view.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
}


@ratingChange(change: Int) = {
@if(change > 0) {
@ratingChange(change: Int, didWin: Boolean) = {
@if(didWin) {
(+@change)
}
@if(change < 0) {
} else {
(@change)
}
}
Expand All @@ -40,10 +39,10 @@ <h1 class="mt-3 mb-2 text-center">
<h3 class="text-center">
@fullBattle.b.winner match {
case Some(Team.R1) => {
@fullBattle.b.pr1Rating @ratingChange(fullBattle.b.pr1RatingChange) <span style="color: var(--grey-2)">/</span> @fullBattle.b.pr2Rating @ratingChange(fullBattle.b.pr2RatingChange)
@fullBattle.b.pr1Rating @ratingChange(fullBattle.b.pr1RatingChange, true) <span style="color: var(--grey-2)">/</span> @fullBattle.b.pr2Rating @ratingChange(fullBattle.b.pr2RatingChange, false)
}
case Some(Team.R2) => {
@fullBattle.b.pr2Rating @ratingChange(fullBattle.b.pr2RatingChange) <span style="color: var(--grey-2)">/</span> @fullBattle.b.pr1Rating @ratingChange(fullBattle.b.pr1RatingChange)
@fullBattle.b.pr2Rating @ratingChange(fullBattle.b.pr2RatingChange, true) <span style="color: var(--grey-2)">/</span> @fullBattle.b.pr1Rating @ratingChange(fullBattle.b.pr1RatingChange, false)
}
case None => {
}
Expand Down
10 changes: 5 additions & 5 deletions app/views/robot/view.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@import services.Markdown
@(fullRobot: FullRobot, boardsWithBattles: Seq[(PRobot, BoardWithBattles)], isOwner: Boolean, assetsFinder: AssetsFinder)(implicit request: Request[AnyContent])

@ratingChange(change: Int) = {
@if(change > 0) {
@ratingChange(change: Int, didWin: Option[Boolean]) = {
@if(didWin.contains(true)) {
(+@change)
}
@if(change < 0) {
@if(didWin.contains(false)) {
(@change)
}
}
Expand Down Expand Up @@ -121,9 +121,9 @@ <h2>Battles</h2>
<td class="_rating">
@ratingChangeImg(battle.didRobotWin(fullRobot.robot.id))
@if(fullRobot.robot.id == battle.r1Id) {
@ratingChange(battle.pr1RatingChange)
@ratingChange(battle.pr1RatingChange, battle.didRobotWin(fullRobot.robot.id))
} else {
@ratingChange(battle.pr2RatingChange)
@ratingChange(battle.pr2RatingChange, battle.didRobotWin(fullRobot.robot.id))
}
</td>
<td class="_robot pr-0"><a href="@routes.RobotController.viewById(otherR.id.id)">
Expand Down

0 comments on commit 66b4651

Please sign in to comment.