New card
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
4 posts
• Page 1 of 1
New card
by Vasiliy » 18 Nov 2009, 21:55
Hello.
I am beginner Java programmer.
I write one card`s code.
Add to cards.txt

I hope my code is correct.
If this code is right, please add it to project.
I am beginner Java programmer.
I write one card`s code.
Add to cards.txt
- Code: Select all
Acolyte of Xathrid
B
Creature Human Cleric
no text
0/1
- Code: Select all
//*************** START *********** START **************************
else if(cardName.equals("Acolyte of Xathrid"))
{
final SpellAbility ability = new Ability_Tap(card, "1 B")
{
private static final long serialVersionUID = -560200331236516099L;
public void resolve()
{
String opponent = AllZone.GameAction.getOpponent(card.getController());
AllZone.GameAction.getPlayerLife(opponent).subtractLife(1);
}
public boolean canPlayAI()
{
//computer should play ability if this creature doesn't attack
Combat c = ComputerUtil.getAttackers();
CardList list = new CardList(c.getAttackers());
//could this creature attack?, if attacks, do not use ability
return (! list.contains(card));
}
};//SpellAbility
card.addSpellAbility(ability);
ability.setDescription("1 B, tap: Target player loses 1 life.");
ability.setStackDescription(card.getName() + " - Opponent loses 1 life.");
}//*************** END ************ END **************************

I hope my code is correct.
If this code is right, please add it to project.
Last edited by Vasiliy on 19 Nov 2009, 19:08, edited 2 times in total.
Sorry for my english. I speak english very bad.
- Vasiliy
- Programmer
- Posts: 47
- Joined: 15 Nov 2009, 12:26
- Has thanked: 0 time
- Been thanked: 0 time
Re: New card
by Vasiliy » 19 Nov 2009, 11:25
I write one card yet.
Add to cards.txt

Add to cards.txt
- Code: Select all
Thoughtcutter Agent
U B
Artifact Creature Human Rogue
no text
1/1
- Code: Select all
//*************** START *********** START **************************
else if(cardName.equals("Thoughtcutter Agent"))
{
final SpellAbility ability = new Ability_Tap(card, "U B")
{
private static final long serialVersionUID = -3880035465617987801L;
public void resolve()
{
String opponent = AllZone.GameAction.getOpponent(card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, opponent);
AllZone.GameAction.getPlayerLife(opponent).subtractLife(1);
Card[] handLook= hand.getCards();
if(opponent.equals(Constant.Player.Computer))
{
AllZone.Display.getChoice("Look", handLook);
}
}
public boolean canPlayAI()
{
//computer should play ability if this creature doesn't attack
Combat c = ComputerUtil.getAttackers();
CardList list = new CardList(c.getAttackers());
//could this creature attack?, if attacks, do not use ability
return (! list.contains(card));
}
};//SpellAbility
card.addSpellAbility(ability);
ability.setDescription("U B, tap: Target player loses 1 life and reveals his or her hand.");
ability.setStackDescription(card.getName() + " - Opponent loses 1 life.");
}//*************** END ************ END **************************

Last edited by Vasiliy on 19 Nov 2009, 15:24, edited 1 time in total.
Sorry for my english. I speak english very bad.
- Vasiliy
- Programmer
- Posts: 47
- Joined: 15 Nov 2009, 12:26
- Has thanked: 0 time
- Been thanked: 0 time
Re: New card
by Vasiliy » 19 Nov 2009, 15:17
I write one card yet.
Add to cards.txt

Add to cards.txt
- Code: Select all
Singe-Mind Ogre
2 B R
Creature Ogre Mutant
When Singe-Mind Ogre comes into play, target player reveals a card at random from his or her hand, then loses life equal to that card's converted mana cost.
3/2
- Code: Select all
//*************** START *********** START **************************
else if(cardName.equals("Singe-Mind Ogre"))
{
final SpellAbility ability = new Ability(card, "0")
{
public void resolve()
{
Card choice = null;
String opponent = AllZone.GameAction.getOpponent(card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, opponent);
Card[] handChoices = hand.getCards();
choice = CardUtil.getRandom(handChoices);
handChoices[0]=choice;
for (int i=1; i<handChoices.length; i++)
{
handChoices[i]=null;
}
AllZone.Display.getChoice("Random card", handChoices);
AllZone.GameAction.getPlayerLife(opponent).subtractLife(CardUtil.getConvertedManaCost(choice.getManaCost()));
}//resolve()
};
Command intoPlay = new Command()
{
private static final long serialVersionUID = -4833144157620224716L;
public void execute()
{
ability.setStackDescription("Singe-Mind Ogre - target player reveals a card at random from his or her hand, then loses life equal to that card's converted mana cost.");
AllZone.Stack.add(ability);
}
};
card.addComesIntoPlayCommand(intoPlay);
}//*************** END ************ END **************************

Sorry for my english. I speak english very bad.
- Vasiliy
- Programmer
- Posts: 47
- Joined: 15 Nov 2009, 12:26
- Has thanked: 0 time
- Been thanked: 0 time
Re: New card
by mtgrares » 19 Nov 2009, 21:00
Thanks for the new cards. (I have a hard time believing that people actually program MTG Forge. I don't really apologize for my bad code but I just feel self conscious. Of course I'm usually the one pointing at my own mistakes, ha.)
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 18 guests