diff --git a/backend_protocol_specification.md b/backend_protocol_specification.md index 7118bdc..f9ad278 100644 --- a/backend_protocol_specification.md +++ b/backend_protocol_specification.md @@ -138,6 +138,8 @@ then the back-end will respond with "too\_many\_players". // e - magenta winning piece // f - cyan placed // g - magenta placed + // h - cyan winning and placed piece + // i - magenta winning and placed piece } ``` diff --git a/front_end/src/state.rs b/front_end/src/state.rs index 3c95288..abea9a8 100644 --- a/front_end/src/state.rs +++ b/front_end/src/state.rs @@ -413,9 +413,9 @@ pub fn board_from_string(board_string: String) -> BoardType { match c { 'a' => board[idx].replace(BoardState::Empty), 'b' | 'f' => board[idx].replace(BoardState::Cyan), - 'd' => board[idx].replace(BoardState::CyanWin), + 'd' | 'h' => board[idx].replace(BoardState::CyanWin), 'c' | 'g' => board[idx].replace(BoardState::Magenta), - 'e' => board[idx].replace(BoardState::MagentaWin), + 'e' | 'i' => board[idx].replace(BoardState::MagentaWin), _ => BoardState::Empty, }; } @@ -467,7 +467,11 @@ pub fn string_from_board(board: BoardType, placed: usize) -> (String, Option { if win_set.contains(&idx) { - 'd' + if idx == placed { + 'h' + } else { + 'd' + } } else if idx == placed { 'f' } else { @@ -476,7 +480,11 @@ pub fn string_from_board(board: BoardType, placed: usize) -> (String, Option { if win_set.contains(&idx) { - 'e' + if idx == placed { + 'i' + } else { + 'e' + } } else if idx == placed { 'g' } else { diff --git a/front_end/src/yew_components.rs b/front_end/src/yew_components.rs index 64f61f2..8b1e457 100644 --- a/front_end/src/yew_components.rs +++ b/front_end/src/yew_components.rs @@ -533,8 +533,10 @@ impl Wrapper { .chars() .nth(idx) .expect("idx into board_string should be in range"); - if char_at_idx == 'f' { - element_append_class(&document, &format!("slot{}", idx), "placed").ok(); + if char_at_idx == 'f' || char_at_idx == 'h' { + if char_at_idx == 'f' { + element_append_class(&document, &format!("slot{}", idx), "placed").ok(); + } if was_open { append_to_info_text( &document, @@ -544,8 +546,10 @@ impl Wrapper { ) .ok(); } - } else if char_at_idx == 'g' { - element_append_class(&document, &format!("slot{}", idx), "placed").ok(); + } else if char_at_idx == 'g' || char_at_idx == 'i' { + if char_at_idx == 'g' { + element_append_class(&document, &format!("slot{}", idx), "placed").ok(); + } if was_open { append_to_info_text( &document,