[card]
name=Phylactery Lich
abilities=indestructible
target=artifact|mybattlefield
auto=counter(0/0,1,Phylactery)
auto=aslongas(counter{0/0,1,Phylactery}|myBattlefield) all(this) sacrifice while <0
text=As Phylactery Lich enters the battlefield, put a Phylactery counter on an artifact you control. -- Phylactery Lich is indestructible. -- When you control no permanents with phylactery counters on them, sacrifice Phylactery Lich.
mana={B}{B}{B}
type=Creature
subtype=Zombie
power=5
toughness=5
[/card]
This coding works to an extent- you need to choose a target as you cast it, but the lich comes into play and works fine. Unfortunately, I just discovered a minute ago that this ties the creature to a specific counter- so if you play 2, each targeting different artifacts, and then sacrifice 1 artifact, 1 lich dies, which shouldn't happen. I can't seem to pinpoint why. The sacrifice code is really odd, but it seems to work perfectly with just one lich.
The version below is more faithful to the card, but it doesn't work- it adds the counter but sacrifices the creature before you get to choose where it goes. Help would be appreciated.
[card]
name=Phylactery Lich
abilities=indestructible
auto=counter(0/0,1,Phylactery) target(artifact|mybattlefield)
auto=aslongas(counter{0/0,1,Phylactery}|myBattlefield) all(this) sacrifice while <1
text=As Phylactery Lich enters the battlefield, put a Phylactery counter on an artifact you control. -- Phylactery Lich is indestructible. -- When you control no permanents with phylactery counters on them, sacrifice Phylactery Lich.
mana={B}{B}{B}
type=Creature
subtype=Zombie
power=5
toughness=5
[/card]
