pub struct Party<P: MonsterProvider> { /* private fields */ }Expand description
An ordered party of monsters with a provider/param-defined capacity.
Implementations§
Source§impl<P: MonsterProvider> Party<P>
impl<P: MonsterProvider> Party<P>
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create an empty party with the given capacity (supplied by the game, not hardcoded).
Sourcepub fn add(&mut self, m: MonsterInstance<P>) -> Result<(), PartyFull<P>>
pub fn add(&mut self, m: MonsterInstance<P>) -> Result<(), PartyFull<P>>
Append a monster. Returns PartyFull (carrying the monster back) if
the party is already full.
Sourcepub fn remove(&mut self, index: usize) -> Option<MonsterInstance<P>>
pub fn remove(&mut self, index: usize) -> Option<MonsterInstance<P>>
Remove and return the monster at index, shifting later members down.
Sourcepub fn swap(&mut self, a: usize, b: usize)
pub fn swap(&mut self, a: usize, b: usize)
Swap the monsters at indices a and b. Out-of-range indices are
ignored.
Sourcepub fn get(&self, index: usize) -> Option<&MonsterInstance<P>>
pub fn get(&self, index: usize) -> Option<&MonsterInstance<P>>
Borrow the monster at index.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut MonsterInstance<P>>
pub fn get_mut(&mut self, index: usize) -> Option<&mut MonsterInstance<P>>
Mutably borrow the monster at index.
Sourcepub fn first_able(&self) -> Option<usize>
pub fn first_able(&self) -> Option<usize>
Index of the first non-fainted member (lead selection), if any.
Sourcepub fn all_fainted(&self) -> bool
pub fn all_fainted(&self) -> bool
Whether every member has fainted (battle loss / whiteout). A party with no members counts as all-fainted.
Sourcepub fn iter(&self) -> impl Iterator<Item = &MonsterInstance<P>>
pub fn iter(&self) -> impl Iterator<Item = &MonsterInstance<P>>
Iterate over the party members in order.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut MonsterInstance<P>>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut MonsterInstance<P>>
Mutably iterate over the party members in order.
Trait Implementations§
impl<P: Eq + MonsterProvider> Eq for Party<P>
impl<P: PartialEq + MonsterProvider> StructuralPartialEq for Party<P>
Auto Trait Implementations§
impl<P> Freeze for Party<P>
impl<P> RefUnwindSafe for Party<P>where
<P as MonsterProvider>::SpeciesId: RefUnwindSafe,
<P as MonsterProvider>::Genetics: RefUnwindSafe,
<P as MonsterProvider>::Training: RefUnwindSafe,
<P as MonsterProvider>::MoveId: RefUnwindSafe,
<P as MonsterProvider>::Stat: RefUnwindSafe,
impl<P> Send for Party<P>where
<P as MonsterProvider>::SpeciesId: Send,
<P as MonsterProvider>::Genetics: Send,
<P as MonsterProvider>::Training: Send,
<P as MonsterProvider>::MoveId: Send,
<P as MonsterProvider>::Stat: Send,
impl<P> Sync for Party<P>where
<P as MonsterProvider>::SpeciesId: Sync,
<P as MonsterProvider>::Genetics: Sync,
<P as MonsterProvider>::Training: Sync,
<P as MonsterProvider>::MoveId: Sync,
<P as MonsterProvider>::Stat: Sync,
impl<P> Unpin for Party<P>where
<P as MonsterProvider>::SpeciesId: Unpin,
<P as MonsterProvider>::Genetics: Unpin,
<P as MonsterProvider>::Training: Unpin,
<P as MonsterProvider>::MoveId: Unpin,
<P as MonsterProvider>::Stat: Unpin,
impl<P> UnsafeUnpin for Party<P>
impl<P> UnwindSafe for Party<P>where
<P as MonsterProvider>::SpeciesId: UnwindSafe,
<P as MonsterProvider>::Genetics: UnwindSafe,
<P as MonsterProvider>::Training: UnwindSafe,
<P as MonsterProvider>::MoveId: UnwindSafe,
<P as MonsterProvider>::Stat: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more