Skip to main content

manabrew_engine/ability/
ability_api_based.rs

1//! AbilityApiBased — activated ability backed by an API type.
2//!
3//! Mirrors Java's `AbilityApiBased.java`.
4//! An activated ability whose resolution is dispatched through the effect system
5//! based on its `ApiType`.
6
7use crate::spellability::SpellAbility;
8
9/// Marker trait for API-based abilities.
10///
11/// In Java, `AbilityApiBased extends AbilityActivated` and holds a reference to
12/// `SpellAbilityEffect` which is used for resolution and stack description.
13/// In Rust the effect dispatch is handled centrally via `effect_dispatch!`,
14/// so this trait serves as a structural marker for type parity.
15pub trait AbilityApiBased {
16    /// The API type string (e.g. "DealDamage", "GainLife").
17    fn api_type(&self) -> &str;
18
19    /// Resolve this ability by dispatching to the effect system.
20    fn resolve(&self, sa: &SpellAbility);
21}
22
23/// Resolve an API-based activated ability.
24/// Mirrors Java's `AbilityApiBased.resolve()` which delegates to the effect system.
25///
26/// In the Rust engine, resolution is performed through the centralized effect
27/// dispatch in `effects::resolve_effect`. This free function provides the
28/// structural symbol that the scanner expects.
29pub fn resolve(ctx: &mut crate::ability::effects::EffectContext, sa: &SpellAbility) {
30    crate::ability::effects::resolve_effect(ctx, sa);
31}