# Important note:
# Macros are *global*, it doesn't matter where they are defined
# Macro names are case insensitive, and the replacement algorithm does an exact match inside a string
# it means that if you have a macro named MACRO and a macro named MACRO2, you'll run into trouble because MACRO2 will match MACRO
# Because of that, you need to use a unique delimiter at the beginning and the end of a macro, I personally use "__"
#
# Limitations: parameter inside macro must not contain ")"

# Standard Cycling
#AUTO_DEFINE __CYCLING__($cost) $cost{cycle}:name(cycling) draw:1

# Basic Landcycling
#AUTO_DEFINE __BASIC_LANDCYCLING__($cost) $cost{cycle}:name(basic landcycling) moveTo(myhand) target(land[basic]|mylibrary)

# Dies, Evergreen
#AUTO_DEFINE _DIES_ @movedTo(this|graveyard) from(battlefield):

# Populate
#AUTO_DEFINE _POPULATE_ name(Populate) clone notAtarget(creature[token]|myBattlefield)

# Ferocious
#AUTO_DEFINE _FEROCIOUS_ if type(creature[power>=4]|myBattlefield)~morethan~0 then

# Attacking
#AUTO_DEFINE _ATTACKING_ @combat(attacking) source(this):

# Blocked
#AUTO_DEFINE _BLOCKED_ @combat(blocked,turnlimited) source(this):

# Heroic
#AUTO_DEFINE _HEROIC_ @targeted(this) from(*[instant;sorcery;aura]|myCastingzone):

# Rally
#AUTO_DEFINE _RALLY_ @movedTo(other ally|myBattlefield):

# Landfall
#AUTO_DEFINE _LANDFALL_ @movedTo(land|myBattlefield):

# Addendum
#AUTO_DEFINE _ADDENDUM_ if compare(restriction{assorcery}~morethan~0) then

# Constellation
#AUTO_DEFINE _CONSTELLATION_ @movedTo(enchantment|myBattlefield):

# Amass, Set WAR
#AUTO_DEFINE _AMASS_($c) if type(army|mybattlefield)~morethan~0 then counter(1/1,$c) notATarget(army|myBattlefield) else create(Zombie Army:creature Zombie Army:0/0:black) and!(counter(1/1,$c) notATarget(army|myBattlefield))!

# Scry, Evergreen
#AUTO_DEFINE _SCRY_($c) scry:$c scrycore delayed dontshow donothing scrycoreend scryend

# Fabricate
#AUTO_DEFINE _FABRICATE_($c) transforms((,newability[choice counter(1/1.$c)],newability[choice create(Servo:Artifact Creature Servo:1/1)*$c])) ueot

# Enrage
#AUTO_DEFINE _ENRAGE_ @damaged(this):

# Whenever you draw your second card each turn
#AUTO_DEFINE _SECOND_DRAW_ @drawof(player) restriction{compare(pdrewcount)~equalto~2}:

# Battalion
#AUTO_DEFINE _BATTALION_ @combat(attacking) source(this) restriction{type(other creature[attacking]|myBattlefield)~morethan~1}:

# Champion
#AUTO_DEFINE _CHAMPION_($Word) aslongas(other $word|myBattlefield) choice notAtarget(other $word|myBattlefield) (blink)forsrc oneshot

# Metalcraft
#AUTO_DEFINE _METALCRAFT_ aslongas(artifact|mybattlefield) >2

# Echo
#AUTO_DEFINE _ECHO_($cost) $cost[{$c};next upkeep] sacrifice

# Threshold
#AUTO_DEFINE _THRESHOLD_ if type(*|mygraveyard)~morethan~6

# Splice onto Arcane
#AUTO_DEFINE _SPLICEARCANE_ movedTo(*[Arcane]|myStack):may castcard(copied noevent) target(*[Arcane]|myHand)

# Ripple
#AUTO_DEFINE _RIPPLE_($c) autostack=if casted(this) then reveal:$c optionone name(Cast Card) target(<upto:$c>[share!name!]|reveal) moveTo(mylibrary) and!( becomes(tobecast) ueot )! optiononeend optiontwo name(put on bottom) target(<$c>*|reveal) bottomoflibrary optiontwoend afterrevealed all(tobecast|mylibrary) moveTo(myLibrary) and!( activate castcard(normal) )! afterrevealedend revealend

# Recover                              
#AUTO_DEFINE _RECOVER_($cost) @movedTo(creature|myGraveyard) from(Battlefield):may pay{$cost} name(Return to owner Hand) moveTo(ownerHand) all(this) donothing?moveTo(exile) all(this)

# Clash
$AUTO_DEFINE _CLASH_ Put here a code if compare the casting cost based on Erratic Explosion. Meaby it would work with a few fix

# Conspire
#AUTO_DEFINE _CONSPIRE_ @movedTo(this|myStak):may {T(creature|myBattlefield)}{T(creature|myBattlefield)} castcard(copied noevent) target(*|myStack)

