From 37a66f640402b15405b609a54a67040e6bc67b54 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Fri, 27 Mar 2026 10:23:27 +0100 Subject: [PATCH] feat(client_web): flip board for black --- .gitignore | 3 +++ client_web/src/components/board.rs | 32 ++++++++++++++++++++---------- doc/backlog.md | 15 -------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index f06eefd..fa83e0e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,7 @@ devenv.local.nix # generated by samply rust profiler profile.json + bot/models +client_web/dist +var diff --git a/client_web/src/components/board.rs b/client_web/src/components/board.rs index 9aa6087..a0ae393 100644 --- a/client_web/src/components/board.rs +++ b/client_web/src/components/board.rs @@ -2,14 +2,20 @@ use leptos::prelude::*; use crate::trictrac::types::{SerTurnStage, ViewState}; -/// Field numbers in visual display order (left-to-right for each quarter). -const TOP_LEFT: [u8; 6] = [13, 14, 15, 16, 17, 18]; -const TOP_RIGHT: [u8; 6] = [19, 20, 21, 22, 23, 24]; -const BOT_LEFT: [u8; 6] = [12, 11, 10, 9, 8, 7]; -const BOT_RIGHT: [u8; 6] = [ 6, 5, 4, 3, 2, 1]; +/// Field numbers in visual display order (left-to-right for each quarter), white's perspective. +const TOP_LEFT_W: [u8; 6] = [13, 14, 15, 16, 17, 18]; +const TOP_RIGHT_W: [u8; 6] = [19, 20, 21, 22, 23, 24]; +const BOT_LEFT_W: [u8; 6] = [12, 11, 10, 9, 8, 7]; +const BOT_RIGHT_W: [u8; 6] = [ 6, 5, 4, 3, 2, 1]; + +/// 180° rotation of white's layout: black's pieces (field 24) appear at the bottom. +const TOP_LEFT_B: [u8; 6] = [ 1, 2, 3, 4, 5, 6]; +const TOP_RIGHT_B: [u8; 6] = [ 7, 8, 9, 10, 11, 12]; +const BOT_LEFT_B: [u8; 6] = [24, 23, 22, 21, 20, 19]; +const BOT_RIGHT_B: [u8; 6] = [18, 17, 16, 15, 14, 13]; /// Returns the displayed board value for `field_num` after applying `staged_moves`. -/// `is_white`: true when the local player's checkers are positive (host = white). +/// Field numbers are always in white's coordinate system (1–24). fn displayed_value( base_board: [i8; 24], staged_moves: &[(u8, u8)], @@ -98,18 +104,24 @@ pub fn Board( .collect() }; + let (tl, tr, bl, br) = if is_white { + (&TOP_LEFT_W, &TOP_RIGHT_W, &BOT_LEFT_W, &BOT_RIGHT_W) + } else { + (&TOP_LEFT_B, &TOP_RIGHT_B, &BOT_LEFT_B, &BOT_RIGHT_B) + }; + view! {
-
{fields_from(&TOP_LEFT)}
+
{fields_from(tl)}
-
{fields_from(&TOP_RIGHT)}
+
{fields_from(tr)}
-
{fields_from(&BOT_LEFT)}
+
{fields_from(bl)}
-
{fields_from(&BOT_RIGHT)}
+
{fields_from(br)}
} diff --git a/doc/backlog.md b/doc/backlog.md index dd52d54..339c552 100644 --- a/doc/backlog.md +++ b/doc/backlog.md @@ -31,21 +31,6 @@ ulimit -s unlimited # Pour revenir à la normale Cheatsheet : arbre des situations et priorité des règles -### Epic : jeu simple - -- déplacements autorisés par les règles (pourront être validés physiquement si jeu avec écoles) -- calcul des points automatique (pas d'écoles) - -Server - -- - -Client - -- client tui (ratatui) -- client desktop (bevy) -- client web - ### Epic : jeu avec écoles - déplacement de fiches points : validation physique