1use serde::{Deserialize, Serialize};
2
3use crate::db::CardId;
4use crate::state::TargetSpec;
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub enum EffectSourceKind {
9 Trigger,
11 Auto,
13 Activated,
15 Continuous,
17 EventPlay,
19 Counter,
21 Replacement,
23 System,
25}
26
27#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
29pub struct EffectId {
30 pub source_kind: EffectSourceKind,
32 pub source_card: CardId,
34 pub ability_index: u8,
36 pub effect_index: u8,
38}
39
40impl EffectId {
41 pub fn new(
43 source_kind: EffectSourceKind,
44 source_card: CardId,
45 ability_index: u8,
46 effect_index: u8,
47 ) -> Self {
48 Self {
49 source_kind,
50 source_card,
51 ability_index,
52 effect_index,
53 }
54 }
55}
56
57#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
59pub struct EffectSpec {
60 pub id: EffectId,
62 pub kind: super::EffectKind,
64 pub target: Option<TargetSpec>,
66 pub optional: bool,
68}