Page 1 of 15

Programming a card

PostPosted: 28 Sep 2009, 18:19
by cyclope
Hello , i'm french and i'm very interested in your mtg forge game.
I want to add to the cards the enchant "armadillo cloak" but i don't know the java language...
so , after looking at card factory , i tried to write the code for this card...
Is my code correct or no ? could anyone help me?

//*************** START *********** START **************************
if(cardName.equals("Armadillo Cloak"))
{
final SpellAbility spell = new Spell(card)
{

private static final long serialVersionUID = 4227124619270545652L;
public boolean canPlayAI()
{
CardList list = new CardList(AllZone.Computer_Play.getCards());
list = list.getType("Creature");

if(list.isEmpty())
return false;

//else
CardListUtil.sortAttack(list);
CardListUtil.sortFlying(list);

setTargetCard(list.get(0));
return true;
}//canPlayAI()
public void resolve()
{
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
play.add(card);

Card c = getTargetCard();

if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c) )
{
card.enchantCard(c);
System.out.println("Enchanted: " +getTargetCard());
}
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);

Command onEnchant = new Command()
{

public void execute()
{
if (card.isEnchanting())
{
Card crd = card.getEnchanting().get(0);
crd.addExtrinsicKeyword("Trample");
crd.addExtrinsicKeyword("Lifelink");
crd.addSemiPermanentAttackBoost(2);
crd.addSemiPermanentDefenseBoost(2);
}
}//execute()
};//Command


Command onUnEnchant = new Command()
{


public void execute()
{
if (card.isEnchanting())
{
Card crd = card.getEnchanting().get(0);
crd.removeExtrinsicKeyword("Trample");

crd.removeExtrinsicKeyword("Lifelink");

crd.addSemiPermanentAttackBoost(-2);
crd.addSemiPermanentDefenseBoost(-2);
}

}//execute()
};//Command

Command onLeavesPlay = new Command()
{

public void execute()
{
if (card.isEnchanting())
{
Card crd = card.getEnchanting().get(0);
card.unEnchantCard(crd);
}
}
};

card.setEnchant(onEnchant);
card.setUnEnchant(onUnEnchant);
card.setLeavesPlay(onLeavesPlay);

spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
}//*************** END ************ END **************************

Re: Programming a card

PostPosted: 28 Sep 2009, 20:45
by DennisBergkamp
Hello and welcome to the forums!
Yep, it looks like this code should work just fine. I'll add it it in!

Re: Programming a card

PostPosted: 28 Sep 2009, 20:58
by DennisBergkamp
By the way, does anyone know if there's some reason Armadillo Cloak's text is:

"Enchant creature
Enchanted creature gets +2/+2 and has trample.
Whenever enchanted creature deals damage, you gain that much life."

Instead of :

"Enchant creature
Enchanted creature gets +2/+2 and has trample and lifelink." #-o ???

Re: Programming a card

PostPosted: 28 Sep 2009, 21:01
by silly freak
it's the same as with Spirit Link ;)
hint: it wouldn't matter if the card had "enchant creature you control"

Re: Programming a card

PostPosted: 28 Sep 2009, 21:03
by DennisBergkamp
Ahhh, that's right, I forgot about that :)
Which, I guess wouldn't make this a 100% correct implementation of this card (controller of the creature will gain the life).

Re: Programming a card

PostPosted: 29 Sep 2009, 03:25
by Rob Cashwalker
With the recent changing of lifelink, they decided to revert many Oracle rules text to the original wording to preserve their functionality.

Re: Programming a card

PostPosted: 29 Sep 2009, 05:27
by Marek14
Rob Cashwalker wrote:With the recent changing of lifelink, they decided to revert many Oracle rules text to the original wording to preserve their functionality.
Yes, but NOT Armadillo Cloak. That was never in Oracle with lifelink.

Speaking of lifelink, could it be added according to M10 rules now (simultaneous with damage, non-stacking)? The old code, of course, is still useful for older cards.

Re: Programming a card

PostPosted: 29 Sep 2009, 06:37
by DennisBergkamp
Hmm, I don't think lifelink "stacks" anymore in forge (I mean yes, it still does get put on the stack, but multiple instances will not do anything).
I'll see if I can change it according to the M10 rules. I guess this means it doesn't show up on the stack at all? And the lifegain happens exactly when damage happens?

Re: Programming a card

PostPosted: 29 Sep 2009, 08:28
by silly freak
yes, that's it like. btw, is there already wither in forge? don't remember at all... if so, that would be the same

Re: Programming a card

PostPosted: 29 Sep 2009, 09:28
by Marek14
silly freak wrote:yes, that's it like. btw, is there already wither in forge? don't remember at all... if so, that would be the same
Wither is there, but remember that you can have wither+lifelink (so the code mustn't be mutually exclusive).

Looking through the Visual Spoiler, there's not too many unimplementable cards in Zendikar. I think that the landfall cards, in particular, will make the random decks better.

I was wondering about Rite of Replication - how does Forge show token copies of cards now? I came with an idea of having a generic "token copy" image and overlay the card image with it. Perhaps a big red stamp reading "FAKE"? :)

Re: Programming a card

PostPosted: 29 Sep 2009, 14:49
by Rob Cashwalker
A copy of a card is just that, a copy. The only part of the rules that care about it being a token would be if something referenced a "non-token". Otherwise, they are supposed to be exact copies, card image and all. Sure, there could be some sort of marker to indicate it's a token, but I think "FAKE" isn't it.

Re: Programming a card

PostPosted: 29 Sep 2009, 15:33
by silly freak
IMO FAKE is great. probably depends on display size...

Re: Programming a card

PostPosted: 29 Sep 2009, 18:51
by cyclope
So , my code would be correct if it was "lifelink" but this don't have "lifelink"... so I can't had it to the implemented cards...

Re: Programming a card

PostPosted: 29 Sep 2009, 19:52
by DennisBergkamp
No, unless a lot of people object, I'll add it in...

There are only two cases in which it would be incorrect:
- If you cast this on a creature an opponent controls (99 out of a 100 times you wouldn't do this).
- If the enchanted creature gets stolen somehow (Control Magic, ...).

For now, I'll add it in... I will try and fix the small issues it has at some point in the future (in which case Spirit Link could be added too).

Re: Programming a card

PostPosted: 30 Sep 2009, 08:06
by silly freak
and a third case: two spirit links. this is still a triggered ability, which means it does stack
magic has more twists than one can think of ^^