weiss_core/effects/replacement.rs
1use serde::{Deserialize, Serialize};
2
3use crate::db::CardId;
4use crate::state::TargetSide;
5
6use super::EffectId;
7
8/// Terminal outcome specified relative to the effect controller.
9#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
10pub enum TerminalOutcomeSpec {
11 /// Controller wins.
12 WinSelf,
13 /// Controller loses (opponent wins).
14 WinOpponent,
15 /// Game ends in draw.
16 Draw,
17 /// Game ends in timeout.
18 Timeout,
19}
20
21/// Turn-scoped rule-action override selectors.
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
23pub enum RuleOverrideKind {
24 /// Skip deck-empty refresh/loss processing in rule actions.
25 SkipDeckRefreshOrLoss,
26 /// Skip level-4 loss checks in rule actions.
27 SkipLevelFourLoss,
28 /// Skip non-character stage cleanup in rule actions.
29 SkipNonCharacterStageCleanup,
30 /// Skip non-positive-power stage cleanup in rule actions.
31 SkipZeroOrNegativePowerCleanup,
32}
33
34/// Hook point for replacement effects.
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
36pub enum ReplacementHook {
37 /// Damage resolution hook.
38 Damage,
39}
40
41/// Replacement behavior for a hook.
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
43pub enum ReplacementKind {
44 /// Cancel damage entirely.
45 CancelDamage,
46 /// Redirect damage to a new target.
47 RedirectDamage {
48 /// Target side to receive redirected damage.
49 new_target: TargetSide,
50 },
51}
52
53/// Replacement specification with priority ordering.
54#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
55pub struct ReplacementSpec {
56 /// Stable effect id.
57 pub id: EffectId,
58 /// Source card id.
59 pub source: CardId,
60 /// Hook point for the replacement.
61 pub hook: ReplacementHook,
62 /// Replacement behavior.
63 pub kind: ReplacementKind,
64 /// Priority ordering (higher first).
65 pub priority: i16,
66 /// Insertion order for stable sorting.
67 pub insertion: u32,
68}