From 19be2ad249aa085f96a79cb51ce0a0e2f07b53d5 Mon Sep 17 00:00:00 2001 From: merowin Date: Mon, 6 Jan 2025 17:51:19 +0100 Subject: [PATCH 1/6] readd last move indicator in baduk --- packages/shared/src/variants/baduk.ts | 13 ++++++++++-- packages/shared/src/variants/baduk_utils.ts | 22 +++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/packages/shared/src/variants/baduk.ts b/packages/shared/src/variants/baduk.ts index bbc1ad65..78574883 100644 --- a/packages/shared/src/variants/baduk.ts +++ b/packages/shared/src/variants/baduk.ts @@ -14,6 +14,7 @@ import { LegacyBadukConfig, NewBadukConfig, NewGridBadukConfig, + equals_placement, isGridBadukConfig, isLegacyBadukConfig, mapBoard, @@ -289,8 +290,16 @@ export class Baduk extends AbstractGame { return []; } }; - const stoneTransform = (color: Color): MulticolorStone => { - return { colors: colorTransform(color) }; + const stoneTransform = ( + color: Color, + idx: number | CoordinateLike, + ): MulticolorStone => { + return { + colors: colorTransform(color), + annotation: equals_placement(gamestate.last_move, idx) + ? "CR" + : undefined, + }; }; return { diff --git a/packages/shared/src/variants/baduk_utils.ts b/packages/shared/src/variants/baduk_utils.ts index f52cfd07..35d4cacc 100644 --- a/packages/shared/src/variants/baduk_utils.ts +++ b/packages/shared/src/variants/baduk_utils.ts @@ -3,6 +3,7 @@ import { BoardPattern, GridBoardConfig, } from "../lib/abstractBoard/boardFactory"; +import { Coordinate, CoordinateLike } from "../lib/coordinate"; import { Grid } from "../lib/grid"; import { BadukConfig } from "./baduk"; @@ -67,22 +68,22 @@ export type BoardShape = "1d" | "2d" | "flatten-2d-to-1d"; export function mapBoard(board: T[], f: (x: T) => S, shape: "1d"): S[]; export function mapBoard( board: T[][], - f: (x: T) => S, + f: (x: T, idx: number | CoordinateLike) => S, shape: "2d", ): S[][]; export function mapBoard( board: T[][], - f: (x: T) => S, + f: (x: T, idx: number | CoordinateLike) => S, shape: "flatten-2d-to-1d", ): S[]; export function mapBoard( board: T[][], - f: (x: T) => S, + f: (x: T, idx: number | CoordinateLike) => S, shape: BoardShape, ): S[] | S[][]; export function mapBoard( board: T[] | T[][], - f: (x: T) => S, + f: (x: T, idx: number | CoordinateLike) => S, shape: BoardShape, ) { switch (shape) { @@ -96,3 +97,16 @@ export function mapBoard( return (board as T[][]).flat().map(f); } } + +export function equals_placement( + last_move: string, + idx: number | CoordinateLike, +): boolean { + if (["", "pass", "resign", "timeout"].includes(last_move)) { + return false; + } + if (typeof idx === "number") { + return idx === Number(last_move); + } + return Coordinate.fromSgfRepr(last_move).equals(idx); +} From 261daa3e14fd10b92437f7e0b0bf00d5333b647d Mon Sep 17 00:00:00 2001 From: merowin Date: Mon, 6 Jan 2025 17:56:42 +0100 Subject: [PATCH 2/6] circle annotation uses mix blend mode --- .../vue-client/src/components/IntersectionAnnotation.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vue-client/src/components/IntersectionAnnotation.vue b/packages/vue-client/src/components/IntersectionAnnotation.vue index df9105b1..9d4fd8f8 100644 --- a/packages/vue-client/src/components/IntersectionAnnotation.vue +++ b/packages/vue-client/src/components/IntersectionAnnotation.vue @@ -24,9 +24,10 @@ const r = computed(() => props.r * 0.6); :r="r" :cx="props.cx" :cy="props.cy" - stroke="black" + stroke="#dbdbdb" stroke-width="0.1" fill="none" + class="mix" /> @@ -48,3 +49,8 @@ const r = computed(() => props.r * 0.6); /> + From 96728174bff4bdb780303699016f6337f4cbc6b2 Mon Sep 17 00:00:00 2001 From: merowin Date: Mon, 6 Jan 2025 18:00:40 +0100 Subject: [PATCH 3/6] last move indicator for sfractional --- packages/shared/src/variants/s_fractional.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/shared/src/variants/s_fractional.ts b/packages/shared/src/variants/s_fractional.ts index c4d3fcb2..7fe9a98e 100644 --- a/packages/shared/src/variants/s_fractional.ts +++ b/packages/shared/src/variants/s_fractional.ts @@ -4,7 +4,12 @@ import { createBoard, createGraph, } from "../lib/abstractBoard/boardFactory"; -import { isGridBadukConfig, mapBoard, NewBadukConfig } from "./baduk_utils"; +import { + equals_placement, + isGridBadukConfig, + mapBoard, + NewBadukConfig, +} from "./baduk_utils"; import { AbstractGame } from "../abstract_game"; import { Baduk, BadukBoard } from "./baduk"; import { Intersection } from "../lib/abstractBoard/intersection"; @@ -301,8 +306,16 @@ export class SFractional extends AbstractGame< } { const boardShape = isGridBadukConfig(config) ? "2d" : "flatten-2d-to-1d"; - const stoneTransform = (colors: PlacementColors): MulticolorStone => { - return { colors: colors }; + const stoneTransform = ( + colors: PlacementColors, + idx: number | CoordinateLike, + ): MulticolorStone => { + return { + colors: colors, + annotation: equals_placement(gamestate.lastMove, idx) + ? "CR" + : undefined, + }; }; const scoreTransform = (color: string): string[] | null => color === "" ? null : [color]; From aaf117a7cff43f8f590da6437246a03129f9f46e Mon Sep 17 00:00:00 2001 From: merowin Date: Mon, 6 Jan 2025 18:18:17 +0100 Subject: [PATCH 4/6] simplify ui transform --- packages/shared/src/variants/baduk.ts | 4 +--- packages/shared/src/variants/s_fractional.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/shared/src/variants/baduk.ts b/packages/shared/src/variants/baduk.ts index 78574883..4650ae4d 100644 --- a/packages/shared/src/variants/baduk.ts +++ b/packages/shared/src/variants/baduk.ts @@ -296,9 +296,7 @@ export class Baduk extends AbstractGame { ): MulticolorStone => { return { colors: colorTransform(color), - annotation: equals_placement(gamestate.last_move, idx) - ? "CR" - : undefined, + ...(equals_placement(gamestate.last_move, idx) && { annotation: "CR" }), }; }; diff --git a/packages/shared/src/variants/s_fractional.ts b/packages/shared/src/variants/s_fractional.ts index 7fe9a98e..fa544fba 100644 --- a/packages/shared/src/variants/s_fractional.ts +++ b/packages/shared/src/variants/s_fractional.ts @@ -312,9 +312,7 @@ export class SFractional extends AbstractGame< ): MulticolorStone => { return { colors: colors, - annotation: equals_placement(gamestate.lastMove, idx) - ? "CR" - : undefined, + ...(equals_placement(gamestate.lastMove, idx) && { annotation: "CR" }), }; }; const scoreTransform = (color: string): string[] | null => From bf72556a65776046a4b756eb1251d75a65cbee70 Mon Sep 17 00:00:00 2001 From: merowin Date: Mon, 6 Jan 2025 18:26:30 +0100 Subject: [PATCH 5/6] fix annotation in graph board --- .../boards/MulticolorGraphBoard.vue | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/vue-client/src/components/boards/MulticolorGraphBoard.vue b/packages/vue-client/src/components/boards/MulticolorGraphBoard.vue index 51d4307c..8f3dd57b 100644 --- a/packages/vue-client/src/components/boards/MulticolorGraphBoard.vue +++ b/packages/vue-client/src/components/boards/MulticolorGraphBoard.vue @@ -95,16 +95,16 @@ const viewBox = computed(() => { /> - +