Skip to main content

Predicate

Enum Predicate 

Source
pub enum Predicate {
    HasType(String),
    StatIs(String),
    RelayIntLt(i64),
    HasVolatile(String),
    MoveTypeIsDefenderType,
    TargetHasStatus(String),
    Not(Box<Predicate>),
    TargetHasAnyStatus,
    LevelGE,
    SelfHpBelow {
        num: u32,
        den: u32,
    },
    SourceHasStatus(String),
}
Expand description

A closed predicate (doc 11 §1.1). Used by unless/when/cond guards.

Variants§

§

HasType(String)

The selector has the named type (chart membership).

§

StatIs(String)

The in-flight folded stat equals the named stat (the Sandstorm WeatherModifyStat SpD case, doc 11 §1). Requires the driver to stash the in-flight stat index in scratch via the binding; see crate::run_ops.

§

RelayIntLt(i64)

The current relay-as-int is strictly less than n (the Clear-Body VetoIf(RelayIntLt(0)) pattern, doc 11 §1).

§

HasVolatile(String)

The target selector has the named volatile live (blueprint 15 §2 / §3, the new predicate). The Gen-1 Substitute block on side-status: VetoIf(HasVolatile("Substitute")) (status fails through a Substitute, status_effects.rs). The volatile name is the game’s vocabulary; the binding resolves it against the live ctx.effects arena (RuleBindings::has_volatile). Pure read; no entropy. Game-agnostic: the rules crate names no concrete volatile.

§

MoveTypeIsDefenderType

The in-flight move’s type equals one of the target selector’s types (blueprint 15 §2 / §3). The Gen-1 burn/freeze/paralyze self-type-immunity quirk #23: VetoIf(MoveTypeIsDefenderType) — a Fire-type can’t be burned by a Fire move, etc. (status_effects.rs:85/110/135). The move type is recovered from the compiled hook’s move_type_index (the record’s type:); the binding answers membership (RuleBindings::move_type_is_defender_type). Pure read; no entropy.

§

TargetHasStatus(String)

The target selector currently has the named non-volatile status (blueprint 15 §2, the Dream Eater sleep gate VetoIf(!TargetHasStatus("sleep"))). The status name is the game’s vocabulary, resolved by the binding’s status_index_of (compiled into the status map) + RuleBindings::has_status. Pure read; no entropy.

§

Not(Box<Predicate>)

Logical negation of a closed predicate — VetoIf(Not(TargetHasStatus( "sleep"))) fires when the target is NOT asleep (the Dream Eater gate: drain only a sleeping target). Generic over any inner predicate; pure.

§

TargetHasAnyStatus

The target selector has ANY non-volatile status. Lets a compound status move (VetoIf(TargetHasAnyStatus) then InflictStatus + InflictVolatile) apply atomically or not at all — the Gen-1 Toxic “already-statused ⇒ nothing happens” rule. The engine knows no concrete status; the binding answers via RuleBindings::has_any_status. Pure read; no entropy.

§

LevelGE

The source selector’s level is ≥ the target selector’s level (blueprint 15 §2/§3, the OHKO gate). The Gen-1 one-hit-KO connects only when the user’s level is at least the foe’s (bug #19: a foe of strictly higher level is immune). The level is the game’s per-battler quantity — answered by RuleBindings::battler_level (the rules crate stays game-agnostic: it reads level only through the binding, never off BattlerState directly), which defaults to 0 so a game that never authors LevelGE is unaffected. Pure read; no entropy. Game-agnostic: the rules crate names no game-specific level concept — only “a number the binding supplies per battler”.

§

SelfHpBelow

The source selector’s HP fraction is strictly below num/den (the wuxia 「血越低攻越高」 self-HP-threshold gate, affinity.md §四 吕醉仙/苏夜). True iff source_hp * den < source_max_hp * num (so < num/den); den clamps to ≥1. Reads the SOURCE (the acting battler) directly off ctx (hp/max_hp are engine fields, no binding needed), so a ModifyDamage hook can scale outgoing damage only when the actor’s own HP is low. Pure read; no entropy. Game-agnostic: a fraction of an engine HP field — no game-specific/wuxia concept named here.

Fields

§num: u32

Numerator of the threshold fraction (e.g. 1 for < 1/2).

§den: u32

Denominator of the threshold fraction (clamped to ≥1).

§

SourceHasStatus(String)

The source selector currently has the named non-volatile status — exactly TargetHasStatus but on the SOURCE (the acting battler) rather than the dispatch target. Lets a BeforeMove VetoIf(SourceHasStatus("...")) skip the HOLDER’s OWN move (the wuxia 眩晕/控制 gate, affinity.md §四). The status name is the game’s vocabulary, resolved by the same status_index_of map + the EXISTING RuleBindings::has_status binding (no new binding). Pure read; no entropy.

Trait Implementations§

Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Predicate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Predicate

Source§

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 Eq for Predicate

Source§

impl PartialEq for Predicate

Source§

fn eq(&self, other: &Predicate) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Predicate

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.