Enum game_features::StatConditionType[][src]

pub enum StatConditionType {
    MinValue(f64),
    BetweenValue(f64f64),
    MaxValue(f64),
    MinPercent(f64),
    BetweenPercent(f64f64),
    MaxPercent(f64),
    DivisibleBy(i32),
    Custom(fn(_: f64) -> bool),
}
Expand description

A condition based on a stat’s value.

Variants

MinValue(f64)

The stat value must be higher or equal to this value.

BetweenValue(f64f64)

The stat value must be between these values.

MaxValue(f64)

The stat value must be lower or equal to this value.

MinPercent(f64)

The minimum progress of the value between its minimum and maximum. This calculates the distance between the minimum and maximum values, then assigns a value between 0.0 and 1.0 that correspond to the absolute distance from the minimum. If the minimum value is 10 and the maximum is 20 and we have a value of 15, then this corresponds to a “distance” of 0.5 (50%!) of the way between 10 and 20.

BetweenPercent(f64f64)

The minimum progress of the value between its minimum and maximum. This calculates the distance between the minimum and maximum values, then assigns a value between 0.0 and 1.0 that correspond to the absolute distance from the minimum. If the minimum value is 10 and the maximum is 20 and we have a value of 15, then this corresponds to a “distance” of 0.5 (50%!) of the way between 10 and 20.

MaxPercent(f64)

The minimum progress of the value between its minimum and maximum. This calculates the distance between the minimum and maximum values, then assigns a value between 0.0 and 1.0 that correspond to the absolute distance from the minimum. If the minimum value is 10 and the maximum is 20 and we have a value of 15, then this corresponds to a “distance” of 0.5 (50%!) of the way between 10 and 20.

DivisibleBy(i32)

The value is divisible by this value. DivisibleBy(2) is equivalent to (value % 2 == 0).

Custom(fn(_: f64) -> bool)

A custom function that takes the value and returns whether the condition passed or not.

Implementations

impl StatConditionType[src]

pub fn new_min_value(f0: f64) -> Self[src]

Constructs a new StatConditionType::MinValue.

impl StatConditionType[src]

pub fn new_between_value(f0: f64, f1: f64) -> Self[src]

Constructs a new StatConditionType::BetweenValue.

impl StatConditionType[src]

pub fn new_max_value(f0: f64) -> Self[src]

Constructs a new StatConditionType::MaxValue.

impl StatConditionType[src]

pub fn new_min_percent(f0: f64) -> Self[src]

Constructs a new StatConditionType::MinPercent.

impl StatConditionType[src]

pub fn new_between_percent(f0: f64, f1: f64) -> Self[src]

Constructs a new StatConditionType::BetweenPercent.

impl StatConditionType[src]

pub fn new_max_percent(f0: f64) -> Self[src]

Constructs a new StatConditionType::MaxPercent.

impl StatConditionType[src]

pub fn new_divisible_by(f0: i32) -> Self[src]

Constructs a new StatConditionType::DivisibleBy.

impl StatConditionType[src]

pub fn new_custom(f0: fn(_: f64) -> bool) -> Self[src]

Constructs a new StatConditionType::Custom.

impl StatConditionType[src]

pub fn is_true(
    &self,
    value: f64,
    min_value: Option<f64>,
    max_value: Option<f64>
) -> bool
[src]

Checks if the condition is true using the actual value, as well as the minimum and maximum values of the stat (found in the StatDefinition).

Trait Implementations

impl Clone for StatConditionType[src]

fn clone(&self) -> StatConditionType[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for StatConditionType[src]

fn fmt(&self, __f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'de> Deserialize<'de> for StatConditionType[src]

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Serialize for StatConditionType[src]

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]