MA Beaudet [Tue, 9 Nov 2021 10:04:19 +0000 (11:04 +0100)]
feat!: apply C-CONV C-GETTER and C-CTOR to card and evaluator
C-CONV recommends accessing inner values with `into_inner`
C-GETTER recommends using `first` instead of `get_first` or `get`
C-CTOR recommends using `with_` for builders, I might create a Dealer
struct that has access to Deck and Rules or simply remove associated
methods in Deck
MA Beaudet [Mon, 8 Nov 2021 12:17:23 +0000 (13:17 +0100)]
feat!: add newtype struct Deck with associated methods
Methods associated to Deck `get()` `init_deck()`(changed to Default) and
others have been moved from Cards to newtype struct Deck.
Functions definitions and returned values are also more coherent.
MA Beaudet [Sun, 7 Nov 2021 19:49:07 +0000 (20:49 +0100)]
feat!: add array ref as args for eval_5hand and eval_7hand
eval_5hand now transmutes (unsafe rust) the `&[Card; 5]`. It "should" not
be unsafe as Card has the same repr as u32.
Looking for suggestions on how to convert slice newtype to inner.
MA Beaudet [Sun, 7 Nov 2021 19:49:07 +0000 (20:49 +0100)]
feat!: add bounded slices for eval_5hand and eval_7hand
eval_5hand now transmutes (unsafe rust) the `&[Card; 5]`. It "should" not
be unsafe as Card has the same repr as u32.
Looking for suggestions on how to convert slice newtype to inner.
MA Beaudet [Sat, 6 Nov 2021 16:23:36 +0000 (17:23 +0100)]
feat!: add Card(u32) newtype and Hand changed to Cards(Vec<Card>) newtype
`Hand` struct changed from Hand { cards } to newtype Cards(Vec<Card>)
Cards and Card both implement std::str::FromStr and std::fmt::Display.
Card implements TryForm<u32> PartialEq and PartialOrd (compares ranks)
Card provides get(), suit() and rank() methods, mostly helpers for
std::fmt::Display
Cards now implements init_deck(), shuffle_cards() and removen(name might
change)
Simulation example updated
MA Beaudet [Sat, 6 Nov 2021 12:02:18 +0000 (13:02 +0100)]
feat: add evaluator and hand structs (WIP)
Evaluation should be done using these structs. I will probably let some
functions available freely for wasm builds.
Hand should probably be changed to `struct Hand(Vec<Card>) where Card is
`struct Card(u32)` that impl `std::str::FromStr`, `std::fmt::Display`,
PartialEq`, `PartialOrd` and others...
MA Beaudet [Fri, 5 Nov 2021 14:37:28 +0000 (15:37 +0100)]
feat: eval_from_str split in two functions
`eval_from_str` was doing too much. Now `parse_cards` parses the cards
and `eval_hand` wraps over `eval_5hand` and `eval_7hand`.
Both functions are available through wasm_bindgen