pub struct ManaPool {
pub max: f64,
pub current: f64,
pub regen_per_second: f64,
pub updated_tick: u64,
}Expand description
Fight-local mana of one combatant.
Character combatants (hero, party ally, human PvP opponent) carry Some;
mobs carry None and are never mana-gated. The pool is refilled to max at
every fight start and is not carried between fights — outside a fight there
is no mana at all, so nothing can spend it.
current is a float because regen is a per-second rate applied on the
millisecond fight clock; updated_tick makes the accrual drift-free and
independent of the heartbeat cadence (see ManaPool::regen_to).
Fields§
§max: f64Full pool size, from mana_settings.pool.
current: f64Points available right now.
regen_per_second: f64Points restored per second of fight time, from mana_settings.regen_per_second.
updated_tick: u64Ticker unit the pool was last accrued at (1 unit = 1 ms).
Implementations§
Source§impl ManaPool
impl ManaPool
Sourcepub fn full(max: f64, regen_per_second: f64, current_tick: u64) -> Self
pub fn full(max: f64, regen_per_second: f64, current_tick: u64) -> Self
A full pool at fight start.
Sourcepub fn regen_to(&mut self, current_tick: u64)
pub fn regen_to(&mut self, current_tick: u64)
Accrues regen for the time elapsed since the last accrual and clamps to
max. Idempotent within one tick, so both the fight heartbeat and the
cast path can call it freely.
Sourcepub fn try_spend(&mut self, cost: f64) -> bool
pub fn try_spend(&mut self, cost: f64) -> bool
Spends cost if the pool covers it. Returns false (and changes
nothing) when it does not — the caller must then wait, not cast.
Sourcepub fn ms_until_affordable(&self, cost: f64) -> Option<u64>
pub fn ms_until_affordable(&self, cost: f64) -> Option<u64>
Milliseconds of fight time until the pool covers cost.
Some(0) when it already does. None when regen can never get there
(no regen at all, or a cost above the whole pool) — the caller decides
the fallback. This is what turns a starving ability’s wait into ONE
scheduled retry instead of a 10 Hz poll of the actions queue.
Sourcepub fn missing_fraction(&self) -> f64
pub fn missing_fraction(&self) -> f64
Share of the pool that is currently missing, in [0, 1]. Feeds the
“Отдача” stone (damage scaling on missing mana).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ManaPool
impl<'de> Deserialize<'de> for ManaPool
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>,
Source§impl FromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
impl FromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
Source§impl IntoWasmAbi for ManaPool
impl IntoWasmAbi for ManaPool
Source§impl JsonSchema for ManaPool
impl JsonSchema for ManaPool
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl OptionFromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
impl OptionFromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
Source§impl OptionIntoWasmAbi for ManaPool
impl OptionIntoWasmAbi for ManaPool
Source§impl RefFromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
impl RefFromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
Source§type Abi = <JsType as RefFromWasmAbi>::Abi
type Abi = <JsType as RefFromWasmAbi>::Abi
Self are recovered from.Source§impl Tsify for ManaPool
impl Tsify for ManaPool
const DECL: &'static str = "/**\n * Fight-local mana of one combatant.\n *\n * Character combatants (hero, party ally, human PvP opponent) carry `Some`;\n * mobs carry `None` and are never mana-gated. The pool is refilled to `max` at\n * every fight start and is not carried between fights \u{2014} outside a fight there\n * is no mana at all, so nothing can spend it.\n *\n * `current` is a float because regen is a per-second rate applied on the\n * millisecond fight clock; `updated_tick` makes the accrual drift-free and\n * independent of the heartbeat cadence (see [`ManaPool::regen_to`]).\n */\nexport interface ManaPool {\n /**\n * Full pool size, from `mana_settings.pool`.\n */\n max: number;\n /**\n * Points available right now.\n */\n current: number;\n /**\n * Points restored per second of fight time, from `mana_settings.regen_per_second`.\n */\n regen_per_second: number;\n /**\n * Ticker unit the pool was last accrued at (1 unit = 1 ms).\n */\n updated_tick: number;\n}"
const SERIALIZATION_CONFIG: SerializationConfig
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
Source§impl VectorFromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
impl VectorFromWasmAbi for ManaPoolwhere
Self: DeserializeOwned,
type Abi = <JsType as VectorFromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>
Source§impl VectorIntoWasmAbi for ManaPool
impl VectorIntoWasmAbi for ManaPool
type Abi = <JsType as VectorIntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi
impl Copy for ManaPool
impl Eq for ManaPool
Auto Trait Implementations§
impl Freeze for ManaPool
impl RefUnwindSafe for ManaPool
impl Send for ManaPool
impl Sync for ManaPool
impl Unpin for ManaPool
impl UnwindSafe for ManaPool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.