magarena/grammar/mtg.peg

449 lines
7.0 KiB
Plaintext

MagicRule
= SpellEffect EOR
/ KeywordAbility EOR
/ StaticAbility EOR
/ ActivatedAbility EOR
;
SpellEffect
= Action EOS
;
Action
= DestroyNoRegenAction
/ DestroyAction
/ ExileAction
/ CounterAction
/ DamageAction
/ DrawAction
/ DiscardAction
/ TapAction
/ PreventAction
/ RegenerateAction
/ PumpAction
/ BounceAction
/ AddManaAction
/ ReturnAction
/ SacrificeAction
/ ChangeLifeAction
/ ChangeCounterAction
/ PutTokenAction
;
KeywordAbility
= Keyword
/ Enchant
;
StaticAbility
= EntersTapped
/ EntersWithCounter
/ EnchantedPump
/ EquippedPump
;
ActivatedAbility
= ActivationCosts ": " SpellEffect
;
Keyword
= "Flash"
/ "Flying"
/ "Haste"
/ "Defender"
/ "Vigilance"
/ "Reach"
/ "Trample"
/ "First strike"
/ "Double strike"
/ "Infect"
/ "Wither"
/ "Fear"
/ "Shadow"
/ "Storm"
/ "Swampwalk"
/ "Forestwalk"
/ "Islandwalk"
/ "Mountainwalk"
/ "Changeling"
/ "Deathtouch"
/ "Lifelink"
/ "Exalted"
/ "Shroud"
/ "Persist"
/ "Protection from black"
/ "Protection from red"
/ "Protection from white"
/ "Protection from blue"
/ "Protection from green"
/ "@ can't block."
/ "Hexproof"
/ "Soulbond"
/ "Undying"
/ "Flanking"
/ "Intimidate"
/ "Living weapon"
/ "Totem armor"
/ "Bushido" SPACE Number
/ "Modular" SPACE Number
/ "Vanishing" SPACE Number
/ "Bloodthirst" SPACE Number
/ "Buyback" SPACE ManaCost
/ "Kicker" SPACE ManaCost
/ "Equip" SPACE ManaCost
/ "Cumulative upkeep" SPACE ManaCost
/ "@ is unblockable."
/ "@ attacks each turn if able."
/ "@ is indestructible."
/ "@ can't be countered."
/ "Affinity for artifacts"
;
ActivationCosts
= ActivationCost ("," SPACE ActivationCost)*
;
SacrificeAction
= "Sacrifice " SelectPermanent
/ "Sacrifice @"
;
ActivationCost
= "{T}"
/ ManaCost
/ Action
/ "Pay " Number " life"
;
ColorlessCost
= "{" Number "}"
/ "{X}"
;
MonoSingleCost
= "{B}"
/ "{U}"
/ "{G}"
/ "{R}"
/ "{W}"
;
HybridSingleCost
= "{G/U}"
/ "{G/W}"
/ "{R/G}"
/ "{R/W}"
/ "{U/R}"
/ "{U/B}"
/ "{B/G}"
/ "{W/B}"
;
ManaCost
= ColorlessCost MonoSingleCost*
/ MonoSingleCost+
/ HybridSingleCost+
;
PutTokenAction
= "Put a 1/1 green Saproling creature token onto the battlefield"
;
ChangeCounterAction
= "Remove a " CounterType " counter from " SelectPermanent
/ "Remove " Count SPACE CounterType " counters from " SelectPermanent
/ "Put a " CounterType " counter on " SelectPermanent
/ "Put " Count SPACE CounterType " counters on " SelectPermanent
;
ChangeLifeAction
= "Target player loses " Number " life and you gain " Number " life"
/ "Target player loses " Number " life"
/ "Target player gains " Number " life"
;
ReturnAction
= "Return " SelectCard " from your graveyard to your hand"
/ "Return " SelectCard " from your graveyard to the battlefield"
;
BounceAction
= "Return " SelectPermanent SPACE "to its owner's hand"
;
PreventAction
= "Prevent the next " Number " damage that would be dealt to target creature or player this turn"
;
TapAction
= "Tap" SPACE SelectPermanent
/ "Untap" SPACE SelectPermanent
;
RegenerateAction
= "Regenerate @"
;
DamageAction
= "@ deals " Number " damage to target creature or player"
;
EntersTapped
= "@ enters the battlefield tapped."
;
EntersWithCounter
= "@ enters the battlefield with a " CounterType " counter on it."
/ "@ enters the battlefield with " Count SPACE CounterType " counters on it."
;
CounterType
= "+1/+1"
/ "-1/-1"
/ "+1/+0"
/ "charge"
/ "spore"
/ "storage"
;
Count
= "one"
/ "two"
/ "three"
/ "four"
/ "five"
/ "six"
/ "seven"
/ "eight"
/ "nine"
/ "ten"
/ "X"
;
Enchant
= "Enchant" SPACE RestrictedPermanent
/ "Enchant player"
;
EnchantedPump
= "Enchanted creature gets " SignedNumber "/" SignedNumber "."
;
EquippedPump
= "Equipped creature gets " SignedNumber "/" SignedNumber "."
;
PumpAction
= "@ gets " SignedNumber "/" SignedNumber " until end of turn"
;
AddManaAction
= "Add " ManaSource " to your mana pool"
;
ManaSource
= "{1}"
/ "{G}"
/ "{B}"
/ "{U}"
/ "{W}"
/ "{R}"
/ "one mana of any color"
;
DrawAction
= "Draw a card"
/ "Draw " Count " cards"
;
DiscardAction
= "Discard a card"
/ "Discard " Count " cards"
;
DestroyNoRegenAction
= Destroy SPACE SelectPermanent EOS SPACE NoRegen
;
DestroyAction
= Destroy SPACE SelectPermanent
;
ExileAction
= Exile SPACE SelectPermanent
;
CounterAction
= Counter SPACE SelectSpell
;
SelectOp
= "target"
/ "a"
;
SelectCard
= SelectOp SPACE RestrictedCard
;
SelectPermanent
= "@"
/ SelectOp SPACE RestrictedPermanentUnion
;
SelectSpell
= SelectOp SPACE RestrictedSpell
;
RestrictedPermanentUnion
= RestrictedPermanent ", " RestrictedPermanent ", or " RestrictedPermanent
/ RestrictedPermanent " or " RestrictedPermanent
/ RestrictedPermanent
;
RestrictedPermanent
= (PermanentRestriction SPACE)? Permanent (SPACE PermanentRestriction)?
/ RestrictedCreature
/ SelectArtifact
/ SelectEnchantment
/ SelectLand
/ SelectTribal
;
PermanentRestriction
= "black or red"
/ "noncreature"
/ "you control"
;
SelectArtifact
= Artifact
;
SelectEnchantment
= Enchantment
;
SelectLand
= Land
;
SelectTribal
= Tribal
;
RestrictedSpell
= (SpellRestriction SPACE)? Spell
;
SpellRestriction
= "creature"
/ "red or green"
/ "noncreature"
;
RestrictedCard
= (CardRestriction SPACE)? Card
;
CardRestriction
= "creature"
/ "artifact"
/ "instant or sorcery"
/ "instant"
/ "sorcery"
;
RestrictedCreature
= (CreatureRestriction SPACE)? Creature (SPACE CreatureRestriction)?
;
CreatureRestriction
= "with converted mana cost 3 or less"
/ "with power 4 or greater"
/ "with flying"
/ "tapped"
/ "blocked"
/ "nonblack"
/ "nonartifact, nonblack"
/ "attacking"
/ "green or white"
/ "Human"
/ "non-Vampire, non-Werewolf, non-Zombie"
/ "nonartifact"
/ "you control"
;
Tribal
= "Spirit"
;
Creature
= "creature"
;
Artifact
= "artifact"
;
Land
= "land"
;
Enchantment
= "enchantment"
;
Permanent
= "permanent"
;
Card
= "card"
;
Spell
= "spell"
;
NoRegen
= "It can't be regenerated"
;
Destroy
= "Destroy"
;
Exile
= "Exile"
;
Counter
= "Counter"
;
SignedNumber
= Sign Number
;
Number
= [0-9]+
;
Sign
= "+"
/ "-"
;
SPACE
= " "
;
EOS
= "."
;
EOR
= !_
;