weiss_core/state/choice.rs
1use serde::{Deserialize, Serialize};
2
3use crate::db::CardId;
4
5use super::{CardInstanceId, PendingTrigger};
6
7/// Reasons for prompting a choice.
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub enum ChoiceReason {
10 /// Choose a standby target from trigger effect.
11 TriggerStandbySelect,
12 /// Choose a treasure target from trigger effect.
13 TriggerTreasureSelect,
14 /// Choose whether to resolve a draw trigger (and/or its target).
15 TriggerDrawSelect,
16 /// Choose a target for a choice trigger.
17 TriggerChoiceSelect,
18 /// Choose targets for an auto ability cost step.
19 TriggerAutoCostSelect,
20 /// Choose whether to draw after a brainstorm effect.
21 BrainstormDrawSelect,
22 /// Choose an ordering for simultaneous stack items.
23 StackOrderSelect,
24 /// Choose an action during a priority window.
25 PriorityActionSelect,
26 /// Choose a payment option for a staged cost.
27 CostPayment,
28 /// Choose effect targets.
29 TargetSelect,
30 /// Choose cards to discard during end phase.
31 EndPhaseDiscard,
32}
33
34/// Cost payment step kinds.
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
36pub enum CostStepKind {
37 /// Rest another character.
38 RestOther,
39 /// Sacrifice a character from stage.
40 SacrificeFromStage,
41 /// Discard a card from hand.
42 DiscardFromHand,
43 /// Clock a card from hand.
44 ClockFromHand,
45 /// Clock the top card(s) of the deck.
46 ClockFromDeckTop,
47 /// Reveal a card from hand.
48 RevealFromHand,
49}
50
51/// Result to execute when staged cost payment finishes.
52#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
53pub enum CostPaymentOutcome {
54 /// Continue by resolving the originating ability.
55 #[default]
56 ResolveAbility,
57 /// Keep a character for encore by selecting the specified slot.
58 EncoreKeep {
59 /// Stage slot index being kept for encore.
60 slot: u8,
61 },
62}
63
64/// State for a multi-step cost payment.
65#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
66pub struct CostPaymentState {
67 /// Controlling player paying the cost.
68 pub controller: u8,
69 /// Source card id of the ability being paid for.
70 pub source_id: CardId,
71 /// Source card instance id (stable per-game).
72 pub source_instance_id: CardInstanceId,
73 /// Optional source slot when the source is on stage.
74 pub source_slot: Option<u8>,
75 /// Ability index on the source card.
76 pub ability_index: u8,
77 /// Remaining cost to pay.
78 pub remaining: crate::db::AbilityCost,
79 /// Currently active staged step, if any.
80 pub current_step: Option<CostStepKind>,
81 /// Outcome to execute once the cost is fully paid.
82 #[serde(default)]
83 pub outcome: CostPaymentOutcome,
84}
85
86/// Zones that choices can draw from.
87#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
88pub enum ChoiceZone {
89 /// Waiting room.
90 WaitingRoom,
91 /// Stage.
92 Stage,
93 /// Hand.
94 Hand,
95 /// Top of deck.
96 DeckTop,
97 /// Clock.
98 Clock,
99 /// Level zone.
100 Level,
101 /// Stock.
102 Stock,
103 /// Memory.
104 Memory,
105 /// Climax zone.
106 Climax,
107 /// Resolution zone.
108 Resolution,
109 /// Effect stack.
110 Stack,
111 /// Priority window: counter action.
112 PriorityCounter,
113 /// Priority window: ACT action.
114 PriorityAct,
115 /// Priority window: pass action.
116 PriorityPass,
117 /// Skip / decline an optional choice.
118 Skip,
119}
120
121/// Reference to a concrete choice option.
122#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
123pub struct ChoiceOptionRef {
124 /// Static card id for the referenced option.
125 pub card_id: CardId,
126 /// Stable per-game card instance id.
127 pub instance_id: CardInstanceId,
128 /// Zone the option is sourced from.
129 pub zone: ChoiceZone,
130 /// Optional index within the zone (for list-like zones).
131 pub index: Option<u16>,
132 /// Optional target slot index (for stage-based options).
133 pub target_slot: Option<u8>,
134}
135
136/// Choice prompt state for a player.
137#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
138pub struct ChoiceState {
139 /// Unique choice id.
140 pub id: u32,
141 /// Reason this choice is being requested.
142 pub reason: ChoiceReason,
143 /// Player seat making the choice.
144 pub player: u8,
145 /// Candidate options in the current page.
146 pub options: Vec<ChoiceOptionRef>,
147 /// Total candidates available across all pages.
148 pub total_candidates: u16,
149 /// Start offset of the current page.
150 pub page_start: u16,
151 /// Optional trigger associated with this choice (when choosing trigger order/targets).
152 pub pending_trigger: Option<PendingTrigger>,
153}