It is currently 12 Sep 2025, 06:41
   
Text Size

Programming a card

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Programming a card

Postby cyclope » 28 Sep 2009, 18:19

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 **************************
cyclope
 
Posts: 69
Joined: 28 Sep 2009, 18:08
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby DennisBergkamp » 28 Sep 2009, 20:45

Hello and welcome to the forums!
Yep, it looks like this code should work just fine. I'll add it it in!
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby DennisBergkamp » 28 Sep 2009, 20:58

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 ???
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby silly freak » 28 Sep 2009, 21:01

it's the same as with Spirit Link ;)
hint: it wouldn't matter if the card had "enchant creature you control"
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Programming a card

Postby DennisBergkamp » 28 Sep 2009, 21:03

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).
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby Rob Cashwalker » 29 Sep 2009, 03:25

With the recent changing of lifelink, they decided to revert many Oracle rules text to the original wording to preserve their functionality.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Programming a card

Postby Marek14 » 29 Sep 2009, 05:27

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.
Marek14
Tester
 
Posts: 2773
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 303 times

Re: Programming a card

Postby DennisBergkamp » 29 Sep 2009, 06:37

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?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby silly freak » 29 Sep 2009, 08:28

yes, that's it like. btw, is there already wither in forge? don't remember at all... if so, that would be the same
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Programming a card

Postby Marek14 » 29 Sep 2009, 09:28

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"? :)
Marek14
Tester
 
Posts: 2773
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 303 times

Re: Programming a card

Postby Rob Cashwalker » 29 Sep 2009, 14:49

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Programming a card

Postby silly freak » 29 Sep 2009, 15:33

IMO FAKE is great. probably depends on display size...
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Programming a card

Postby cyclope » 29 Sep 2009, 18:51

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...
cyclope
 
Posts: 69
Joined: 28 Sep 2009, 18:08
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby DennisBergkamp » 29 Sep 2009, 19:52

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).
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Programming a card

Postby silly freak » 30 Sep 2009, 08:06

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 ^^
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 17 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 17 guests

Login Form