help with Kjeldoran Outpost
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
5 posts
• Page 1 of 1
help with Kjeldoran Outpost
by slapshot5 » 16 Apr 2010, 04:34
Hi all,
I'm trying to program Kjeldoran Outpost and here is what I have:
cards.txt:
Would someone mind having a quick look to see what I'm doing wrong?
Thanks,
-slapshot5
I'm trying to program Kjeldoran Outpost and here is what I have:
cards.txt:
- Code: Select all
Kjeldoran Outpost
no cost
Land
If Kjeldoran Outpost would enter the battlefield, sacrifice a Plains instead. If you do, put Kjeldoran Outpost onto the battlefield. If you don't, put it into its owner's graveyard.
tap: add W
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Kjeldoran Outpost")) {
final Command comesIntoPlay = new Command() {
private static final long serialVersionUID = 6175830918425915833L;
final String player = card.getController();
public void execute() {
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
CardList plains = new CardList(play.getCards());
plains = plains.getType("Plains");
if( player.equals(Constant.Player.Computer)) {
if( plains.size() > 0 ) {
CardList tappedPlains = new CardList(plains.toArray());
tappedPlains = tappedPlains.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isTapped();
}
});
if( tappedPlains.size() > 0 ) {
AllZone.GameAction.sacrifice(tappedPlains.get(0));
}
else {
AllZone.GameAction.sacrifice(plains.get(0));
}
//if any are tapped, sacrifice it
//else sacrifice random
}
else {
AllZone.GameAction.sacrifice(card);
}
}
else { //this is the human resolution
//this works with correct input
//really, what I want is Cancel to sacrifice Kjeldoran Outpost
Input target = new Input() {
private static final long serialVersionUID = 6653677835621129465L;
public void showMessage() {
AllZone.Display.showMessage("Kjeldoran Outpost - Select one plains to sacrifice");
ButtonUtil.enableOnlyCancel();
}
public void selectButtonCancel() {stop();}
public void selectCard(Card c, PlayerZone zone) {
if(c.isLand() && zone.is(Constant.Zone.Play) && c.getType().contains("Plains")) {
AllZone.GameAction.sacrifice(c);
stop();
}
else {
//basically, if the human hits cancel, I figure the code would get here.
//I want to sacrifice Kjeldoran Outpost, but this doesn't work
AllZone.GameAction.sacrifice(card);
}
}//selectCard()
};//Input
AllZone.InputControl.setInput(target);
}
}
};
final Ability_Tap ability2 = new Ability_Tap(card, "1 W") {
private static final long serialVersionUID = 6987135326425915833L;
public void resolve() {
CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card, "W", new String[] {"Creature", "Soldier"}, 1, 1, new String[] {""});
}
};//SpellAbility
card.addComesIntoPlayCommand(comesIntoPlay);
card.addSpellAbility(ability2);
ability2.setDescription("tap: Put a 1/1 white soldier token in play.");
ability2.setStackDescription("Kjeldoran Outpost - put a 1/1 white soldier token in play");
ability2.setBeforePayMana(new Input_PayManaCost(ability2));
}//*************** END ************ END **************************
Would someone mind having a quick look to see what I'm doing wrong?
Thanks,
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: help with Kjeldoran Outpost
by DennisBergkamp » 16 Apr 2010, 21:13
You're very very close
Notice the method selectButtonCancel(), I made it look like this:
EDIT: the way you had it originally, the else block in selectCard referred to any card selected that's not a land, not in play and a non-plains.

- Code: Select all
else { //this is the human resolution
//this works with correct input
//really, what I want is Cancel to sacrifice Kjeldoran Outpost
Input target = new Input() {
private static final long serialVersionUID = 6653677835621129465L;
public void showMessage() {
AllZone.Display.showMessage("Kjeldoran Outpost - Select one plains to sacrifice");
ButtonUtil.enableOnlyCancel();
}
public void selectButtonCancel() {
AllZone.GameAction.sacrifice(card);
stop();
}
public void selectCard(Card c, PlayerZone zone) {
if(c.isLand() && zone.is(Constant.Zone.Play) && c.getType().contains("Plains")) {
AllZone.GameAction.sacrifice(c);
stop();
}
}//selectCard()
};//Input
AllZone.InputControl.setInput(target);
}
EDIT: the way you had it originally, the else block in selectCard referred to any card selected that's not a land, not in play and a non-plains.
Last edited by DennisBergkamp on 16 Apr 2010, 21:21, edited 1 time in total.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: help with Kjeldoran Outpost
by jim » 16 Apr 2010, 21:16
AllZone.GameAction.sacrificeDestroy checks whether the card is in play or not. My best guess is that it isn't yet in that zone when you sacrifice. Try instead just adding it to the graveyard. (I apologize if you already checked this.)
I want to play with this card so I hope you succeed.
EDIT: Wow, I swear Dennis's post wasn't there when I wrote this..
I want to play with this card so I hope you succeed.

EDIT: Wow, I swear Dennis's post wasn't there when I wrote this..

Last edited by jim on 16 Apr 2010, 23:58, edited 1 time in total.
- jim
- Posts: 46
- Joined: 19 Feb 2010, 01:46
- Location: Sunny New England
- Has thanked: 0 time
- Been thanked: 0 time
Re: help with Kjeldoran Outpost
by DennisBergkamp » 16 Apr 2010, 21:21
No, it just needs to be in selectButtonCancel().
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: help with Kjeldoran Outpost
by slapshot5 » 17 Apr 2010, 22:26
Aargh! It's so obvious now. Thanks Dennis.DennisBergkamp wrote:No, it just needs to be in selectButtonCancel().
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 50 guests