pub struct CombatState {
pub name: String,
pub campaign: String,
pub status: CombatStatus,
pub round: u32,
pub current_turn: Option<Uuid>,
pub combatants: Vec<Combatant>,
pub effects: Vec<Effect>,
}Expand description
Where a combat stands: the result of applying its log, event by event.
Fields§
§name: String§campaign: StringThe campaign this combat belongs to.
status: CombatStatus§round: u320 until the combat starts.
current_turn: Option<Uuid>Whose turn it is.
combatants: Vec<Combatant>Always kept in initiative order; combatants without initiative last.
effects: Vec<Effect>Implementations§
Source§impl CombatState
impl CombatState
Sourcepub fn replay<'a>(events: impl IntoIterator<Item = &'a CombatEvent>) -> Self
pub fn replay<'a>(events: impl IntoIterator<Item = &'a CombatEvent>) -> Self
Rebuilds a combat from its full event log.
Sourcepub fn combatant(&self, id: Uuid) -> Option<&Combatant>
pub fn combatant(&self, id: Uuid) -> Option<&Combatant>
The combatant with id, if it’s in the combat.
Sourcepub fn turn_order(&self) -> impl Iterator<Item = &Combatant>
pub fn turn_order(&self) -> impl Iterator<Item = &Combatant>
Combatants who take turns, in turn order.
Sourcepub fn apply(&mut self, event: &CombatEvent)
pub fn apply(&mut self, event: &CombatEvent)
Applies an event. Events are facts already validated by decide,
so this never fails; references to unknown ids are ignored.
Trait Implementations§
Source§impl Clone for CombatState
impl Clone for CombatState
Source§fn clone(&self) -> CombatState
fn clone(&self) -> CombatState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ComposeSchema for CombatState
impl ComposeSchema for CombatState
Source§impl Debug for CombatState
impl Debug for CombatState
Source§impl Default for CombatState
impl Default for CombatState
Source§fn default() -> CombatState
fn default() -> CombatState
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CombatState
impl<'de> Deserialize<'de> for CombatState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for CombatState
impl PartialEq for CombatState
Source§fn eq(&self, other: &CombatState) -> bool
fn eq(&self, other: &CombatState) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CombatState
impl Serialize for CombatState
Source§impl ToSchema for CombatState
impl ToSchema for CombatState
impl Eq for CombatState
impl StructuralPartialEq for CombatState
Auto Trait Implementations§
impl Freeze for CombatState
impl RefUnwindSafe for CombatState
impl Send for CombatState
impl Sync for CombatState
impl Unpin for CombatState
impl UnsafeUnpin for CombatState
impl UnwindSafe for CombatState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.