Skip to main content

View

Struct View 

Source
pub struct View<'a> { /* private fields */ }
Expand description

What one seat may legally see of a round

The wrapped Round is private, and these accessors are the whitelist: the opponent’s hand and the stock order are structurally unreachable.

Implementations§

Source§

impl<'a> View<'a>

Source

pub const fn seat(&self) -> Player

The seat this view belongs to

Source

pub const fn game_scores(&self) -> [u16; 2]

The running game totals, this seat’s first: [mine, theirs]

Note the order: seat-relative, unlike Table::scores, which is indexed by Player. Both totals sit on the scoreboard in plain sight, so they are part of the legal whitelist. [0, 0] for a standalone round played outside a Game; the target to win is rules().game_target.

Source

pub const fn rules(&self) -> &'a Rules

The scoring rules of the round

Source

pub const fn dealer(&self) -> Player

The dealer of the round

Source

pub const fn knock_limit(&self) -> u8

The knock limit in effect

Source

pub const fn phase(&self) -> Phase

The current phase of the round

Source

pub fn discard_pile(&self) -> &'a [Card]

The discard pile, oldest first — the last card is the top

Source

pub fn upcard(&self) -> Option<Card>

The top of the discard pile

Source

pub fn stock_len(&self) -> usize

How many cards remain in the stock — the order is never visible

Source

pub fn spread(&self) -> impl Iterator<Item = Meld> + 'a

The knocker’s spread, extended by any layoffs so far

Empty before a knock. Enumeration order gives the meld indices that Layoff::meld addresses.

Source

pub const fn knocker(&self) -> Option<Player>

The knocker, if the round has reached a knock

Source

pub const fn hand(&self) -> Hand

This seat’s hand

Source

pub const fn taken_discard(&self) -> Option<Card>

The card this seat took from the pile this turn, which may not be shed until the next turn

Source

pub const fn can_take_discard(&self) -> bool

Whether taking the top of the discard pile is available

True at the upcard offer and on a normal draw, false on the forced stock draw after both players pass the upcard.

Source

pub const fn opponent_known(&self) -> Hand

Cards known to be in the opponent’s hand: taken from the pile and not yet shed or laid off

Source

pub const fn opponent_shed(&self) -> Hand

Every card the opponent has discarded, whether or not it is still in the pile

Source

pub const fn opponent_passed(&self) -> Hand

Upcards the opponent declined during the upcard phase

Source

pub const fn opponent_hand_len(&self) -> usize

How many cards the opponent holds — 10, or 11 mid-turn

Source

pub fn unseen(&self) -> Hand

The cards this seat cannot locate: the whole deck minus its own hand, the discard pile, the opponent’s known cards, and the spread

Exactly the cards a determinizing bot must distribute between the stock and the hidden part of the opponent’s hand. Until a knock reveals the spread, unseen().len() == stock_len() + opponent_hand_len() - opponent_known().len(); afterwards the spread also counts as seen.

Source

pub fn deadwood(&self) -> u8

The minimum deadwood of this seat’s hand

Source

pub fn best_melds(&self) -> Melds

A deadwood-minimizing arrangement of this seat’s hand

Auto Trait Implementations§

§

impl<'a> Freeze for View<'a>

§

impl<'a> RefUnwindSafe for View<'a>

§

impl<'a> Send for View<'a>

§

impl<'a> Sync for View<'a>

§

impl<'a> Unpin for View<'a>

§

impl<'a> UnsafeUnpin for View<'a>

§

impl<'a> UnwindSafe for View<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.