Programming a card
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Programming a card
by Triadasoul » 01 Dec 2009, 21:36
Thank you for your code. It seems to work. Here it isDennisBergkamp wrote:As for the duplicate detection, you probably have to do some hack like this:
Spawning Pool:
- Code: Select all
cardfactory_lands.java:
//*************** START *********** START **************************
else if(cardName.equals("Spawning Pool"))
{
final Command untilEOT = new Command()
{
private static final long serialVersionUID = -451839437837081897L;
public void execute()
{
card.setShield(0);
}
};
final SpellAbility a2 = new Ability(card, "B")
{
public boolean canPlayAI() {return false;}
public void resolve()
{
card.addShield();
AllZone.EndOfTurn.addUntil(untilEOT);
}
};//SpellAbility
a2.setDescription("B: Regenerate Spawning Pool.");
a2.setStackDescription("Regenerate Spawning Pool");
a2.setBeforePayMana(new Input_PayManaCost(a2));
final Command eot1 = new Command()
{
private static final long serialVersionUID = -8535770979347971863L;
public void execute()
{
Card c = card;
c.setBaseAttack(0);
c.setBaseDefense(0);
c.removeType("Creature");
c.removeType("Skeleton");
c.setManaCost("");
c.removeSpellAbility(a2);
}
};
final SpellAbility a1 = new Ability(card, "1 B")
{
public boolean canPlayAI()
{
return ! card.getType().contains("Creature");
}
public void resolve()
{
Card c = card;
c.setBaseAttack(1);
c.setBaseDefense(1);
c.setManaCost("B");
//to prevent like duplication like "Creature Creature"
boolean hasRegen = false;
SpellAbility[] sas = card.getSpellAbility();
for (SpellAbility sa : sas)
{
if(sa.toString().equals("B: Regenerate Spawning Pool.")) //this is essentially ".getDescription()"
hasRegen = true;
}
if (!hasRegen){ card.addSpellAbility(a2);
}
if(!c.getType().contains("Creature"))
c.addType("Creature");
if(!c.getType().contains("Skeleton"))
c.addType("Skeleton");
AllZone.EndOfTurn.addUntil(eot1);
}
};//SpellAbility
card.clearSpellKeepManaAbility();
card.addSpellAbility(a1);
a1.setStackDescription(card +" becomes a 1/1 skeleton creature with B: regenerate this creature until EOT");
a1.setDescription("1B: Spawning Pool becomes a 1/1 skeleton creature with B: regenerate this creature until end of the turn. It's still a land.");
Command paid1 = new Command() {
private static final long serialVersionUID = -6800983290478844750L;
public void execute() {AllZone.Stack.add(a1);}
};
a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
}//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Spawning Pool
no cost
Land
no text
Comes into play tapped.
tap: add B
===============================================================================================================
Cards-pictures.txt
spawning_pool.jpg http://www.wizards.com/global/images/magic/general/spawning_pool.jpg
- Code: Select all
cardfactory_lands:
//*************** START *********** START **************************
else if(cardName.equals("Shizo, Death's Storehouse"))
{
final SpellAbility[] a2 = new SpellAbility[1];
final Command eot2 = new Command()
{
private static final long serialVersionUID = 6180724472470740160L;
public void execute()
{
Card c = a2[0].getTargetCard();
if(AllZone.GameAction.isCardInPlay(c))
{
c.removeIntrinsicKeyword("Fear");
}
}
};
a2[0] = new Ability_Tap(card, "B")
{
private static final long serialVersionUID = 3561450520225198222L;
public boolean canPlayAI()
{
return getAttacker() != null;
}
public void chooseTargetAI()
{
setTargetCard(getAttacker());
}
public Card getAttacker()
{
//target creature that is going to attack
Combat c = ComputerUtil.getAttackers();
CardList att = new CardList(c.getAttackers());
att.remove(card);
att.shuffle();
if(att.size() != 0)
return att.get(0);
else
return null;
}//getAttacker()
public void resolve()
{
Card c = a2[0].getTargetCard();
if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,c) )
{
if(!c.getIntrinsicKeyword().contains("Fear"))
c.addIntrinsicKeyword("Fear");
AllZone.EndOfTurn.addUntil(eot2);
}
}//resolve()
};//SpellAbility
card.addSpellAbility(a2[0]);
a2[0].setDescription("B, tap: Target legendary creature gains fear until end of turn.");
@SuppressWarnings("unused") // target unused
final Input target = new Input()
{
private static final long serialVersionUID = 8913477363141356082L;
public void showMessage()
{
ButtonUtil.enableOnlyCancel();
AllZone.Display.showMessage("Select egendary creature to get fear");
}
public void selectCard(Card c, PlayerZone zone)
{
if(!CardFactoryUtil.canTarget(card, c)){
AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
}
else if(c.isCreature() && c.getType().contains("Legendary"))
{
card.tap();
AllZone.Human_Play.updateObservers();
a2[0].setTargetCard(c);//since setTargetCard() changes stack description
a2[0].setStackDescription(c +" gets fear until EOT");
AllZone.InputControl.resetInput();
AllZone.Stack.add(a2[0]);
}
}//selectCard()
public void selectButtonCancel()
{
card.untap();
stop();
}
};//Input target
a2[0].setBeforePayMana(CardFactoryUtil.input_targetType(a2[0], "Legendary"));
}//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Shizo, Death's Storehouse
no cost
Legendary Land
no text
tap: add B
===============================================================================================================
Cards-pictures.txt:
Shizo_Deaths_Storehouse.jpg http://www.wizards.com/global/images/magic/general/Shizo_Deaths_Storehouse.jpg

