Skip to content

Commit

Permalink
todo
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienPensart committed Dec 22, 2024
1 parent 9fbbc90 commit 8983ef6
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 189 deletions.
293 changes: 133 additions & 160 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ edition = "2021"

[dependencies]
log = "0.4"
clap = { version = "4.0.4", features = ["derive"] }
thiserror = "1.0"
clap = { version = "4.5.21", features = ["derive"] }
thiserror = "2.0"
rand = "0.8"
rand_distr = "0.4.3"
derive_more = "0.99.17"
derive-new = "0.6.0"
derive_more = { version = "1.0", features = ["full"] }
derive-new = "0.7.0"
itertools = "0.13"
strum = { version = "0.26", features = ["derive"] }
indoc = "2.0"
regex = "1"
regex = "1.11.1"
colored = "2.0.0"
array-init = "2.0.1"
ordered-float = "4.2.0"
ordered-float = "4.5.0"
lazy-regex = "3.1.0"

[lints.rust]
Expand Down
8 changes: 0 additions & 8 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,4 @@ Usage :
- linting :
- clippy : cargo clippy --all-targets --all-features -- -D warnings

Todo :
- type games : defense, attack, petit hunt, full assets
- game managing
- flag on/off
- cut game
- random reunion
- duplicate

70.70% coverage, 772/1092 lines covered
9 changes: 9 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Todo :
- type games : defense, attack, petit hunt, full assets
- game managing
- flag on/off
- cut game
- dog one by one
- random reunion
- test games : handles, chelem, etc
- duplicate mode
4 changes: 2 additions & 2 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<const MODE: usize> Game<MODE> {
}
Ok(())
}
pub fn distribute(&mut self) -> Option<GameDistributed<MODE>> {
fn distribute(&mut self) -> Option<GameDistributed<MODE>> {
let mut players_in_game: [PlayerInGame; MODE] =
array_init(|i| PlayerInGame::new(self.mode, *self.players[i].options()));

Expand Down Expand Up @@ -138,7 +138,7 @@ impl<const MODE: usize> Game<MODE> {
pub fn rotate_at(&mut self, index: usize) {
self.players.rotate_left(index);
}
pub fn rotate_dealer(&mut self) {
fn rotate_dealer(&mut self) {
if self.dealer == self.players.len() - 1 {
self.dealer = 0;
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/game_distributed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ pub struct GameDistributed<'a, const MODE: usize> {
players_in_game: [PlayerInGame; MODE],
}

impl<const MODE: usize> fmt::Display for GameDistributed<'_, MODE> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "Game {} with dog {}", self.game.mode(), self.dog)
}
}

impl<'a, const MODE: usize> GameDistributed<'a, MODE> {
pub fn game(&mut self) -> &mut Game<MODE> {
self.game
Expand Down Expand Up @@ -167,3 +161,9 @@ impl<'a, const MODE: usize> GameDistributed<'a, MODE> {
Ok(Some(game_started))
}
}

impl<const MODE: usize> fmt::Display for GameDistributed<'_, MODE> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "Game {} with dog {}", self.game.mode(), self.dog)
}
}
16 changes: 11 additions & 5 deletions src/game_started.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::constants::{BASE_CONTRACT_POINTS, MAX_CARDS};
use crate::contract::Contract;
use crate::errors::TarotErrorKind;
use crate::game_distributed::GameDistributed;
// use crate::helpers::wait_input;
use crate::mode::Mode;
use crate::options::Options;
use crate::player::Player;
Expand Down Expand Up @@ -48,11 +47,11 @@ impl<const MODE: usize> fmt::Display for GameStarted<'_, MODE> {
}
}

impl<'a, const MODE: usize> GameStarted<'a, MODE> {
impl<const MODE: usize> GameStarted<'_, MODE> {
pub fn is_consistent(&mut self) -> Result<(), TarotErrorKind> {
self.game_distributed.game().is_consistent()
}
pub fn finished(&mut self) -> bool {
pub fn finished(&self) -> bool {
self.game_distributed.finished()
}
pub fn mode(&mut self) -> &Mode {
Expand Down Expand Up @@ -416,5 +415,12 @@ impl<'a, const MODE: usize> GameStarted<'a, MODE> {
}
}

// #[test]
// fn game_started_tests() {}
#[test]
fn game_started_tests() {
use crate::game::Game;

let options = Options::default();
let _game = Game::<{ Mode::Four.players() }>::new(options);

// let game_distributed = GameDistributed::new(game, options, )
}
2 changes: 1 addition & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub struct Options {
pub random: bool,
pub auto: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/player_in_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl PlayerInGame {
Ok(self.hand.remove(final_choice))
}
pub fn choose_contract_among(
&mut self,
&self,
player: &Player,
contracts: &[Contract],
) -> Option<Contract> {
Expand Down

0 comments on commit 8983ef6

Please sign in to comment.