Skip to content

Commit

Permalink
change the text when looking stats of another player
Browse files Browse the repository at this point in the history
  • Loading branch information
Prune2000 committed Mar 11, 2020
1 parent 7bc84d3 commit 412acb3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
28 changes: 20 additions & 8 deletions app/views/user/perfStat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object perfStat {
),
ratingChart.isDefined option div(cls := "rating-history")(spinner),
div(cls := "box__pad perf-stat__content")(
glicko(perfType, u.perfs(perfType), percentile),
glicko(ctx, u, perfType, u.perfs(perfType), percentile),
counter(stat.count),
highlow(stat),
resultStreak(stat.resultStreak),
Expand All @@ -70,7 +70,7 @@ object perfStat {

private def decimal(v: Double) = lila.common.Maths.roundAt(v, 2)

private def glicko(perfType: PerfType, perf: Perf, percentile: Option[Double])(implicit lang: Lang): Frag =
private def glicko(ctx: Context, u: User, perfType: PerfType, perf: Perf, percentile: Option[Double])(implicit lang: Lang): Frag =
st.section(cls := "glicko")(
h2(
trans.perfRatingX(strong(decimal(perf.glicko.rating).toString)),
Expand All @@ -82,13 +82,25 @@ object perfStat {
)("(", provisional(), ")")
),
". ",
percentile.filter(_ != 0.0 && !perf.glicko.provisional).map { percentile =>
span(cls := "details")(
trans.youAreBetterThanPercentOfPerfTypePlayers(
a(href := routes.Stat.ratingDistribution(perfType.key))(strong(percentile, "%")),
a(href := routes.Stat.ratingDistribution(perfType.key))(perfType.trans)
if (ctx.me.map(_.username) == Some(u.username) ) {
percentile.filter(_ != 0.0 && !perf.glicko.provisional).map { percentile =>
span(cls := "details")(
trans.youAreBetterThanPercentOfPerfTypePlayers(
a(href := routes.Stat.ratingDistribution(perfType.key))(strong(percentile, "%")),
a(href := routes.Stat.ratingDistribution(perfType.key))(perfType.trans)
)
)
)
}
} else {
percentile.filter(_ != 0.0 && !perf.glicko.provisional).map { percentile =>
span(cls := "details")(
trans.userIsBetterThanPercentOfPerfTypePlayers(
a(href := routes.User.show(u.username))(u.username),
a(href := routes.Stat.ratingDistribution(perfType.key))(strong(percentile, "%")),
a(href := routes.Stat.ratingDistribution(perfType.key))(perfType.trans)
)
)
}
}
),
p(
Expand Down
1 change: 1 addition & 0 deletions modules/i18n/src/main/I18nKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ val `returnToTournamentsHomepage` = new I18nKey("returnToTournamentsHomepage")
val `weeklyPerfTypeRatingDistribution` = new I18nKey("weeklyPerfTypeRatingDistribution")
val `yourPerfTypeRatingIsRating` = new I18nKey("yourPerfTypeRatingIsRating")
val `youAreBetterThanPercentOfPerfTypePlayers` = new I18nKey("youAreBetterThanPercentOfPerfTypePlayers")
val `userIsBetterThanPercentOfPerfTypePlayers` = new I18nKey("userIsBetterThanPercentOfPerfTypePlayers")
val `youDoNotHaveAnEstablishedPerfTypeRating` = new I18nKey("youDoNotHaveAnEstablishedPerfTypeRating")
val `yourRating` = new I18nKey("yourRating")
val `cumulative` = new I18nKey("cumulative")
Expand Down
1 change: 1 addition & 0 deletions translation/source/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ computer analysis, game chat and shareable URL.</string>
</plurals>
<string name="yourPerfTypeRatingIsRating">Your %1$s rating is %2$s.</string>
<string name="youAreBetterThanPercentOfPerfTypePlayers">You are better than %1$s of %2$s players.</string>
<string name="userIsBetterThanPercentOfPerfTypePlayers">%1$s is better than %2$s of %3$s players.</string>
<string name="youDoNotHaveAnEstablishedPerfTypeRating">You do not have an established %s rating.</string>
<string name="yourRating">Your rating</string>
<string name="cumulative">Cumulative</string>
Expand Down

0 comments on commit 412acb3

Please sign in to comment.