use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ruleset {
pub game: GameInfo,
pub players: PlayerRules,
pub zones: Vec<ZoneDef>,
pub resources: Vec<ResourceDef>,
pub turn: TurnStructure,
pub actions: Vec<ActionDef>,
pub stack: StackRules,
pub trigger_kinds: Vec<TriggerKind>,
pub keywords: Vec<Keyword>,
pub win_conditions: Vec<WinCondition>,
pub loss_conditions: Vec<LossCondition>,
#[serde(default)]
pub cards: Vec<CardDef>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GameInfo {
pub id: String,
pub name: String,
pub version: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlayerRules {
pub min_players: usize,
pub max_players: usize,
pub starting_life: i32,
pub max_life: i32,
pub starting_hand_size: usize,
pub max_hand_size: usize,
pub min_deck_size: usize,
pub max_deck_size: usize,
pub mulligan_rule: String,
pub first_player_rule: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ZoneDef {
pub id: String,
pub name: String,
pub owner_scope: ZoneOwnerScope,
pub visibility: ZoneVisibility,
pub ordered: bool,
pub allow_duplicates: bool,
pub default_capacity: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ZoneOwnerScope {
Player,
Shared,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ZoneVisibility {
Public,
Private,
TopCardPublic,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceDef {
pub id: String,
pub name: String,
pub description: String,
pub min_value: i32,
pub max_value: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TurnStructure {
pub priority_system: bool,
pub skip_first_turn_draw_for_first_player: bool,
pub phases: Vec<PhaseDef>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PhaseDef {
pub id: String,
pub name: String,
pub order: usize,
pub allow_actions: bool,
pub steps: Vec<StepDef>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StepDef {
pub id: String,
pub name: String,
pub order: usize,
pub allow_actions: bool,
pub allow_triggers: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActionDef {
pub id: String,
pub name: String,
pub description: String,
pub source_zones: Option<Vec<String>>,
pub target_zone: Option<String>,
pub speed: Option<String>,
#[serde(default)]
pub requires_empty_stack: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StackRules {
pub enabled: bool,
pub resolve_order: String,
pub auto_resolve_on_pass: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TriggerKind {
pub id: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Keyword {
pub id: String,
pub name: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WinCondition {
pub id: String,
pub description: String,
pub priority: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LossCondition {
pub id: String,
pub description: String,
pub priority: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CardDef {
pub id: String,
pub name: String,
pub card_type: String,
pub cost: Option<String>,
pub description: Option<String>,
#[serde(default)]
pub abilities: Vec<CardAbility>,
#[serde(default)]
pub script_path: Option<String>,
#[serde(default)]
pub keywords: Vec<String>,
#[serde(default)]
pub stats: std::collections::HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CardAbility {
pub trigger: String,
pub effect: String,
#[serde(default)]
pub params: std::collections::HashMap<String, String>,
}