Skip to main content

manabrew_engine/
game_object.rs

1use crate::card::Card;
2use crate::card_trait_base::CardTraitBase;
3use crate::ids::PlayerId;
4use crate::spellability::SpellAbility;
5
6pub trait GameObject {
7    fn can_be_targeted_by(&self, _sa: &SpellAbility) -> bool {
8        false
9    }
10
11    fn is_valid(
12        &self,
13        restrictions: &[String],
14        source_controller: PlayerId,
15        source: &Card,
16        spell_ability: &CardTraitBase,
17    ) -> bool {
18        for restriction in restrictions {
19            if self.is_valid_single(restriction, source_controller, source, spell_ability) {
20                return true;
21            }
22        }
23        false
24    }
25
26    fn is_valid_single(
27        &self,
28        _restriction: &str,
29        _source_controller: PlayerId,
30        _source: &Card,
31        _spell_ability: &CardTraitBase,
32    ) -> bool {
33        false
34    }
35
36    fn has_property(
37        &self,
38        _property: &str,
39        _source_controller: PlayerId,
40        _source: &Card,
41        _spell_ability: &CardTraitBase,
42    ) -> bool {
43        false
44    }
45}