boseiju/ability_tree/conditional/
this_is_your_turn.rs

1use crate::ability_tree::AbilityTreeNode;
2use crate::ability_tree::MAX_CHILDREN_PER_NODE;
3
4/// If condition for event that only applies during your turn.
5///
6/// This condition will mostly appear silently with sentences like "when X during your turn".
7#[derive(serde::Serialize, serde::Deserialize)]
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct ConditionThisIsYourTurn {
10    #[cfg(feature = "spanned_tree")]
11    pub span: crate::ability_tree::span::TreeSpan,
12}
13
14impl crate::ability_tree::AbilityTreeNode for ConditionThisIsYourTurn {
15    fn node_id(&self) -> usize {
16        use idris::Idris;
17        crate::ability_tree::NodeKind::ThisIsYourTurn.id()
18    }
19
20    fn children(&self) -> arrayvec::ArrayVec<&dyn AbilityTreeNode, MAX_CHILDREN_PER_NODE> {
21        arrayvec::ArrayVec::new()
22    }
23
24    fn display(&self, out: &mut crate::utils::TreeFormatter<'_>) -> std::io::Result<()> {
25        use std::io::Write;
26        write!(out, "this is your turn")
27    }
28
29    fn node_tag(&self) -> &'static str {
30        "condition: this is your turn"
31    }
32
33    #[cfg(feature = "spanned_tree")]
34    fn node_span(&self) -> crate::ability_tree::span::TreeSpan {
35        self.span
36    }
37}
38
39#[cfg(feature = "parser")]
40impl crate::utils::DummyInit for ConditionThisIsYourTurn {
41    fn dummy_init() -> Self {
42        Self {
43            #[cfg(feature = "spanned_tree")]
44            span: Default::default(),
45        }
46    }
47}