Struct riichi_tools_rs::riichi::hand::Hand[][src]

pub struct Hand { /* fields omitted */ }

Implementations

impl Hand[src]

pub fn new(tiles: Vec<Option<Tile>>) -> Hand[src]

pub fn validate(&self) -> bool[src]

Checks the hand for invalid things (wrong number of tiles, > 4 same tiles…)

pub fn get_tiles(&self) -> &Vec<Option<Tile>>[src]

pub fn get_shapes(&self) -> &Vec<CompleteShape>[src]

pub fn get_open_shapes(&self) -> Vec<OpenShape>[src]

Returns a vector of OpenShape from shapes that we have identified in the hand.

pub fn get_34_array(&self, remove_open_tiles: bool) -> [u8; 34][src]

Converts our tiles vector to an array of 34 counts, since riichi has 34 different tiles. remove_open_tiles: ignores chi, pon and kanned tiles (also closed kans)

pub fn random_complete_hand(closed: bool, kans: bool) -> Hand[src]

Generate a 14 tile hand that is complete TODO fix kan generation TODO add open hand generation

pub fn random_hand(rules: Option<&Rules>) -> Hand[src]

Generate a random closed hand

pub fn from_text(
    representation: &str,
    force_return: bool
) -> Result<Hand, RiichiError>
[src]

Parses a hand from its text representation. force_return: will return even a partial/invalid hand TODO: red 5

pub fn add_tile(&mut self, tile: Tile)[src]

Adds a tile to this hand

pub fn remove_tile(&mut self, tile: &Tile)[src]

Removes a tile from this hand

pub fn remove_tile_by_id(&mut self, tile_id: u8)[src]

Removes a tile by ID

pub fn add_open_shape(&mut self, shape: &OpenShape)[src]

Goes through the tiles and dedicates them to an open shape

pub fn add_closed_kan(&mut self, kan: ClosedShape)[src]

pub fn count_tiles(&self) -> usize[src]

Returns the size of a hand - usually 13 or 14 tiles, depending on the situation.

pub fn get_closed_kans(&self) -> u8[src]

pub fn is_closed(&self) -> bool[src]

pub fn convert_to_string(&self) -> String[src]

Renders the hand as a string representation. The notation looks like this: Tiles are written as NC (number + color) More tiles of the same color can be written consecutively (1234p) z = honors - 1-4 = winds, 5-7 = dragons 0mps = red 5 (TODO) Open shapes are in brackets, (123s2) (p1s1) (k2p3) etc. See parse_* functions for more info

pub fn to_vec_of_strings(&self, no_shapes: bool) -> Vec<String>[src]

Returns the tiles of the hand as a vec of their string representations. Can be returned without open/closed shapes.

pub fn shanten(&mut self) -> i8[src]

Get shanten of this hand (and also set it if it’s not calculated yet)

pub fn get_shanten(&self) -> i8[src]

Get shanten of this hand

pub fn reset_shanten(&mut self)[src]

Reset shanten to 99 when we change the hand somehow

pub fn find_shanten_improving_tiles(
    &mut self,
    visible_tiles: Option<&[u8; 34]>
) -> Vec<(Option<Tile>, Vec<(Tile, u8)>, u8)>
[src]

Returns tiles that can be used to improve this hand. For 13 tile hands, there is only one option. For 14 tile hands, we list options for all discards that don’t lower our shanten. You can set visible_tiles that you can see on the table and it will remove them from the final list / ukeire count

pub fn reset_drawn_tiles(&mut self)[src]

pub fn get_drawn_tile(&self) -> Option<&Tile>[src]

Trait Implementations

impl Clone for Hand[src]

impl Default for Hand[src]

impl Display for Hand[src]

Auto Trait Implementations

impl RefUnwindSafe for Hand

impl Send for Hand

impl Sync for Hand

impl Unpin for Hand

impl UnwindSafe for Hand

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,