change the text when looking stats of another player

pull/6153/head
Prune2000 2020-03-11 15:39:09 -07:00
parent 7bc84d320c
commit 412acb36fc
3 changed files with 22 additions and 8 deletions

View File

@ -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),
@ -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)),
@ -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(

View File

@ -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")

View File

@ -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>