Skip to content

Commit 5cf8eb5

Browse files
author
Mauran
committed
chore: 0.1.2
Signed-off-by: Mauran <thomas.mauran@etu.umontpellier.fr>
1 parent b6c857d commit 5cf8eb5

7 files changed

Lines changed: 36 additions & 26 deletions

File tree

.github/workflows/flow_test_build_push.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ jobs:
1414
name: Build & push Docker image
1515
needs: build_and_test
1616
uses: ./.github/workflows/docker_push.yml
17-
18-
17+
release_crate:
18+
name: Release new crate
19+
needs: build_and_test
20+
uses: ./.github/workflows/release_cargo.yml
21+
secrets: inherit
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release the cargo crate
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions-rs/toolchain@v1
12+
with:
13+
toolchain: stable
14+
override: true
15+
16+
- uses: katyo/publish-crates@v2
17+
with:
18+
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
19+
ignore-unpublished-changes: true

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chess-tui"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["Thomas Mauran"]
55
license = "MIT"
66
edition = "2021"

src/board.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -414,27 +414,19 @@ impl Board {
414414
}
415415
}
416416
}
417-
return possible_moves.len();
417+
possible_moves.len()
418418
}
419419

420420
pub fn is_checkmate(&self) -> bool {
421421
if !is_getting_checked(self.board, self.player_turn, self.moves_history.clone()) {
422422
return false;
423423
}
424424

425-
if self.number_of_authorized_positions() == 0 {
426-
return true;
427-
} else {
428-
return false;
429-
}
425+
self.number_of_authorized_positions() == 0
430426
}
431427

432428
pub fn is_pat(&self) -> bool {
433-
if self.number_of_authorized_positions() == 0 {
434-
return true;
435-
} else {
436-
return false;
437-
}
429+
self.number_of_authorized_positions() == 0
438430
}
439431

440432
// Method to render the board
@@ -862,7 +854,7 @@ mod tests {
862854
];
863855
let board = Board::new(custom_board, PieceColor::White, vec![]);
864856

865-
assert_eq!(Board::is_checkmate(&board), true);
857+
assert!(Board::is_checkmate(&board));
866858
}
867859

868860
#[test]
@@ -906,7 +898,7 @@ mod tests {
906898
];
907899
let board = Board::new(custom_board, PieceColor::White, vec![]);
908900

909-
assert_eq!(Board::is_checkmate(&board), false);
901+
assert!(!Board::is_checkmate(&board));
910902
}
911903

912904
#[test]
@@ -959,7 +951,7 @@ mod tests {
959951
];
960952
let board = Board::new(custom_board, PieceColor::White, vec![]);
961953

962-
assert_eq!(Board::is_checkmate(&board), false);
954+
assert!(!Board::is_checkmate(&board));
963955
}
964956

965957
#[test]
@@ -1003,7 +995,7 @@ mod tests {
1003995
];
1004996
let board = Board::new(custom_board, PieceColor::White, vec![]);
1005997

1006-
assert_eq!(Board::is_pat(&board), true);
998+
assert!(Board::is_pat(&board));
1007999
}
10081000

10091001
#[test]
@@ -1047,6 +1039,6 @@ mod tests {
10471039
];
10481040
let board = Board::new(custom_board, PieceColor::White, vec![]);
10491041

1050-
assert_eq!(Board::is_pat(&board), false);
1042+
assert!(!Board::is_pat(&board));
10511043
}
10521044
}

src/pieces/knight.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Knight {
8989
mod tests {
9090
use crate::{
9191
board::Board,
92-
pieces::{bishop::Bishop, knight::Knight, PieceColor, PieceType, Position},
92+
pieces::{knight::Knight, PieceColor, PieceType, Position},
9393
utils::is_getting_checked,
9494
};
9595

src/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ratatui::{
88
};
99

1010
use crate::{app::App, constants::WHITE, pieces::PieceColor, utils::get_opposite_color};
11-
use std::fmt::format;
11+
1212

1313
/// Renders the user interface widgets.
1414
pub fn render(app: &mut App, frame: &mut Frame) {

src/utils.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,7 @@ pub fn impossible_positions_king_checked(
236236
pub fn is_piece_opposite_king(piece: Option<(PieceType, PieceColor)>, color: PieceColor) -> bool {
237237
match piece {
238238
Some((piece_type, piece_color)) => {
239-
if piece_type == PieceType::King && piece_color == get_opposite_color(color) {
240-
true
241-
} else {
242-
false
243-
}
239+
piece_type == PieceType::King && piece_color == get_opposite_color(color)
244240
}
245241
_ => false,
246242
}

0 commit comments

Comments
 (0)