magarena/grammar/mtg.peg

366 lines
5.5 KiB
Plaintext

MagicRule
= SpellEffect EOR
/ KeywordAbility EOR
/ StaticAbility EOR
/ ActivatedAbility EOR
;
SpellEffect
= DestroyNoRegenAction
/ DestroyAction
/ ExileAction
/ CounterAction
/ DamageAction
/ DrawAction
/ TapAction
;
KeywordAbility
= Keyword
/ Enchant
;
StaticAbility
= EntersTapped
/ EnchantedPump
/ EquippedPump
;
ActivatedAbility
= AddManaActivation
/ PumpActivation
/ RegenerateActivation
/ PingActivation
/ TapActivation
/ DrawActivation
/ BounceActivation
;
Keyword
= "Flash"
/ "Flying"
/ "Haste"
/ "Defender"
/ "Vigilance"
/ "Reach"
/ "Trample"
/ "First strike"
/ "Double strike"
/ "Infect"
/ "Wither"
/ "Fear"
/ "Shadow"
/ "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"
/ "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 " SelectOp SPACE SelectPermanent
;
ActivationCost
= "{T}"
/ "Sacrifice @"
/ SacrificeAction
/ ManaCost
;
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+
;
BounceActivation
= ActivationCosts ": " BounceAction
;
BounceAction
= "Return " SelectOp SPACE SelectPermanent SPACE "to its owner's hand."
;
DrawActivation
= ActivationCosts ": " DrawAction
;
TapActivation
= ActivationCosts ": " TapAction
;
TapAction
= "Tap" SPACE SelectOp SPACE SelectPermanent EOS
;
RegenerateActivation
= ActivationCost ": Regenerate @."
;
PingActivation
= ActivationCost ": " DamageAction
;
DamageAction
= "@ deals " Number " damage to target creature or player."
;
EntersTapped
= "@ enters the battlefield tapped."
;
Enchant
= "Enchant" SPACE SelectPermanent
/ "Enchant player"
;
EnchantedPump
= "Enchanted creature gets " SignedNumber "/" SignedNumber "."
;
EquippedPump
= "Equipped creature gets " SignedNumber "/" SignedNumber "."
;
AddManaActivation
= ActivationCost ": " AddManaAction EOS
;
PumpActivation
= ActivationCost ": @ 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."
;
DestroyNoRegenAction
= Destroy SPACE SelectOp SPACE SelectPermanentUnion EOS SPACE NoRegen EOS
;
DestroyAction
= Destroy SPACE SelectOp SPACE SelectPermanentUnion EOS
;
ExileAction
= Exile SPACE SelectOp SPACE SelectPermanentUnion EOS
;
CounterAction
= Counter SPACE SelectOp SPACE SelectSpell EOS
;
SelectOp
= "target"
/ "a"
;
SelectPermanentUnion
= SelectPermanent ", " SelectPermanent ", or " SelectPermanent
/ SelectPermanent " or " SelectPermanent
/ SelectPermanent
;
SelectPermanent
= (PermanentRestriction SPACE)? Permanent
/ SelectCreature
/ SelectArtifact
/ SelectEnchantment
/ SelectLand
/ SelectTribal
;
SelectCreature
= (CreatureRestriction SPACE)? Creature (SPACE CreatureRestriction)?
;
SelectArtifact
= Artifact
;
SelectEnchantment
= Enchantment
;
SelectLand
= Land
;
SelectTribal
= Tribal
;
SelectSpell
= (SpellRestriction SPACE)? Spell
;
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"
;
SpellRestriction
= "creature"
/ "red or green"
/ "noncreature"
;
PermanentRestriction
= "black or red"
/ "noncreature"
;
Tribal
= "Spirit"
;
Creature
= "creature"
;
Artifact
= "artifact"
;
Land
= "land"
;
Enchantment
= "enchantment"
;
Permanent
= "permanent"
;
Spell
= "spell"
;
NoRegen
= "It can't be regenerated"
;
Destroy
= "Destroy"
;
Exile
= "Exile"
;
Counter
= "Counter"
;
SignedNumber
= Sign Number
;
Number
= [0-9]+
;
Sign
= "+"
/ "-"
;
SPACE
= " "
;
EOS
= "."
;
EOR
= !_
;