# This is the basic rules for MTG.
# Do not add any "Draw X cards at startup" or "shuffle" here, as the story mode and the test suite rely on this
# file, and they usually don't expect the draw rule or shuffle to happen
# If you want shuffle or draw events, put them directly in your own rules file that includes this file, see clasic.txt for example 
hidden
[INIT]
mode=mtg

#MTG Game specific rules
auto=bonusrule
auto=putinplayrule
auto=kickerrule
auto=alternativecostrule
auto=buybackrule
auto=flashbackrule
auto=retracerule
auto=suspendrule
auto=morphrule
auto=payzerorule
auto=overloadrule
auto=attackrule
auto=attackcostrule
auto=blockrule
auto=blockcostrule
auto=combattriggerrule
auto=legendrule
auto=planeswalkerrule
auto=planeswalkerdamage
auto=planeswalkerattack
auto=tokencleanuprule
auto=persistrule
auto=vampirerule
auto=unearthrule
auto=lifelinkrule
auto=deathtouchrule
auto=soulbondrule
auto=dredgerule
auto=bestowrule

[PLAYERS]
life:20
offerinterruptonphase=draw
auto=ability$!all(*[isconspiracy]|mysideboard) transforms((,newability[may name(Put in commandzone) name(Put in commandzone) moveto(mycommandzone)])) onehot!$ controller

auto=sethand:7
auto=@each my draw:draw:1
auto=maxPlay(land)1

#Lands Mana Rules
auto=lord(Plains[-noactivatedability;-nomanaability;-notapability;land]|MyBattlefield) {T}:Add{W}
auto=lord(Island[-noactivatedability;-nomanaability;-notapability;land]|MyBattlefield) {T}:Add{U}
auto=lord(Swamp[-noactivatedability;-nomanaability;-notapability;land]|MyBattlefield) {T}:Add{B}
auto=lord(Mountain[-noactivatedability;-nomanaability;-notapability;land]|MyBattlefield) {T}:Add{R}
auto=lord(Forest[-noactivatedability;-nomanaability;-notapability;land]|MyBattlefield) {T}:Add{G}

#Mana Empties from manapool at the end of each phase
auto=@each untap:removeMana(*)
auto=@each upkeep:removeMana(*)
auto=@each draw:removeMana(*)
auto=@each firstmain:removeMana(*)
auto=@each combatbegins:removeMana(*)
auto=@each attackers:removeMana(*)
auto=@each blockers:removeMana(*)
auto=@each combatdamage:removeMana(*)
auto=@each combatEnds:removeMana(*)
auto=@each secondmain:removeMana(*)
auto=@each end:removeMana(*)
auto=@each cleanup:removeMana(*)

#Modal dual face card flip back rule
auto=@each untap restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each upkeep restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each draw restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each firstmain restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each combatbegins restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each attackers restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each blockers restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each combatdamage restriction{type(*[isflipped]|nonbattlezone))~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each combatEnds restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each secondmain restriction{type(*[isflipped]|nonbattlezone))~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each end restriction{compare(type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@each cleanup restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@movedto(other *|nonbattlezone) restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@movedto(other *|stack) restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller
auto=@movedto(other *|battlefield) restriction{type(*[isflipped]|nonbattlezone)~morethan~0}:ability$!all(*[isflipped]|nonbattlezone) doubleside()!$ controller

#reset Creature damage at the cleanup phase
auto=@each cleanup:all(*|myBattlefield) resetDamage

#Stun counter
auto=@untapped(*[counter{0/0.1.Stun}]|mybattlefield):name(Stunned creature can't untap) name(Stunned creature can't untap) all(trigger[to]) transforms((,newability[tap(noevent)],newability[counter(0/0.-1.Stun)])) oneshot
