Nemata, Grove Guardian

Mr Chaos requested this card awhile ago. As far as I know it works fine except for one minor thing: if you have a bunch of Saprolings, sacrifice one of them to give all your saps +1/+1, then create another Saproling during the same turn AFTER sacrificing a Saproling, the newly created Saproling will get -1/-1 at the end of the turn (and be destroyed).
As for the AI using the first (put token into play) ability, I just made it random (so sometimes he will play a card from his hand, sometimes he'll use his mana to put tokens into play). This is far from ideal.
In cards.txt:
As for the AI using the first (put token into play) ability, I just made it random (so sometimes he will play a card from his hand, sometimes he'll use his mana to put tokens into play). This is far from ideal.
In cards.txt:
- Code: Select all
Nemata, Grove Guardian
4 G G
Legendary Creature Treefolk
no text
4/5
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Nemata, Grove Guardian"))
{
final SpellAbility a1 = new Ability(card, "2 G")
{
public boolean canPlayAI()
{
return MyRandom.random.nextBoolean();
}
public void resolve()
{
makeToken();
}
void makeToken()
{
Card c = new Card();
c.setName("Saproling");
c.setOwner(card.getController());
c.setController(card.getController());
c.setManaCost("G");
c.setToken(true);
c.addType("Creature");
c.addType("Saproling");
c.setAttack(1);
c.setDefense(1);
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
play.add(c);
}//makeToken()
};//SpellAbility
final SpellAbility a2 = new Ability(card, "0")
{
final Command eot1 = new Command()
{
public void execute()
{
CardList saps = new CardList();
saps.addAll(AllZone.Human_Play.getCards());
saps.addAll(AllZone.Computer_Play.getCards());
saps = saps.getType("Saproling");
for (int i=0; i < saps.size(); i++)
{
Card sap = saps.get(i);
sap.setAttack(sap.getAttack() - 1);
sap.setDefense(sap.getDefense() - 1);
}
}
};
public void resolve()
{
//get all saprolings:
CardList saps = new CardList();
saps.addAll(AllZone.Human_Play.getCards());
saps.addAll(AllZone.Computer_Play.getCards());
saps = saps.getType("Saproling");
Card c = getTargetCard();
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner());
if(AllZone.GameAction.isCardInPlay(c))
{
//AllZone.getZone(c).remove(c);
AllZone.GameAction.sacrifice(c);
for (int i=0; i < saps.size(); i++)
{
Card sap = saps.get(i);
sap.setAttack(sap.getAttack() + 1);
sap.setDefense(sap.getDefense() + 1);
}
}
AllZone.EndOfTurn.addUntil(eot1);
}
public boolean canPlayAI()
{
return false;
}
};//SpellAbility
Input runtime = new Input()
{
public void showMessage()
{
CardList saps = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards());
saps = saps.getType("Saproling");
stopSetNext(CardFactoryUtil.input_targetSpecific(a2, saps, "Select a Saproling to sacrifice."));
}
};
a1.setDescription("2G: Put a 1/1 green Saproling creature token into play.");
a1.setStackDescription("Put a 1/1 Saproling into play.");
card.addSpellAbility(a1);
a1.setBeforePayMana(new Input_PayManaCost(a1));
card.addSpellAbility(a2);
a2.setDescription("Sacrifice a Saproling: Saproling creatures get +1/+1 until end of turn");
a2.setStackDescription("Saprolings get +1/+1 until end of turn.");
a2.setBeforePayMana(runtime);
}//*************** END ************ END **************************