Skip to content

Commit

Permalink
Merge pull request #2856 from fnoaman/handicap-filter
Browse files Browse the repository at this point in the history
Added handicap filter
  • Loading branch information
anoek authored Nov 4, 2024
2 parents e405026 + 1f7edc9 commit 4148dc3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
26 changes: 17 additions & 9 deletions src/components/SeekGraph/SeekGraphLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ export function SeekGraphLegend(props: SeekGraphLegendProps): JSX.Element {

const group1 = [
legendItem(_("19x19"), () => BoardSizeLegendIcon(currentPalette.size19), "show19x19"),
legendItem(_("13x13"), () => BoardSizeLegendIcon(currentPalette.size13), "show13x13"),
legendItem(_("9x9"), () => BoardSizeLegendIcon(currentPalette.size9), "show9x9"),
legendItem(
_("Other"),
() => BoardSizeLegendIcon(currentPalette.sizeOther),
"showOtherSizes",
),
];
const group2 = [
legendItem(
_("Ranked"),
() =>
Expand All @@ -94,6 +85,14 @@ export function SeekGraphLegend(props: SeekGraphLegendProps): JSX.Element {
}),
"showRanked",
),
legendItem(
_("Handicap"),
() => BoardSizeLegendIcon(currentPalette.handicap),
"showHandicap",
),
];
const group2 = [
legendItem(_("13x13"), () => BoardSizeLegendIcon(currentPalette.size13), "show13x13"),
legendItem(
_("Unranked"),
() =>
Expand All @@ -108,6 +107,14 @@ export function SeekGraphLegend(props: SeekGraphLegendProps): JSX.Element {
}),
"showUnranked",
),
legendItem(
_("Other"),
() => BoardSizeLegendIcon(currentPalette.sizeOther),
"showOtherSizes",
),
];
const group3 = [
legendItem(_("9x9"), () => BoardSizeLegendIcon(currentPalette.size9), "show9x9"),
legendItem(
_("Rengo"),
() =>
Expand Down Expand Up @@ -135,6 +142,7 @@ export function SeekGraphLegend(props: SeekGraphLegendProps): JSX.Element {
<div className="row">
<div className="legend-group grid">{group1}</div>
<div className="legend-group grid">{group2}</div>
<div className="legend-group grid">{group3}</div>
</div>
</Card>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/SeekGraph/SeekGraphPalettes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface SeekGraphColorPalette {
size13: ChallengePointStyle;
size9: ChallengePointStyle;
sizeOther: ChallengePointStyle;
handicap: ChallengePointStyle;
// UNRANKED: ChallengePointStyle;
ineligible: ChallengePointStyle;
user: ChallengePointStyle;
Expand All @@ -43,6 +44,7 @@ export class SeekGraphPalettes {
size13: { fill: "#f000d0aa", stroke: "#ff60dd" },
size9: { fill: "#009090aa", stroke: "#00ffff" },
sizeOther: { fill: "#d06000aa", stroke: "#ff9000" },
handicap: { fill: "#d1cb0faa", stroke: "#fff712" },
// UNRANKED: { fill: "#d06000", stroke: "#ff9000" },
ineligible: { fill: "#6b6b6baa", stroke: "#bbb" },
user: { fill: "#ed1f1faa", stroke: "#e37495" },
Expand All @@ -57,6 +59,7 @@ export class SeekGraphPalettes {
size13: { fill: "#ff60ddaa", stroke: "#f000d0" },
size9: { fill: "#00ffffaa", stroke: "#009090" },
sizeOther: { fill: "#ff9000aa", stroke: "#d06000" },
handicap: { fill: "#fff712aa", stroke: "#d1cb0f" },
// UNRANKED: { fill: "#d06000", stroke: "#ff9000" },
ineligible: { fill: "#bbbbbbaa", stroke: "#6b6b6b" },
user: { fill: "#e37495aa", stroke: "#ed1f1f" },
Expand All @@ -71,6 +74,7 @@ export class SeekGraphPalettes {
size13: { fill: "#cc73a8aa", stroke: "#cc73a8" },
size9: { fill: "#55b2ebaa", stroke: "#55b2eb" },
sizeOther: { fill: "#d55b00aa", stroke: "#d55b00" },
handicap: { fill: "#d55b00aa", stroke: "#d55b00" },
// UNRANKED: { fill: "#d06000", stroke: "#ff9000" },
ineligible: { fill: "#bbbbbbaa", stroke: "#bbb" },
user: { fill: "#e6a100aa", stroke: "#e6a100" },
Expand Down
4 changes: 3 additions & 1 deletion src/lib/challenge_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface ChallengeFilter {
show9x9: boolean;
showOtherSizes: boolean;
showRengo: boolean;
showHandicap: boolean;
}

export type ChallengeFilterKey = keyof ChallengeFilter;
Expand All @@ -49,5 +50,6 @@ export function shouldDisplayChallenge(c: Challenge, filter: ChallengeFilter): b
(filter.showUnranked && !c.ranked && !c.rengo) ||
(filter.showRanked && c.ranked) ||
(filter.showRengo && c.rengo);
return (c.eligible || filter.showIneligible) && matchesRanked && matchesSize;
const matchesHandicap = filter.showHandicap || c.handicap === 0;
return (c.eligible || filter.showIneligible) && matchesRanked && matchesSize && matchesHandicap;
}
1 change: 1 addition & 0 deletions src/lib/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const defaults = {
"show-9x9-challenges": true,
"show-other-boardsize-challenges": true,
"show-rengo-challenges": true,
"show-handicap-challenges": true,
"show-move-numbers": true,
"show-offline-friends": true,
"show-seek-graph": true,
Expand Down
1 change: 1 addition & 0 deletions src/views/Play/Play.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class Play extends React.Component<{}, PlayState> {
["show9x9", "show-9x9-challenges"],
["showOtherSizes", "show-other-boardsize-challenges"],
["showRengo", "show-rengo-challenges"],
["showHandicap", "show-handicap-challenges"],
]);

constructor(props: {}) {
Expand Down

0 comments on commit 4148dc3

Please sign in to comment.