{
  "title": "Magic: The Gathering Comprehensive Rules & Gameplay Mechanics Engine",
  "version": "CR-2026",
  "host": "https://avascry.com",
  "canonical_url": "https://avascry.com/rules.json",
  "markdown_url": "https://avascry.com/rules.md",
  "stack_and_priority": {
    "rule_references": ["CR 116", "CR 117"],
    "structure": "Last-In, First-Out (LIFO)",
    "priority_system": "The active player receives priority at the beginning of each step/phase (except Untap and Cleanup). A player must hold priority to cast spells, activate abilities, or take special actions.",
    "passing_priority": "A spell or ability on the stack resolves only when all players pass priority in succession without taking actions.",
    "apnap_order": "When multiple triggered abilities trigger simultaneously, they are placed on the stack in Active Player, Non-Active Player (APNAP) order. The active player puts their triggers on the stack first, followed by each other player in turn order. Non-active player triggers resolve first."
  },
  "continuous_layers": {
    "rule_reference": "CR 613",
    "description": "Continuous effects are evaluated strictly in order from Layer 1 through Layer 7.",
    "layers": [
      {
        "layer": 1,
        "rule": "CR 613.1a",
        "name": "Copy Effects",
        "description": "Modifies the copiable values of an object (e.g., Clone, mutate, face-down status)."
      },
      {
        "layer": 2,
        "rule": "CR 613.1b",
        "name": "Control-Changing Effects",
        "description": "Effects that change who controls a permanent (e.g., Act of Treason, Control Magic)."
      },
      {
        "layer": 3,
        "rule": "CR 613.1c",
        "name": "Text-Changing Effects",
        "description": "Effects that alter words or mana symbols on a card (e.g., Mind Bend, Sleight of Mind)."
      },
      {
        "layer": 4,
        "rule": "CR 613.1d",
        "name": "Type-Changing Effects",
        "description": "Effects that change types, subtypes, or supertypes (e.g., Blood Moon, Enchanted Evening, Dryad of the Ilysian Grove)."
      },
      {
        "layer": 5,
        "rule": "CR 613.1e",
        "name": "Color-Changing Effects",
        "description": "Effects that alter an object's color (e.g., Painter's Servant, Darkest Hour)."
      },
      {
        "layer": 6,
        "rule": "CR 613.1f",
        "name": "Ability-Granting & Ability-Removing Effects",
        "description": "Effects that add or remove abilities (e.g., Humility, Dress Down, Archetype of Courage)."
      },
      {
        "layer": 7,
        "rule": "CR 613.1g",
        "name": "Power and Toughness Modifications",
        "description": "Evaluated strictly in 5 distinct sublayers (7a through 7e).",
        "sublayers": [
          {"sublayer": "7a", "name": "Characteristic-Defining Abilities (CDA)", "examples": ["Tarmogoyf", "Lord of Extinction"]},
          {"sublayer": "7b", "name": "Base P/T Setting Effects", "examples": ["Humility (sets base to 1/1)", "Serendib Sorcerer"]},
          {"sublayer": "7c", "name": "Counters (+1/+1, -1/-1)", "examples": ["+1/+1 counters", "-1/-1 counters"]},
          {"sublayer": "7d", "name": "Static/Spell Modifiers", "examples": ["Giant Growth (+3/+3)", "Glorious Anthem (+1/+1)"]},
          {"sublayer": "7e", "name": "Power/Toughness Switching", "examples": ["Inside Out", "About Face"]}
        ]
      }
    ]
  },
  "replacement_effects_vs_triggers": {
    "replacement_effects": {
      "rule": "CR 614",
      "syntax": "Identified by 'If... instead', 'enters the battlefield with', or 'as [this] enters the battlefield'.",
      "stack_interaction": "Does NOT use the stack; modifies events instantaneously as they happen."
    },
    "triggered_abilities": {
      "rule": "CR 603",
      "syntax": "Identified by 'When', 'Whenever', or 'At'.",
      "stack_interaction": "Always uses the stack and can be responded to by all players."
    }
  },
  "state_based_actions": {
    "rule": "CR 704",
    "timing": "Checked automatically whenever any player would receive priority.",
    "actions": [
      "Creature with toughness <= 0 is put into its owner's graveyard (cannot be prevented by indestructible or regeneration).",
      "Creature with marked damage >= toughness is destroyed.",
      "The Legend Rule (CR 704.5j): If a player controls 2+ legendary permanents with identical names, one is kept and the rest go to graveyard.",
      "Player with 10+ poison counters loses the game.",
      "Player attempting to draw from an empty library loses the game.",
      "Pairs of +1/+1 and -1/-1 counters on the same permanent annihilate each other until only one type remains."
    ]
  },
  "keyword_interactions": {
    "deathtouch_trample": "An attacking creature with deathtouch and trample only needs to assign 1 damage to each blocker as lethal damage; all remaining damage tramples over to defending player/planeswalker.",
    "double_strike_trample": "If all blockers are destroyed during first-strike damage step, the attacker assigns all regular combat damage directly to the defending player.",
    "ward": "A triggered ability triggering upon being targeted by an opponent; counters the spell/ability unless the ward cost is paid upon trigger resolution.",
    "protection_debt": "Cannot be Damaged, Enchanted/Equipped, Blocked, or Targeted by sources of the protected quality."
  },
  "historical_errata": [
    {
      "name": "Companion Rule Errata",
      "date": "2020-06",
      "change": "A player may pay {3} at sorcery speed to put their companion from outside the game into their hand before casting."
    },
    {
      "name": "Planeswalker Redirection Rule Removal",
      "date": "2018-04",
      "change": "Noncombat damage no longer redirects to planeswalkers; spells explicitly specify 'any target' or 'target player or planeswalker'."
    },
    {
      "name": "Dies Trigger Definition",
      "change": "'Dies' means 'is put into a graveyard from the battlefield'. Tokens do die and trigger death abilities before ceasing to exist as an SBA."
    },
    {
      "name": "Phasing Mechanics",
      "rule": "CR 702.26",
      "change": "Phasing out does NOT trigger leaves-the-battlefield abilities; phased-out permanents phase in during untap with all attached Auras/Equipment intact."
    }
  ]
}
