From e3236fd7f9b6acc8f24cce2baffff59b35e96e72 Mon Sep 17 00:00:00 2001
From: fnoaman <4604419+fnoaman@users.noreply.github.com>
Date: Fri, 25 Oct 2024 14:31:48 +0100
Subject: [PATCH 1/2] Added handicap filter
---
src/components/SeekGraph/SeekGraphLegend.tsx | 26 ++++++++++++-------
.../SeekGraph/SeekGraphPalettes.tsx | 4 +++
src/lib/challenge_utils.tsx | 4 ++-
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/components/SeekGraph/SeekGraphLegend.tsx b/src/components/SeekGraph/SeekGraphLegend.tsx
index 29ad4e264e..39ee1ccec1 100644
--- a/src/components/SeekGraph/SeekGraphLegend.tsx
+++ b/src/components/SeekGraph/SeekGraphLegend.tsx
@@ -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"),
() =>
@@ -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"),
() =>
@@ -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"),
() =>
@@ -135,6 +142,7 @@ export function SeekGraphLegend(props: SeekGraphLegendProps): JSX.Element {
{group1}
{group2}
+
{group3}
diff --git a/src/components/SeekGraph/SeekGraphPalettes.tsx b/src/components/SeekGraph/SeekGraphPalettes.tsx
index bf3756f64b..746db3c34c 100644
--- a/src/components/SeekGraph/SeekGraphPalettes.tsx
+++ b/src/components/SeekGraph/SeekGraphPalettes.tsx
@@ -27,6 +27,7 @@ export interface SeekGraphColorPalette {
size13: ChallengePointStyle;
size9: ChallengePointStyle;
sizeOther: ChallengePointStyle;
+ handicap: ChallengePointStyle;
// UNRANKED: ChallengePointStyle;
ineligible: ChallengePointStyle;
user: ChallengePointStyle;
@@ -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" },
@@ -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" },
@@ -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" },
diff --git a/src/lib/challenge_utils.tsx b/src/lib/challenge_utils.tsx
index ccb23a8a49..afd75ffd74 100644
--- a/src/lib/challenge_utils.tsx
+++ b/src/lib/challenge_utils.tsx
@@ -31,6 +31,7 @@ export interface ChallengeFilter {
show9x9: boolean;
showOtherSizes: boolean;
showRengo: boolean;
+ showHandicap: boolean;
}
export type ChallengeFilterKey = keyof ChallengeFilter;
@@ -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;
}
From 1f7edc9da91971ac4d771c6e32c12025be65986b Mon Sep 17 00:00:00 2001
From: fnoaman <4604419+fnoaman@users.noreply.github.com>
Date: Fri, 25 Oct 2024 17:04:25 +0100
Subject: [PATCH 2/2] Added handicap to preferences
---
src/lib/preferences.ts | 1 +
src/views/Play/Play.tsx | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/lib/preferences.ts b/src/lib/preferences.ts
index 19bf26dab4..ec973cb634 100644
--- a/src/lib/preferences.ts
+++ b/src/lib/preferences.ts
@@ -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,
diff --git a/src/views/Play/Play.tsx b/src/views/Play/Play.tsx
index 8913e9198f..d29e68ede2 100644
--- a/src/views/Play/Play.tsx
+++ b/src/views/Play/Play.tsx
@@ -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: {}) {