Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve conditional display of provisional rank in mini-goban #2362

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/components/MiniGoban/MiniGoban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as preferences from "preferences";
import { Goban } from "goban";
import * as data from "data";
import { PersistentElement } from "PersistentElement";
import { getUserRating } from "rank_utils";
import { getUserRating, PROVISIONAL_RATING_CUTOFF } from "rank_utils";
import { Clock } from "Clock";
import { fetch } from "player_cache";
import { getGameResultText } from "misc";
Expand Down Expand Up @@ -113,11 +113,12 @@ export function MiniGoban(props: MiniGobanProps): JSX.Element {
// the goban engine doesn't come with the full player rating structure
fetch(goban.current.engine.players.black.id)
.then((player) => {
setBlackRank(
preferences.get("hide-ranks")
? ""
: " [" + getUserRating(player).bounded_rank_label + "]",
);
const blackRating = getUserRating(player);
let rank_text = blackRating.bounded_rank_label;
if (blackRating.deviation >= PROVISIONAL_RATING_CUTOFF) {
rank_text = "?";
}
setBlackRank(preferences.get("hide-ranks") ? "" : `[${rank_text}]`);
})
.catch(() => {
console.log("Couldn't work out black rank");
Expand All @@ -133,11 +134,12 @@ export function MiniGoban(props: MiniGobanProps): JSX.Element {
// the goban engine doesn't come with the full player rating structure
fetch(goban.current.engine.players.white.id)
.then((player) => {
setWhiteRank(
preferences.get("hide-ranks")
? ""
: " [" + getUserRating(player).bounded_rank_label + "]",
);
const whiteRating = getUserRating(player);
let rank_text = whiteRating.bounded_rank_label;
if (whiteRating.deviation >= PROVISIONAL_RATING_CUTOFF) {
rank_text = "?";
}
setWhiteRank(preferences.get("hide-ranks") ? "" : `[${rank_text}]`);
})
.catch(() => {
console.log("Couldn't work out white rank");
Expand Down
Loading