1use serde::{Deserialize, Serialize};
2
3use crate::ids::{CardId, PlayerId};
4use crate::spellability::AlternativeCost;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
10pub enum GameEntity {
11 Player(PlayerId),
12 Card(CardId),
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
16pub struct PlayOption {
17 pub card_id: CardId,
18 pub mode: PlayCardMode,
19 #[serde(default)]
24 pub alt_cost_index: u8,
25}
26
27impl PlayOption {
28 pub fn normal(card_id: CardId) -> Self {
29 Self {
30 card_id,
31 mode: PlayCardMode::Normal,
32 alt_cost_index: 0,
33 }
34 }
35
36 pub fn with_mode(card_id: CardId, mode: PlayCardMode) -> Self {
37 Self {
38 card_id,
39 mode,
40 alt_cost_index: 0,
41 }
42 }
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
46pub enum PlayCardMode {
47 Normal,
48 BackFaceLand,
49 Adventure,
50 RoomRightSplit,
51 Alternative(AlternativeCost),
52 StaticAlternative,
54 ForetellExile,
55 UnlockDoor {
59 door: forge_foundation::CardStateName,
60 },
61}
62
63#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
65pub enum TargetChoice {
66 Player(PlayerId),
67 Card(CardId),
68 None,
69}
70
71#[derive(Debug, Clone, Copy, PartialEq, Eq)]
73pub enum MainPhaseAction {
74 Pass,
76 Play(PlayOption),
78 ActivateMana(CardId, Option<usize>, Option<u16>),
81 UntapMana(CardId),
83 ActivateAbility(CardId, usize),
85}
86
87#[derive(Debug, Clone)]
88pub struct ActivatableAction {
89 pub card_id: CardId,
90 pub ability_index: usize,
91 pub description: String,
92 pub cost: Option<String>,
93 pub is_mana_ability: bool,
94 pub is_class_level_up: bool,
95 pub is_level_up: bool,
96 pub produced_mana: Option<String>,
97 pub produced_mana_amount: Option<i32>,
98}
99
100#[derive(Debug, Clone, Default)]
101pub struct PriorityActionSpace {
102 pub playable: Vec<PlayOption>,
103 pub tappable_lands: Vec<CardId>,
105 pub untappable_lands: Vec<CardId>,
106 pub activatable: Vec<ActivatableAction>,
107 pub mana_abilities: Vec<ActivatableAction>,
108}
109
110impl PriorityActionSpace {
111 pub fn is_empty(&self) -> bool {
112 self.playable.is_empty()
113 && self.tappable_lands.is_empty()
114 && self.untappable_lands.is_empty()
115 && self.activatable.is_empty()
116 }
117}
118
119#[derive(Debug, Clone, Copy, PartialEq, Eq)]
121pub enum CombatCostAction {
122 TapLand {
124 card_id: CardId,
125 mana_ability_index: Option<usize>,
126 express_choice: Option<u16>,
127 },
128 UntapLand(CardId),
130 Pay,
132 Decline,
134}
135
136#[derive(Debug, Clone, Copy, PartialEq, Eq)]
138pub enum ManaCostAction {
139 TapForMana {
140 card_id: CardId,
141 mana_ability_index: Option<usize>,
142 express_choice: Option<u16>,
143 },
144 Untap(CardId),
145 Pay {
148 auto: bool,
149 },
150 AttemptedAndFailed,
152}
153
154#[derive(Debug, Clone, PartialEq, Eq)]
155pub struct ManaAbilityOption {
156 pub card_id: CardId,
157 pub ability_index: usize,
158 pub description: String,
159 pub cost: Option<String>,
160 pub produced_mana: Option<String>,
161 pub produced_mana_amount: Option<i32>,
162}
163
164#[derive(Debug, Clone, Copy, PartialEq, Eq)]
166pub enum BinaryChoiceKind {
167 HeadsOrTails,
168 TapOrUntap,
169 PlayOrDraw,
170 OddsOrEvens,
171 UntapOrLeaveTapped,
172 LeftOrRight,
173 AddOrRemove,
174 IncreaseOrDecrease,
175}
176
177impl BinaryChoiceKind {
178 pub fn labels(self) -> (&'static str, &'static str) {
180 match self {
181 BinaryChoiceKind::HeadsOrTails => ("Heads", "Tails"),
182 BinaryChoiceKind::TapOrUntap => ("Tap", "Untap"),
183 BinaryChoiceKind::PlayOrDraw => ("Play", "Draw"),
184 BinaryChoiceKind::OddsOrEvens => ("Odds", "Evens"),
185 BinaryChoiceKind::UntapOrLeaveTapped => ("Untap", "Leave tapped"),
186 BinaryChoiceKind::LeftOrRight => ("Left", "Right"),
187 BinaryChoiceKind::AddOrRemove => ("Add", "Remove"),
188 BinaryChoiceKind::IncreaseOrDecrease => ("Increase", "Decrease"),
189 }
190 }
191
192 pub fn as_str(self) -> &'static str {
193 match self {
194 BinaryChoiceKind::HeadsOrTails => "HeadsOrTails",
195 BinaryChoiceKind::TapOrUntap => "TapOrUntap",
196 BinaryChoiceKind::PlayOrDraw => "PlayOrDraw",
197 BinaryChoiceKind::OddsOrEvens => "OddsOrEvens",
198 BinaryChoiceKind::UntapOrLeaveTapped => "UntapOrLeaveTapped",
199 BinaryChoiceKind::LeftOrRight => "LeftOrRight",
200 BinaryChoiceKind::AddOrRemove => "AddOrRemove",
201 BinaryChoiceKind::IncreaseOrDecrease => "IncreaseOrDecrease",
202 }
203 }
204}
205
206#[derive(Debug, Clone, Copy, PartialEq, Eq)]
207pub enum RollSwapChoice {
208 Power,
209 Toughness,
210}