Fix up setup of an initial game.
This commit is contained in:
parent
6b9027bdd8
commit
3af3ede5a7
|
@ -1,3 +1,5 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "justcheckers-engine"
|
||||
version = "0.6.0"
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Board {
|
|||
|
||||
let board_size = size.get_size();
|
||||
let width = board_size / 2;
|
||||
let height = board_size / 2;
|
||||
let height = board_size;
|
||||
let starting_rows = board_size / 2 - 1;
|
||||
|
||||
let playing_tiles = (0..width * height)
|
||||
|
@ -47,7 +47,7 @@ impl Board {
|
|||
match row {
|
||||
r if r < starting_rows => BoardTile::Piece(
|
||||
Piece::LightPawn),
|
||||
r if r > height - starting_rows => BoardTile::Piece(
|
||||
r if r > height - starting_rows - 1 => BoardTile::Piece(
|
||||
Piece::DarkPawn),
|
||||
_ => BoardTile::Empty,
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ impl Board {
|
|||
}
|
||||
|
||||
fn get_index(&self, row: u32, column: u32) -> usize {
|
||||
let width = self.dimensions.get_size();
|
||||
(row * width + column) as usize
|
||||
let width = self.dimensions.get_size() / 2;
|
||||
(row * width + (column / 2)) as usize
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,15 +88,18 @@ impl fmt::Display for Board {
|
|||
}
|
||||
|
||||
for col in 0..(width / 2) {
|
||||
let token = match self.tiles[self.get_index(row, col)] {
|
||||
|
||||
let idx = (row * (width / 2) + col) as usize;
|
||||
|
||||
let token = match self.tiles[idx] {
|
||||
BoardTile::Piece(Piece::LightPawn) => "○",
|
||||
BoardTile::Piece(Piece::LightKing) => "⍟",
|
||||
BoardTile::Piece(Piece::DarkPawn) => "●",
|
||||
BoardTile::Piece(Piece::DarkKing) => "✪",
|
||||
BoardTile::Empty => "✪",
|
||||
BoardTile::Empty => "◰",
|
||||
};
|
||||
|
||||
let adjacent = if row % 2 == 1 && col == width - 1 {
|
||||
let adjacent = if row % 2 == 0 && col == (width / 2) - 1 {
|
||||
""
|
||||
} else {
|
||||
" "
|
||||
|
@ -122,7 +125,7 @@ mod tests {
|
|||
fn setup_international_board() {
|
||||
|
||||
let expected =
|
||||
"\
|
||||
" \
|
||||
ABCDEFGHIJ\n\
|
||||
1 ○ ○ ○ ○ ○\n\
|
||||
2○ ○ ○ ○ ○ \n\
|
||||
|
|
Loading…
Reference in New Issue