- Code: Select all
cardfactory_creatures:
//*************** START *********** START **************************
else if(cardName.equals("Assembly-Worker"))
{
final SpellAbility[] a2 = new SpellAbility[1];
final Command eot2 = new Command()
{
private static final long serialVersionUID = 6180724472470740160L;
public void execute()
{
Card c = a2[0].getTargetCard();
if(AllZone.GameAction.isCardInPlay(c))
{
c.addTempAttackBoost(-1);
c.addTempDefenseBoost(-1);
}
}
};
a2[0] = new Ability_Tap(card)
{
private static final long serialVersionUID = 3561450525225198222L;
public boolean canPlayAI()
{
return getAttacker() != null;
}
public void chooseTargetAI()
{
setTargetCard(getAttacker());
}
public Card getAttacker()
{
//target creature that is going to attack
Combat c = ComputerUtil.getAttackers();
CardList att = new CardList(c.getAttackers());
att.remove(card);
att.shuffle();
if(att.size() != 0)
return att.get(0);
else
return null;
}//getAttacker()
public void resolve()
{
Card c = a2[0].getTargetCard();
if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card,c) )
{
c.addTempAttackBoost(1);
c.addTempDefenseBoost(1);
AllZone.EndOfTurn.addUntil(eot2);
}
}//resolve()
};//SpellAbility
card.addSpellAbility(a2[0]);
a2[0].setDescription("tap: Target Assembly-Worker creature gets +1/+1 until end of turn.");
@SuppressWarnings("unused") // target unused
final Input target = new Input()
{
private static final long serialVersionUID = 8913477363141356082L;
public void showMessage()
{
ButtonUtil.enableOnlyCancel();
AllZone.Display.showMessage("Select Assembly-Worker to get +1/+1");
}
public void selectCard(Card c, PlayerZone zone)
{
if(!CardFactoryUtil.canTarget(card, c)){
AllZone.Display.showMessage("Cannot target this card (Shroud? Protection?).");
}
else if(c.isCreature() && c.getType().contains("Assembly-Worker"))
{
card.tap();
AllZone.Human_Play.updateObservers();
a2[0].setTargetCard(c);//since setTargetCard() changes stack description
a2[0].setStackDescription(c +" gets +1/+1 until EOT");
AllZone.InputControl.resetInput();
AllZone.Stack.add(a2[0]);
}
}//selectCard()
public void selectButtonCancel()
{
card.untap();
stop();
}
};//Input target
a2[0].setBeforePayMana(CardFactoryUtil.input_targetType(a2[0], "Assembly-Worker"));
}//*************** END ************ END **************************
===============================================================================================================
Cards.txt:
Assembly-Worker
3
Artifact Creature Assembly-Worker
no text
2/2
===============================================================================================================
Cards-pictures.txt:
assembly_worker.jpg http://www.wizards.com/global/images/magic/general/assembly_worker.jpg
- Code: Select all
cardfactory_lands:
//*************** START *********** START **************************
if(cardName.equals("Novijen, Heart of Progress"))
{
card.clearSpellKeepManaAbility();
final CardListFilter targets = new CardListFilter()
{
public boolean addCard(Card c) {
return AllZone.GameAction.isCardInPlay(c) && c.isCreature()
&& c.getTurnInZone() == AllZone.Phase.getTurn();
}
};
Ability_Tap ability = new Ability_Tap(card,"G U")
{
/**
*
*/
private static final long serialVersionUID = 1416258136308898492L;
CardList inPlay = new CardList();
public boolean canPlayAI()
{
if(!(AllZone.Phase.getPhase().equals(Constant.Phase.Main1)
&& AllZone.Phase.getActivePlayer().equals(Constant.Player.Computer)))
return false;
inPlay.clear();
inPlay.addAll(AllZone.Computer_Play.getCards());
return (inPlay.filter(targets).size() > 1);
}
public void resolve() {
inPlay.clear();
inPlay.addAll(AllZone.Human_Play.getCards());
inPlay.addAll(AllZone.Computer_Play.getCards());
for(Card targ : inPlay.filter(targets))
targ.addCounter(Counters.P1P1, 1);
}
};
ability.setDescription("tap: Put a +1/+1 counter on each creature that entered the battlefield this turn.");
ability.setStackDescription("Put a +1/+1 counter on each creature that entered the battlefield this turn.");
card.addSpellAbility(ability);
}
//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Novijen, Heart of Progress
no cost
Land
no text
tap: add 1
===============================================================================================================
Cards-pictures.txt:
novijen_heart_of_progress.jpg http://www.wizards.com/global/images/magic/general/novijen_heart_of_progress.jpg
- Code: Select all
cardfactory:
//*************** START *********** START **************************
if (cardName.equals("Glimpse the Unthinkable") || cardName.equals("Tome Scour"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 0;
if (cardName.equals("Glimpse the Unthinkable")) max = 10; else max = 5;
if (libList.size() < max)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Glimpse the Unthinkable
U B
Sorcery
Target player puts the top ten cards of his or her library into his or her graveyard.
Tome Scour
U
Sorcery
Target player puts the top five cards of his or her library into his or her graveyard.
===============================================================================================================
Cards-pictures.txt:
glimpse_the_unthinkable.jpg http://www.wizards.com/global/images/magic/general/glimpse_the_unthinkable.jpg
tome_scour.jpg http://www.wizards.com/global/images/magic/general/tome_scour.jpg
- Code: Select all
cardfactory:
//*************** START *********** START **************************
else if (cardName.equals("Millstone"))
{
Ability_Tap ab1 = new Ability_Tap(card, "2")
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 2;
if (libList.size() < 2)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};
ab1.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
ab1.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ab1));
ab1.setDescription("2, tap: Target player puts the top two cards of his or her library into his or her graveyard.");
card.addSpellAbility(ab1);
}//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Millstone
2
Artifact
no text
===============================================================================================================
Cards-pictures.txt:
millstone.jpg http://www.wizards.com/global/images/magic/general/millstone.jpg
- Code: Select all
gameactionutil
public static Command Lhurgoyf = new Command()
{
private static final long serialVersionUID = -8778902687347191964L;
public void execute()
{
// get all creatures
CardList list = new CardList();
list.addAll(AllZone.Human_Play.getCards());
list.addAll(AllZone.Computer_Play.getCards());
list = list.getName("Lhurgoyf");
for (int i = 0; i < list.size(); i++)
{
Card c = list.get(i);
c.setBaseAttack(countCreatures());
c.setBaseDefense(c.getBaseAttack()+1);
}
}
private int countCreatures()
{
PlayerZone compGrave = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Computer);
PlayerZone humGrave = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Human);
CardList list = new CardList();
list.addAll(compGrave.getCards());
list.addAll(humGrave.getCards());
list = list.filter(new CardListFilter(){
public boolean addCard(Card c) {
return c.isCreature();
}
});
return list.size();
}
};//Lhurgoyf
commands.put("Lhurgoyf", Lhurgoyf);
===============================================================================================================
statebasedeffects:
cardToEffectsList.put("Lhurgoyf", new String[] {"Lhurgoyf"});
===============================================================================================================
cards.txt:
Lhurgoyf
2 G G
Creature Lhurgoyf
Lhurgoyf's power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1.
0/1
===============================================================================================================
Cards-pictures.txt:
Lhurgoyf.jpg http://www.wizards.com/global/images/magic/general/Lhurgoyf.jpg
- Code: Select all
cardfactory:
//*************** START *********** START **************************
else if(cardName.equals("Path to Exile"))
{
SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 4752934806606319269L;
public void resolve()
{
if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
{
//add life
String player = getTargetCard().getController();
// PlayerLife life = AllZone.GameAction.getPlayerLife(player);
// life.addLife(getTargetCard().getNetAttack());
PlayerZone lib = AllZone.getZone(Constant.Zone.Library,
player);
CardList lands = new CardList(lib.getCards());
lands = lands.getType("Basic");
if (player.equals("Human") && lands.size() > 0)
{
String[] choices =
{ "Yes", "No" };
Object choice = AllZone.Display.getChoice(
"Search fo Basic Land?", choices);
if (choice.equals("Yes"))
{
Object o = AllZone.Display
.getChoiceOptional(
"Pick a basic land card to put into play",
lands.toArray());
if (o != null)
{
Card card = (Card) o;
lib.remove(card);
AllZone.Human_Play.add(card);
card.tap();
lands.remove(card);
AllZone.GameAction.shuffle(player);
}
}// if choice yes
} // player equals human
else if (player.equals("Computer") && lands.size() > 0)
{
Card card = lands.get(0);
lib.remove(card);
// hand.add(card);
AllZone.Computer_Play.add(card);
card.tap();
lands.remove(card);
AllZone.GameAction.shuffle(player);
}
//remove card from play
AllZone.GameAction.removeFromGame(getTargetCard());
}
}//resolve()
public boolean canPlayAI()
{
CardList creature = new CardList(AllZone.Human_Play.getCards());
creature = creature.getType("Creature");
creature = creature.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return CardFactoryUtil.canTarget(card,c);
}
});
return creature.size() != 0 && (AllZone.Phase.getTurn() > 4);
}
public void chooseTargetAI()
{
CardList play = new CardList(AllZone.Human_Play.getCards());
Card target = CardFactoryUtil.AI_getBestCreature(play, card);
setTargetCard(target);
}
};
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Path to Exile
W
Instant
Exile target creature. Its controller may search his or her library for a basic land card, put that card onto the battlefield tapped, then shuffle his or her library.
===============================================================================================================
Cards-pictures.txt:
path_to_exile.jpg http://www.wizards.com/global/images/magic/general/path_to_exile.jpg
- Code: Select all
cardfactory_creatures:
//*************** START *********** START **************************
else if(cardName.equals("Wood Elves"))
{
final SpellAbility ability = new Ability(card, "0")
{
public void resolve()
{
Card c = card;
String player = c.getController();
//PlayerLife life = AllZone.GameAction.getPlayerLife(c.getController());
//life.addLife(2);
PlayerZone lib = AllZone.getZone(Constant.Zone.Library,
player);
CardList lands = new CardList(lib.getCards());
lands = lands.getType("Forest");
if (player.equals("Human") && lands.size() > 0)
{
Object o = AllZone.Display
.getChoiceOptional(
"Pick a forest card to put into play",
lands.toArray());
if (o != null)
{
Card card = (Card) o;
lib.remove(card);
AllZone.Human_Play.add(card);
// card.tap();
lands.remove(card);
AllZone.GameAction.shuffle(player);
}
} // player equals human
else if (player.equals("Computer") && lands.size() > 0)
{
Card card = lands.get(0);
lib.remove(card);
// hand.add(card);
AllZone.Computer_Play.add(card);
// card.tap();
lands.remove(card);
AllZone.GameAction.shuffle(player);
}
}
};
Command intoPlay = new Command()
{
private static final long serialVersionUID = 1832932499373431651L;
public void execute()
{
ability.setStackDescription(card.getController() +" searches his library for a Forest card to put that card into play.");
AllZone.Stack.add(ability);
}
};
card.addComesIntoPlayCommand(intoPlay);
}//*************** END ************ END **************************
===============================================================================================================
cards.txt:
Wood Elves
2 G
Creature Elf Scout
When Wood Elves comes into play, search your library for a Forest card and put that card into play. Then shuffle your library.
1/1
===============================================================================================================
Cards-pictures.txt:
wood_elves.jpg http://www.wizards.com/global/images/magic/general/wood_elves.jpg
- Code: Select all
//*************** START *********** START **************************
if (cardName.equals("Traumatize"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = libList.size()/2 ;
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
===============================================================================================================
Cards.txt:
Traumatize
3 U U
Sorcery
Target player puts the top half of his or her library, rounded down, into his or her graveyard.
===============================================================================================================
Cards-pictures.txt:
traumatize.jpg http://www.wizards.com/global/images/magic/general/traumatize.jpg
- Code: Select all
cardfactory:
//*************** START *********** START **************************
if (cardName.equals("Mind Funeral"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = libList.size();
int prev = 0 ;
int count = 0;
int total =0;
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
if (c.getType().contains("Land"))
{
count= count + 1;
if (count == 4 && prev==0) total=i;
if (count == 4) prev=1;
}
}
for (int i=0;i<total+1;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
===============================================================================================================
Cards.txt:
Mind Funeral
1 U B
Sorcery
Target opponent reveals cards from the top of his or her library until four land cards are revealed. That player puts all cards revealed this way into his or her graveyard.
===============================================================================================================
Cards-pictures.txt:
mind_funeral.jpg http://www.wizards.com/global/images/magic/general/mind_funeral.jpg
PPS: How can i add player choice to Hedron Crab landfall ability (AI choose target player correctly) ?
- Code: Select all
private static void landfall_Hedron_Crab(Card c)
{
//final Card crd = c;
Ability ability = new Ability(c, "0")
{
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 3;
if (libList.size() < 3)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};
ability.setStackDescription(c.getName() + " - Landfall: " + c.getController() + " puts the top three cards of his or her library into his or her graveyard.");
ability.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability));
if (c.getController().equals(Constant.Player.Human)) {
if (showLandfallDialog(c))
AllZone.Stack.add(ability);
}
else if (c.getController().equals(Constant.Player.Computer))
AllZone.Stack.add(ability);
}//landfall_Hedron_Crab
Last edited by Triadasoul on 03 Dec 2009, 21:30, edited 4 times in total.
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by Triadasoul » 02 Dec 2009, 17:26
For some reason it updates exiled cards total with the last exiled card only next turn. What code should i add to update it the same turn?
Haunting Echoes:
Haunting Echoes:
- Code: Select all
cardfactory:
//*************** START *********** START **************************
if (cardName.equals("Haunting Echoes"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
PlayerZone exiled = AllZone.getZone(Constant.Zone.Removed_From_Play, player);
CardList libList = new CardList(lib.getCards());
CardList grvList = new CardList(grave.getCards());
int max = libList.size();
int grv = grvList.size();
for (int j=0;j < grv;j++)
{
Card g = grvList.get(j);
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
if ( c.getName().equals(g.getName()) && ! g.getType().contains("Basic") )
{ lib.remove(c);
exiled.add(c);
}
}
if ( ! g.getType().contains("Basic") ) {grave.remove(g);
exiled.add(g);}
}
}
};//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
=======================================================================================
cards.txt:
Haunting Echoes
3 B B
Sorcery
Remove all cards in target player's graveyard other than basic land cards from the game. Search that player's library for all cards with the same name as cards removed this way, and remove them from the game. Then that player shuffles his or her library.
=======================================================================================
card-pictures.txt:
haunting_echoes.jpg http://www.wizards.com/global/images/magic/general/haunting_echoes.jpg
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by DennisBergkamp » 02 Dec 2009, 20:27
Nice, Wood Elves only fetches Forests though (not basic lands) 
The Exiled cards counter not updating as often as it should is a known bug, I'm not sure why it happens exactly, but I haven't looked into it much... probably something doesn't get updated in updateObservers()?
Anyway, now that we have so many mill cards (and especially Traumatize / Haunting Echoes, I guess I have no excuses anymore, we need milling as a win/loss condition.I will add it into the next beta

The Exiled cards counter not updating as often as it should is a known bug, I'm not sure why it happens exactly, but I haven't looked into it much... probably something doesn't get updated in updateObservers()?
Anyway, now that we have so many mill cards (and especially Traumatize / Haunting Echoes, I guess I have no excuses anymore, we need milling as a win/loss condition.I will add it into the next beta

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Programming a card
by DennisBergkamp » 02 Dec 2009, 20:53
Hm, I got Hedron Crab working like this:
The cool thing is that inputs are stacked (might be because of Zerker's recent update?), if you have 4 of them in play, you should be able to target a player four separate times.
- Code: Select all
private static void landfall_Hedron_Crab(Card c)
{
//final Card crd = c;
final Ability ability = new Ability(c, "0")
{
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 3;
if (libList.size() < 3)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};
//ability.setStackDescription(c.getName() + " - Landfall: " + c.getController() + " puts the top three cards of his or her library into his or her graveyard.");
ability.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability));
if (c.getController().equals(Constant.Player.Human)) {
AllZone.InputControl.setInput(CardFactoryUtil.input_targetPlayer(ability));
//AllZone.Stack.add(ability);
}
else if (c.getController().equals(Constant.Player.Computer))
AllZone.Stack.add(ability);
}//landfall_Hedron_Crab
The cool thing is that inputs are stacked (might be because of Zerker's recent update?), if you have 4 of them in play, you should be able to target a player four separate times.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Programming a card
by Triadasoul » 02 Dec 2009, 21:12
Thank you for your help with Hedron Crab. I've corrected Wood Elves code up there. Here's another one
Lobotomy:
Lobotomy:
- Code: Select all
cardfactory:
//*************** START *********** START **************************
else if(cardName.equals("Lobotomy"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 5338238621454661783L;
public void resolve()
{
Card choice = null;
//check for no cards in hand on resolve
String player = getTargetPlayer();
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
PlayerZone exiled = AllZone.getZone(Constant.Zone.Removed_From_Play, player);
CardList libList = new CardList(lib.getCards());
CardList grvList = new CardList(grave.getCards());
CardList fullHand = new CardList(hand.getCards());
Card[] handChoices = removeLand(hand.getCards());
if (fullHand.size() > 0 && card.getController().equals(Constant.Player.Human))
AllZone.Display.getChoice("Revealing hand", fullHand.toArray());
if(card.getController().equals(Constant.Player.Human))
{
choice = (Card) AllZone.Display.getChoice("Choose", handChoices);
}
else//computer chooses
{
choice = CardUtil.getRandom(handChoices);
}
String chosen = choice.getName();
int max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
if ( c.getName().equals(chosen))
{ lib.remove(c);
exiled.add(c);
}
}
int grv = grvList.size();
for (int i=0;i<grv;i++)
{
Card c = grvList.get(i);
if ( c.getName().equals(chosen))
{ grave.remove(c);
exiled.add(c);
}
}
int hnd = fullHand.size();
for (int i=0;i<hnd;i++)
{
Card c = fullHand.get(i);
if ( c.getName().equals(chosen))
{ hand.remove(c);
exiled.add(c);
}
}
}//resolve()
public boolean canPlayAI()
{
Card[] c = removeLand(AllZone.Human_Hand.getCards());
return 0 < c.length;
}
Card[] removeLand(Card[] in)
{
CardList c = new CardList(in);
c = c.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return !c.getType().contains("Basic");
}
});
return c.toArray();
}//removeLand()
};//SpellAbility spell
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
}//*************** END ************ END **************************
==============================================================================================
cards.txt:
Lobotomy
2 U B
Sorcery
Target player reveals his or her hand, then you choose a card other than a basic land card from it. Search that player's graveyard, hand, and library for all cards with the same name as the chosen card and remove them from the game. Then that player shuffles his or her library.
==============================================================================================
cards-pictures.txt
lobotomy.jpg http://www.wizards.com/global/images/magic/general/lobotomy.jpg
Last edited by Triadasoul on 03 Dec 2009, 14:01, edited 1 time in total.
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by Triadasoul » 02 Dec 2009, 21:41
Identity Crisis:
- Code: Select all
//*************** START *********** START **************************
if (cardName.equals("Identity Crisis"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
PlayerZone exiled = AllZone.getZone(Constant.Zone.Removed_From_Play, player);
CardList handList = new CardList(hand.getCards());
CardList graveList = new CardList(grave.getCards());
int max = handList.size() ;
for (int i=0;i<max;i++)
{
Card c = handList.get(i);
hand.remove(c);
exiled.add(c);
}
int grv = graveList.size() ;
for (int i=0;i<grv;i++)
{
Card c = graveList.get(i);
grave.remove(c);
exiled.add(c);
}
}
};//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
==============================================================================================
cards.txt
Identity Crisis
2 W W B B
Sorcery
Exile all cards from target player’s hand and graveyard.
==============================================================================================
cards-pictures.txt
identity_crisis.jpg http://www.wizards.com/global/images/magic/general/identity_crisis.jpg
- Code: Select all
gameactionutil
upkeep_Moroii();
private static void upkeep_Moroii()
{
final String player = AllZone.Phase.getActivePlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
CardList list = new CardList();
list.addAll(play.getCards());
list = list.getName("Moroii");
for (int i = 0; i < list.size(); i++) {
AllZone.GameAction.getPlayerLife(player).subtractLife(1);
}
}// upkeep_Moroii
==============================================================================================
cards.txt
Moroii
2 U B
Creature Vampire
At the beginning of your upkeep, you lose 1 life.
4/4
FLying
==============================================================================================
cards-pictures.txt
moroii.jpg http://www.wizards.com/global/images/magic/general/moroii.jpg
- Code: Select all
cardfactory_lands
//*************** START *********** START **************************
if(cardName.equals("Duskmantle, House of Shadow"))
{
card.clearSpellKeepManaAbility();
Ability_Tap ability = new Ability_Tap(card,"U B")
{
private static final long serialVersionUID = 42470566751344693L;
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 1;
if (libList.size() < 1)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
};
ability.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability));
ability.setDescription("tap U B: Target player puts the top card of his or her library into his or her graveyard.");
ability.setStackDescription("Target player puts the top card of his or her library into his or her graveyard.");
card.addSpellAbility(ability);
}
//*************** END ************ END **************************
==============================================================================================
cards.txt:
Duskmantle, House of Shadow
no cost
Land
no text
tap: add 1
==============================================================================================
cards-pictures.txt
Duskmantle_House_of_Shadow.jpg http://www.wizards.com/global/images/magic/general/Duskmantle_House_of_Shadow.jpg
- Code: Select all
else if(c.getName().equals("Nemesis of Reason") && !c.getCreatureAttackedThisTurn())
{
String player = AllZone.GameAction.getOpponent(c.getController());
//if (c.getController().equals(Constant.Player.Human))
//player="Human";
//else if (c.getController().equals(Constant.Player.Computer))
//player="Computer";
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 10;
if (libList.size() < 10)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c1 = libList.get(i);
lib.remove(c1);
grave.add(c1);
}
}//Nemesis of Reason
==============================================================================================
cards.txt
Nemesis of Reason
3 U B
Creature Leviathan Horror
Whenever Nemesis of Reason attacks, defending player puts the top ten cards of his or her library into his or her graveyard.
3/7
==============================================================================================
cards-pictures.txt
nemesis_of_reason.jpg http://www.wizards.com/global/images/magic/general/nemesis_of_reason.jpg
- Code: Select all
GameActionUtil
upkeep_Vampire_Lacerator();
private static void upkeep_Vampire_Lacerator()
{
final String player = AllZone.Phase.getActivePlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
CardList list = new CardList();
list.addAll(play.getCards());
list = list.getName("Vampire Lacerator");
for (int i = 0; i < list.size(); i++) {
if (player == "Human" && AllZone.Computer_Life.getLife() > 10)
{AllZone.GameAction.getPlayerLife(player).subtractLife(1);}
else{ if (player == "Computer" && AllZone.Computer_Life.getLife() > 10)
{AllZone.GameAction.getPlayerLife(player).subtractLife(1);}}
}
}// upkeep_Vampire_Lacerator
==============================================================================================
cards.txt
Vampire Lacerator
B
Creature Vampire Warrior
At the beginning of your upkeep, you lose 1 life unless an opponent has 10 or less life.
2/2
==============================================================================================
cards-pictures.txt
http://www.wizards.com/global/images/magic/general/vampire_lacerator.jpg
- Code: Select all
gameactionutil:
else if (c.getName().equals("Raven Guild Master"))
playerCombatDamage_Raven_Guild_Master(c);
private static void playerCombatDamage_Raven_Guild_Master(Card c)
{
final String player = c.getController();
final String opponent = AllZone.GameAction.getOpponent(player);
if (c.getNetAttack() > 0)
{
Ability ability = new Ability(c, "0")
{
public void resolve()
{
AllZone.GameAction.discardRandom(opponent);
////////////
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, opponent);
PlayerZone exiled = AllZone.getZone(Constant.Zone.Removed_From_Play, opponent);
CardList libList = new CardList(lib.getCards());
int max = 10;
if (libList.size() < 10)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
exiled.add(c);
}
}
};// ability
ability.setStackDescription("Raven Guild Master - " + opponent
+ " removes the top ten cards of his or her library from the game");
AllZone.Stack.add(ability);
}
}
==============================================================================================
cards.txt:
Raven Guild Master
1 U U
Creature Wizard Mutant
Whenever Raven Guild Master deals combat damage to a player, that player removes the top ten cards of his or her library from the game.
1/1
Morph:2 U U
==============================================================================================
cards-pictures.txt:
raven_guild_master.jpg http://www.wizards.com/global/images/magic/general/raven_guild_master.jpg
- Code: Select all
cardfactory_creatures:
//*************** START *********** START **************************
else if(cardName.equals("Ambassador Laquatus"))
{
final SpellAbility a1 = new Ability(card, "3")
{
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 3;
if (libList.size() < 3)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
};//SpellAbility
card.addSpellAbility(a1);
a1.setDescription("3: Target player puts the top three cards of his or her library into his or her graveyard.");
a1.setStackDescription("Player puts the top three cards of his or her library into his or her graveyard");
a1.setBeforePayMana(new Input_PayManaCost(a1));
a1.setBeforePayMana(CardFactoryUtil.input_targetPlayer(a1));
}//*************** END ************ END **************************
==============================================================================================
cards.txt:
Ambassador Laquatus
1 U U
Legendary Creature Merfolk Wizard
no text
1/3
==============================================================================================
cards-pictures.txt:
Ambassador_Laquatus.jpg http://www.wizards.com/global/images/magic/general/Ambassador_Laquatus.jpg
- Code: Select all
cardfactory_creatures:
//*************** START *********** START **************************
else if(cardName.equals("Vedalken Entrancer"))
{
final SpellAbility a1 = new Ability_Tap(card, "U")
{
public void resolve()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 2;
if (libList.size() < 2)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
public boolean canPlayAI()
{
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList libList = new CardList(lib.getCards());
return libList.size() > 0;
}
};//SpellAbility
card.addSpellAbility(a1);
a1.setDescription("U, tap: Target player puts the top two cards of his or her library into his or her graveyard.");
a1.setStackDescription("Player puts the top two cards of his or her library into his or her graveyard");
a1.setBeforePayMana(new Input_PayManaCost(a1));
a1.setBeforePayMana(CardFactoryUtil.input_targetPlayer(a1));
}//*************** END ************ END **************************
==============================================================================================
cards.txt:
Vedalken Entrancer
3 U
Creature Vedalken Wizard
no text
1/4
==============================================================================================
cards-pictures.txt:
vedalken_entrancer.jpg http://www.wizards.com/global/images/magic/general/vedalken_entrancer.jpg
- Code: Select all
GameactionUtil
playCard_Forced_Fruition(c);
public static void playCard_Forced_Fruition(Card c)
{
PlayerZone hplay = AllZone.getZone(Constant.Zone.Play,
Constant.Player.Human);
PlayerZone cplay = AllZone.getZone(Constant.Zone.Play,
Constant.Player.Computer);
CardList list = new CardList();
list.addAll(hplay.getCards());
list.addAll(cplay.getCards());
list = list.getName("Forced Fruition");
for (int i = 0; i < list.size(); i++)
{
final Card card = list.get(i);
final String drawer = AllZone.GameAction.getOpponent(card
.getController());
Ability ability2 = new Ability(card, "0")
{
public void resolve()
{
AllZone.GameAction.drawCard(drawer);
AllZone.GameAction.drawCard(drawer);
AllZone.GameAction.drawCard(drawer);
AllZone.GameAction.drawCard(drawer);
AllZone.GameAction.drawCard(drawer);
AllZone.GameAction.drawCard(drawer);
AllZone.GameAction.drawCard(drawer);
}
}; // ability2
if (!(card.getController() == c.getController())) {
ability2.setStackDescription(card.getName() + " - "
+ c.getController() + " played a spell, " + drawer
+ " draws seven cards.");
AllZone.Stack.add(ability2);
}
}
}
==============================================================================================
cards.txt
Forced Fruition
4 U U
Enchantment
Whenever an opponent casts a spell, that player draws seven cards.
==============================================================================================
cards-pictures.txt:
Forced_Fruition.jpg http://www.wizards.com/global/images/magic/general/Forced_Fruition.jpg
- Code: Select all
GameactionUtil
playCard_Memory_Erosion(c);
public static void playCard_Memory_Erosion(Card c)
{
PlayerZone hplay = AllZone.getZone(Constant.Zone.Play,
Constant.Player.Human);
PlayerZone cplay = AllZone.getZone(Constant.Zone.Play,
Constant.Player.Computer);
CardList list = new CardList();
list.addAll(hplay.getCards());
list.addAll(cplay.getCards());
list = list.getName("Memory Erosion");
for (int i = 0; i < list.size(); i++)
{
final Card card = list.get(i);
final String drawer = AllZone.GameAction.getOpponent(card
.getController());
Ability ability2 = new Ability(card, "0")
{
public void resolve()
{
// sac standstill
// AllZone.GameAction.sacrifice(card);
// player who didn't play spell, draws 3 cards
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, drawer);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, drawer);
CardList libList = new CardList(lib.getCards());
int max = 2;
if (libList.size() < 2)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}
}; // ability2
if (!(card.getController() == c.getController())) {
ability2.setStackDescription(card.getName() + " - "
+ c.getController() + " played a spell, " + drawer
+ " puts the top two cards of his or her library into his or her graveyard.");
AllZone.Stack.add(ability2);
}
}
}
==============================================================================================
cards.txt
Memory Erosion
1 U U
Enchantment
Whenever an opponent casts a spell, that player puts the top two cards of his or her library into his or her graveyard.
==============================================================================================
cards-pictures.txt:
memory_erosion.jpg http://www.wizards.com/global/images/magic/general/memory_erosion.jpg
Last edited by Triadasoul on 03 Dec 2009, 21:43, edited 7 times in total.
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by Triadasoul » 03 Dec 2009, 11:34
I've tried to implement Carnophage but realize that we have upkeep step at the end of opponent's turn so it's before untap step to be honest )) . Is there any reason for that?
PS: I've updated the above code of Lobotomy with full hand revealing.
PPS: Added Tome Scour code to above code of Glimse Unthinkable
(Carnophage works pretty fine with "This card doesn't untap during your untap step." keyword)
PS: I've updated the above code of Lobotomy with full hand revealing.
PPS: Added Tome Scour code to above code of Glimse Unthinkable
(Carnophage works pretty fine with "This card doesn't untap during your untap step." keyword)
- Code: Select all
Gameactionutil
upkeep_Carnophage();
private static void upkeep_Carnophage()
{
final String player = AllZone.Phase.getActivePlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
CardList list = new CardList();
list.addAll(play.getCards());
list = list.getName("Carnophage");
if ( player == "Human" ) {
for (int i = 0; i < list.size(); i++) {
Card c = list.get(i);
String[] choices =
{ "Yes", "No" };
Object choice = AllZone.Display.getChoice(
"Pay upkeep?", choices);
if (choice.equals("Yes"))
AllZone.GameAction.getPlayerLife(player).subtractLife(1);
else c.tap();
} }
if ( player == "Computer" )
for (int i = 0; i < list.size(); i++) {
Card c = list.get(i);
if ( AllZone.Computer_Life.getLife() > 1 )
AllZone.GameAction.getPlayerLife(player).subtractLife(1);
else c.tap(); }
}// upkeep_Carnophage
=======================================================================================
cards.txt
Carnophage
B
Creature Zombie
At the beginning of your upkeep, tap Carnophage unless you pay 1 life
2/2
This card doesn't untap during your untap step.
=======================================================================================
cards-pictures.txt
carnophage.jpg http://www.wizards.com/global/images/magic/general/carnophage.jpg
- Code: Select all
Gameactionutil
upkeep_();
private static void upkeep_Sangrophage()
{
final String player = AllZone.Phase.getActivePlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
CardList list = new CardList();
list.addAll(play.getCards());
list = list.getName("Sangrophage");
if ( player == "Human" ) {
for (int i = 0; i < list.size(); i++) {
Card c = list.get(i);
String[] choices =
{ "Yes", "No" };
Object choice = AllZone.Display.getChoice(
"Pay 2 life?", choices);
if (choice.equals("Yes"))
AllZone.GameAction.getPlayerLife(player).subtractLife(2);
else c.tap();
} }
if ( player == "Computer" )
for (int i = 0; i < list.size(); i++) {
Card c = list.get(i);
if ( AllZone.Computer_Life.getLife() > 2 )
AllZone.GameAction.getPlayerLife(player).subtractLife(2);
else c.tap(); }
}// upkeep_Carnophage
=======================================================================================
cards.txt
Sangrophage
B
Creature Zombie
At the beginning of your upkeep, tap Carnophage unless you pay 2 life
3/3
This card doesn't untap during your untap step.
=======================================================================================
cards-pictures.txt
Sangrophage.jpg http://www.wizards.com/global/images/magic/general/Sangrophage.jpg
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by DennisBergkamp » 03 Dec 2009, 17:10
Ah, you're right, this should be list.get(i);Forced Fruition. When copying this code from Standstill i found strange part in Standstill code - "list.get(0)" - is it right, or it should be "list.get(i)" ?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Programming a card
by DennisBergkamp » 03 Dec 2009, 20:25
I've added most of the cards to my local version, they all look good so far, except for Mind Funeral... I cast this, and the AI put 38 (!!!) cards in his graveyard (upon casting, the AI had 0 cards in his graveyard, so I checked to see what cards where in his graveyard, and it contained a lot more lands than 4), so something is not right here 

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Programming a card
by Triadasoul » 03 Dec 2009, 20:42
I thought it must check for 4 lands in a row ))) It isn't strange that i felt it like overpowered. I'll correct it within an hour.
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by DennisBergkamp » 03 Dec 2009, 21:03
Ahh, I see 
Well, no problems, take your time... I won't release a beta for a few days anyway.
By the way, do you know how to use SVN ? I could invite you to our SVN, and you can submit code directly.

Well, no problems, take your time... I won't release a beta for a few days anyway.
By the way, do you know how to use SVN ? I could invite you to our SVN, and you can submit code directly.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Programming a card
by Triadasoul » 03 Dec 2009, 21:37
I haven't tried SVN yet, but i think i could study out it. So it would be great if you invite me there.
PS: I've updated Mind Funeral above with the correct code. I've also corrected Vedalken Entrancer code with correct ability description.
PPS: Is there way to make certain spells in hand uncastable via Gameactionutil code ? I'm eager to code this guy

PS: I've updated Mind Funeral above with the correct code. I've also corrected Vedalken Entrancer code with correct ability description.
PPS: Is there way to make certain spells in hand uncastable via Gameactionutil code ? I'm eager to code this guy


- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Re: Programming a card
by Chris H. » 03 Dec 2009, 21:47
We have a couple of topics covering SVN in our Developer's Corner forum. Most of the information needed can be found in those two topics. If you have any problems, ask a question and someone here will be able to give you the answer that you need.Triadasoul wrote:I haven't tried SVN yet, but i think i could study out it. So it would be great if you invite me there.

-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Programming a card
by DennisBergkamp » 03 Dec 2009, 21:54
Alright cool, pm me your gmail account, and I'll give that account committer privileges.
Uncastable spells... we haven't implemented those yet. But I could give it a shot. It would be very cool, cards like Meddling Mage and Iona, Shield of Emeria would be possible then.
Uncastable spells... we haven't implemented those yet. But I could give it a shot. It would be very cool, cards like Meddling Mage and Iona, Shield of Emeria would be possible then.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Programming a card
by Triadasoul » 03 Dec 2009, 22:35
Also Gaddock Teeg =).
This could be implemented with casting cost altering (free spells/cheaper spells) to kill two birds with one stone. So we could set banned cards casting cost to 999999.
PS: I've pm'ed you the gmail account.
This could be implemented with casting cost altering (free spells/cheaper spells) to kill two birds with one stone. So we could set banned cards casting cost to 999999.
PS: I've pm'ed you the gmail account.
- Triadasoul
- Posts: 223
- Joined: 21 Jun 2008, 20:17
- Has thanked: 0 time
- Been thanked: 4 times
Who is online
Users browsing this forum: No registered users and 20 guests