Re: Programming a card
If Dennis could explain me how he will fix the bug with the Lieges card , i'm found of explainations...
I've tried to code two other cards:
Grixis Battlemage:
Jund Battlemage:
I've tried to code two other cards:
Grixis Battlemage:
- Code: Select all
Grixis Battlemage
//*************** START *********** START **************************
if (cardName.equals("Grixis Battlemage")
{
final SpellAbility ability = new Ability_Tap(card, "U")
{
private static final long serialVersionUID = ;
public boolean canPlayAI() {return false;}
public void resolve()
{
AllZone.GameAction.drawCard(card.getController());
AllZone.InputControl.setInput(CardFactoryUtil.input_discard());
}
};//SpellAbility
card.addSpellAbility(ability);
ability.setDescription("U ,tap: Draw a card, then discard a card.");
ability.setStackDescription("Grixis Battlemage - draw a card, then discard a card.");
}//*************** END ************ END **************************
and in cards.txt
Grixis Battlemage
2 B
Creature Human Wizard
U, tap : draw a card then discard a card. R, tap: target creature can't block this turn.
2/2
TgtKpump R T: This creature cannot block
Jund Battlemage:
- Code: Select all
//*************** START *********** START **************************
if (cardName.equals("Jund Battlemage")
{
final SpellAbility ability = new Ability_Tap(card, "G")
{
private static final long serialVersionUID = ;
public void resolve()
{
Card c = new Card();
c.setName("Saproling");
c.setImageName("G 1 1 Saproling");
c.setOwner(card.getController());
c.setController(card.getController());
c.setManaCost("G");
c.setToken(true);
c.addType("Creature");
c.addType("Saproling");
c.setBaseAttack(1);
c.setBaseDefense(1);
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
play.add(c);
}//resolve()
};
final SpellAbility ability2 = new Ability_Tap(card, "B")
{
private static final long serialVersionUID = ;
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("G , tap: put a 1/1 green Saproling creature token onto battlefield);
ability.setStackDescription(card.getName() + " - Put a 1/1 green Saproling token onto the battlefield.");
ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
card.addSpellAbility(ability2);
ability2.setDescription("B, tap: Target player loses 1 life.");
ability2.setStackDescription(card.getName() + " - Opponent loses 1 life.");
}//*************** END ************ END **************************
in cards.txt:
Jund Battlemage
2 R
Creature Human Shaman
B, tap : target player loses 1 life. G, tap: put a 1/1 green Saproling creature token onto battlefield.
2/2