chess_turn_engine/game/
castlinginfo.rs1use super::side::Side;
2use chess_notation_parser::{CastlingType, Square};
3
4pub struct Path {
6 pub src: Square,
8
9 pub dst: Square,
11}
12
13pub fn get_path_king(side: Side, castling_type: CastlingType) -> Path {
15 match side {
16 Side::White => match castling_type {
17 CastlingType::Long => Path {
18 src: Square::E1,
19 dst: Square::C1,
20 },
21 CastlingType::Short => Path {
22 src: Square::E1,
23 dst: Square::G1,
24 },
25 },
26 Side::Black => match castling_type {
27 CastlingType::Long => Path {
28 src: Square::E8,
29 dst: Square::C8,
30 },
31 CastlingType::Short => Path {
32 src: Square::E8,
33 dst: Square::G8,
34 },
35 },
36 }
37}
38
39pub fn get_path_rook(side: Side, castling_type: CastlingType) -> Path {
41 match side {
42 Side::White => match castling_type {
43 CastlingType::Long => Path {
44 src: Square::A1,
45 dst: Square::D1,
46 },
47 CastlingType::Short => Path {
48 src: Square::H1,
49 dst: Square::F1,
50 },
51 },
52 Side::Black => match castling_type {
53 CastlingType::Long => Path {
54 src: Square::A8,
55 dst: Square::D8,
56 },
57 CastlingType::Short => Path {
58 src: Square::H8,
59 dst: Square::F8,
60 },
61 },
62 }
63}
64
65pub fn get_king_crossing_squares(
68 side: Side,
69 castling_type: CastlingType,
70) -> &'static [Square] {
71 match side {
72 Side::White => match castling_type {
73 CastlingType::Long => &[Square::D1, Square::C1],
74 CastlingType::Short => &[Square::F1, Square::G1],
75 },
76 Side::Black => match castling_type {
77 CastlingType::Long => &[Square::D8, Square::C8],
78 CastlingType::Short => &[Square::F8, Square::G8],
79 },
80 }
81}
82
83pub fn get_required_empty_squares(
86 side: Side,
87 castling_type: CastlingType,
88) -> &'static [Square] {
89 match side {
90 Side::White => match castling_type {
91 CastlingType::Long => &[Square::D1, Square::C1, Square::B1],
92 CastlingType::Short => &[Square::F1, Square::G1],
93 },
94 Side::Black => match castling_type {
95 CastlingType::Long => &[Square::D8, Square::C8, Square::B8],
96 CastlingType::Short => &[Square::F8, Square::G8],
97 },
98 }
99}