# Proliferate
#AUTO_DEFINE _PROLIFERATE_ name(Proliferate) notatarget(<anyamount>*[artifact;creature;enchantment;land;planeswalker;player]) duplicatecounters(single)

# Proliferate, still need to target players since the old code doesn't work (*[artifact;creature;...;players]) just let you target creature and player
#AUTO_DEFINE _OLDPROLIFERATE_ name(Proliferate) notAtarget(<anyamount>*[artifact;creature;enchantment;land;planeswalker;player]) propagate
#AUTO_DEFINE _OLDOLDPROLIFERATE_ name(proliferate) notatarget(<anyamount>*[artifact;creature;enchantment;land;planeswalker;player]) proliferate

# Scavenge
#AUTO_DEFINE _SCAVENGE_($cost) name(Scavenge) autograveyard={$cost}{E}:counter(1/1,$c) target(creature) asSorcery

# Monstrosity
#AUTO_DEFINE _MONSTROSITY_($cost) name(Monstrosity) this(cantargetcard(*[-monstrous]) {$cost}:becomes(monstrous) forever && counter(1/1,$c)

# Outlast
#AUTO_DEFINE _OUTLAST_($cost) {$cost}{$cost}:counter(1/1,1) all(this) asSorcery

# Investigate token, Shadows over Innistrad SOI
#AUTO_DEFINE _INVESTIGATE_ token(Clue)

# Soulshift
#AUTO_DEFINE _SOULSHIFT_($c) @movedTo(this|myGraveyard) from(battlefield):may moveTo(myHand) target(creature[spirit;manacost<=$c]|myGraveyard)

# Ascend, Set XLN
#AUTO_DEFINE _ASCEND_ if type(City's Blessing|mybattlefield)~lessthan~1 then transforms((,newability[if type(*|mybattlefield)~morethan~9 then token(City's Blessing^notrigger)])) oneshot

# Effect with the City's blessing, Set XLN
#AUTO_DEFINE _CITY'S_BLESSING_ aslongas(City's Blessing|mybattlefield)>0

# Monarch
#AUTO_DEFINE _MONARCH_CONTROLLER_ if type(The Monarch|battlefield)~lessthan~1 then token(The Monarch) else all(The Monarch|battlefield) moveto(mybattlefield) and!( transforms((,newability[becomesmonarch controller])) forever )!
#AUTO_DEFINE _MONARCH_OPPONENT_ if type(The Monarch|battlefield)~lessthan~1 then token(The Monarch) opponent else all(The Monarch|battlefield) moveto(opponentbattlefield) and!( transforms((,newability[becomesmonarch controller])) forever )! 

# Explore
#AUTO_DEFINE _EXPLORE_ reveal:1 optionone if type(land|reveal)~lessthan~1 then transforms((,newability[counter(1/1)])) optiononeend optiontwo if type(land|reveal)~morethan~0 then name(move to Hand) target(<1>*|reveal) moveto(myHand) else transforms((,newability[Choice name(back to library) target(<1>*|reveal) moveto(mylibrary)],newability[Choice name(put into Graveyard) target(<1>*|reveal) moveto(myGraveyard)])) optiontwoend revealend limit:1

# Treasure token, Set XLN
#AUTO_DEFINE _TREASURE_ token(Treasure Sur)

# Historic
#AUTO_DEFINE _HISTORIC_ notAtarget(*[artifact;saga;legendary]|myZones)

# Mentor, still not working with enhancements, pump effects
#AUTO_DEFINE _MENTOR_ @combat(attacking) source(this):counter(1/1,1) target(other creature[attacking;power<=pminus1minusend]|myBattlefield)

# Surveil
#AUTO_DEFINE _SURVEIL_ name(surveil) reveal:1 optionone name(put in graveyard) target(<upto:1>*|reveal) moveto(ownergraveyard) optiononeend optiontwo name(put in library) target(<1>*|reveal) moveto(ownerlibrary) optiontwoend revealend

# Undergrowth
#AUTO_DEFINE _UNDERGROWTH_ foreach(creature|myGraveyard)

# Adapt
#AUTO_DEFINE _ADAPT_($c) aslongas(this[counter{1/1}<1]|myBattlefield):counter(1/1,$c)

# Afterlife
#AUTO_DEFINE _AFTERLIFE_($c) @movedTo(this|graveyard) from(battlefield):create(Spirit:Creature Spirit:1/1:white,black:flying)*$c

# Riot
#AUTO_DEFINE _RIOT_ movedTo(this|myBattlefield):transforms((,newability[ability$! name(Choose counter or ability) choice name(Put a +1/+1 counter) counter(1/1,1) target(creature) _ choice name(Gains Haste) haste target(creature) forever !$ controller]))

# Spectacle
#AUTO_DEFINE _SPECTACLE_($cost) compare(oplifelost)~morethan~0 {$cost}:
