boseiju/ability_tree/
tree_node.rs

1/// This enum lists all the possible nodes of the ability tree.
2///
3/// The goal of this enum is to distribute an unique identifier to all node kinds.
4/// The [`idris_derive::Idris`] implements the [`idris::Idris`] trait for this enum,
5/// providing a unique id for each variant, allowing to get that variant through this enum.
6///
7/// The id is distributed recursively to all variants that are unnamed with a single field.
8///
9/// Sometimes, it is desired to have an id for an enum node, but we also want to distribute ids
10/// to all variants of this node, since its the kind of node that carries enum only.
11///
12/// To do this, we create two variants, an IdMarker variant to give the node an id, and a variant
13/// that use the idris derive to recusrively add the nodes to all child variants.
14#[derive(idris_derive::Idris)]
15#[derive(Debug, Clone, PartialEq, Eq)]
16pub enum NodeKind {
17    /// A special "no node" kind.
18    ///
19    /// It's sometimes usefull to put "blank spaces" nodes when providing children.
20    /// Check the [`crate::ability_tree::AbilityTreeNode::children`] implementation of the
21    /// [`crate::ability_tree::object::SpecifierOrOfAndList`] for an example.
22    ///
23    /// The node is placed first so that idris will give him the symbolic id 0.
24    _EmptyNode,
25    /// The none node is another speical case of node, that does not mean that there is no node,
26    /// but rather that there could have been something, but instead the none variant is present.
27    _NoneNode,
28    Ability,
29    AbilityKind,
30    AbilityTree,
31    AbilityWordAbility,
32    ActivatedAbility,
33    CastSpecifier,
34    CharacteristicDefiningAbility,
35    ChooseImperative,
36    Colors,
37    Condition,
38    Conditional,
39    ConditionalIf,
40    ConditionalUnless,
41    ConditionalImperative,
42    ContinuousEffect,
43    ContinuousEffectKind,
44    ContinuousEffectModifyObject,
45    ContinuousEffectReplacementEvent,
46    ControlSpecifier,
47    Cost,
48    CostModification,
49    CostModificationCostMore,
50    CostModificationCostLess,
51    CostModificationCostSet,
52    CostModificationEffect,
53    CounterKind,
54    CounterOnPermanent, /* Fixme: better name for this one */
55    CounterOnPermanentReplacement,
56    CountSpecifierIdMarker,
57    CountSpecifier(crate::ability_tree::object::CountSpecifier),
58    CreateTokensEvent,
59    CreatureAction,
60    CreatureActionEvent,
61    CreatureAttacksAction,
62    CreatureDiesAction,
63    CreatureDealsCombatDamageAction,
64    DamagesDealt,
65    DealsDamageImperative,
66    DestroyImperative,
67    EffectEventSource,
68    EntersTheBattlefieldEvent,
69    Event,
70    EventReplacement,
71    EventSource,
72    EventSourceReferenceIdMarker,
73    EventSourceReference(crate::ability_tree::event::replacement::EventSourceReference),
74    ExileImperative,
75    ExileFollowUp,
76    ExileFollowUpReturn,
77    ExpandedKeywordAbilityIdMarker,
78    ExpandedKeywordAbility(crate::ability_tree::terminals::StandaloneKeywordAbility),
79    ConditionEventOccured,
80    ConditionObjectMatchSpecifier,
81    GainLifeImperative,
82    GenerateContinuousEffectImperative,
83    Imperative,
84    ImperativeList,
85    ImperativeChoices,
86    KeywordAbilityIdMarker,
87    KeywordAbility(KeywordAbilityNodeKind),
88    LifeGainedEvent,
89    ManaCost,
90    MayAbility,
91    MtgData(MtgDataNodeKind),
92    NumberIdMarker,
93    NumberOfResolutions(crate::ability_tree::conditional::NumberOfResolutions),
94    NumberOfResolutionsIdMarker,
95    Number(crate::ability_tree::number::Number),
96    ObjectAbilitiesModification,
97    ObjectCharacteristicModification,
98    ObjectGainAbility,
99    ObjectReference,
100    ObjectSpecifier,
101    ObjectSpecifiers,
102    OwnedZone,
103    PlayerAction,
104    PlayerActionEvent,
105    PlayerAttacksAction,
106    PlayerCastsSpellEvent,
107    PlayerEventSource,
108    PlayerSpecifier(crate::ability_tree::player::PlayerSpecifier),
109    PlayerSpecifierIdMarker,
110    PlayerSpecifierObjectController,
111    PlayerSpecifierObjectOwner,
112    PowerToughnessModifiers,
113    PowerToughnessModifiersMinusMinus,
114    PowerToughnessModifiersMinusPlus,
115    PowerToughnessModifiersPlusMinus,
116    PowerToughnessModifiersPlusPlus,
117    PowerToughnessModifiersSet,
118    PreviouslyMentionnedCounter,
119    PreviouslyMentionnedObject,
120    PreviouslyMentionnedToken,
121    PutCounterOnPermanentEvent,
122    PutCountersImperative,
123    RemovableCounterKind,
124    RemovableCounterOnPermanent,
125    ReplacableImperatives,
126    ReplacedTokenKind,
127    ReturnImperative,
128    SacrificeImperative,
129    SpecifiedObject,
130    SpecifierAndList,
131    SpecifierOrList,
132    SpecifierOrOfAndList,
133    SpellAbility,
134    Statement,
135    StaticAbility,
136    StaticAbilityKind,
137    Terminal(TerminalNodeKind),
138    ThisIsYourTurn,
139    TokenCreation,
140    TokenCreationReplacement,
141    TokenLayout,
142    TriggerCondition,
143    TriggeredAbility,
144    TypeLineIdMarker,
145    TypeLine(TypeLineNodeKind),
146    UnlessConditional,
147    ZoneReferenceIdMarker,
148    ZoneReference(crate::ability_tree::zone::ZoneReference),
149}
150
151#[derive(idris_derive::Idris)]
152#[derive(Debug, Clone, PartialEq, Eq)]
153pub enum MtgDataNodeKind {
154    AbilityWord(mtg_data::AbilityWord),
155    AbilityWordIdMarker,
156    ArtifactSubtypeIdMarker,
157    BattleSubtypeIdMarker,
158    CardIdMarker,
159    CardTypeIdMarker,
160    Color,
161    CreatureSubtypeIdMarker,
162    EnchantmentSubtypeIdMarker,
163    LandSubtypeIdMarker,
164    Mana(mtg_data::Mana),
165    ManaIdMarker,
166    ObjectKind(crate::ability_tree::object::ObjectKind),
167    ObjectKindIdMarker,
168    PermanentIdMarker,
169    PlaneswalkerSubtypeIdMarker,
170    SpellIdMarker,
171    SpellSubtypeIdMarker,
172    SupertypeIdMarker,
173}
174
175#[derive(idris_derive::Idris)]
176#[derive(Debug, Clone, PartialEq, Eq)]
177pub enum KeywordAbilityNodeKind {
178    Enchant,
179    Ward,
180}
181
182#[derive(idris_derive::Idris)]
183#[derive(Debug, Clone, PartialEq, Eq)]
184pub enum TerminalNodeKind {
185    AnotherObjectSpecifier,
186    CastSpecifierIdMarker,
187    BackwardDurationIdMarker,
188    BackwardDuration(crate::ability_tree::time::BackwardDuration),
189    ControlSpecifierIdMarker,
190    CounterIdMarker,
191    Counter(crate::ability_tree::terminals::CounterKind),
192    ForwardDurationIdMarker,
193    ForwardDuration(crate::ability_tree::time::ForwardDuration),
194    InstantIdMarker,
195    Instant(crate::ability_tree::time::Instant),
196    NamedTokenIdMarker,
197    NamedToken(crate::ability_tree::terminals::NamedToken),
198    NotPreviouslySelectedObjectSpecifier,
199    ObjectAttachedTo,
200    OrderIdMarker,
201    Order(crate::ability_tree::terminals::Order),
202    OwnerSpecifierIdMarker,
203    OwnerSpecifier(crate::ability_tree::terminals::OwnerSpecifier),
204    SelfReferencing,
205    OwnableZoneIdMarker,
206    OwnableZone(crate::ability_tree::zone::OwnableZone),
207}
208
209#[derive(idris_derive::Idris)]
210#[derive(Debug, Clone, PartialEq, Eq)]
211pub enum TypeLineNodeKind {
212    ArtifactSubtype,
213    BattleSubtype,
214    ConspiracySubtype,
215    CreatureSubtype,
216    DungeonSubtype,
217    EmblemSubtype,
218    EnchantmentSubtype,
219    HeroSubtype,
220    InstantSubtype,
221    KindredSubtype,
222    LandSubtype,
223    PhenomenonSubtype,
224    PlaneSubtype,
225    PlaneswalkerSubtype,
226    SchemeSubtype,
227    SorcerySubtype,
228    VanguardSubtype,
229}