pub enum AmountSpec {
Literal(i32),
X,
Svar(String),
}Expand description
The amount slot of a CostPart. Replaces the legacy i32 (with
DYNAMIC_X_SENTINEL) once consumers are migrated. Mirrors Java’s
CostPart.convertAmount + AbilityUtils.calculateAmount split:
literals resolve trivially, X reads XPaid / SVar:X, named SVar
identifiers walk the host card’s SVar table at call time.
Variants§
Literal(i32)
X
Svar(String)
SVar name on the host card (e.g. Y in ExileFromHand<Y/Card.Blue>
— the only legitimate source today is the RaiseCost SVar walker
in cost_adjustment). Reserved for explicit, audited parser sites.
Implementations§
Source§impl AmountSpec
impl AmountSpec
Sourcepub fn parse_or(raw: &str, default: i32) -> Self
pub fn parse_or(raw: &str, default: i32) -> Self
Parse a script amount token ("3", "X"). Strips any trailing
/extra suffix so DSL forms like Draw<1/You> parse as 1. Non-int,
non-X tokens fall back to Literal(default) — Self::Svar is reserved
for explicit parsers that want SVar-chain resolution (only
cost_adjustment today).
Sourcepub fn resolve(&self, game: &GameState, source: CardId, player: PlayerId) -> i32
pub fn resolve(&self, game: &GameState, source: CardId, player: PlayerId) -> i32
Resolve to an i32 at call time. X reads XPaid/SVar:X via the
legacy resolve_dynamic_amount flow; Svar(name) walks the host’s
SVar chain to its first numeric value.
pub fn as_literal(&self) -> Option<i32>
pub fn is_x(&self) -> bool
Trait Implementations§
Source§impl Clone for AmountSpec
impl Clone for AmountSpec
Source§fn clone(&self) -> AmountSpec
fn clone(&self) -> AmountSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AmountSpec
impl Debug for AmountSpec
Source§impl Default for AmountSpec
impl Default for AmountSpec
Source§impl<'de> Deserialize<'de> for AmountSpec
impl<'de> Deserialize<'de> for AmountSpec
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 Display for AmountSpec
impl Display for AmountSpec
impl Eq for AmountSpec
Source§impl From<i32> for AmountSpec
impl From<i32> for AmountSpec
Source§impl PartialEq for AmountSpec
impl PartialEq for AmountSpec
Source§impl Serialize for AmountSpec
impl Serialize for AmountSpec
impl StructuralPartialEq for AmountSpec
Auto Trait Implementations§
impl Freeze for AmountSpec
impl RefUnwindSafe for AmountSpec
impl Send for AmountSpec
impl Sync for AmountSpec
impl Unpin for AmountSpec
impl UnsafeUnpin for AmountSpec
impl UnwindSafe for AmountSpec
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.