It is currently 09 Sep 2025, 17:53
   
Text Size

help with Kjeldoran Outpost

Post MTG Forge Related Programming Questions Here

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

help with Kjeldoran Outpost

Postby slapshot5 » 16 Apr 2010, 04:34

Hi all,

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
CardFactory_Lands.java:
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 **************************
Everything works, except not choosing a Plains to sacrifice, and hitting Cancel. I would want that to sacrifice Kjeldoran Outpost, but it does not. Currently Cancel leaves all Plains intact and Kjeldoran Outpost in play.

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

Postby DennisBergkamp » 16 Apr 2010, 21:13

You're very very close :) Notice the method selectButtonCancel(), I made it look like this:

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);
                 }
And it seems to work just fine.
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.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: help with Kjeldoran Outpost

Postby 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.. :shock:
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

Postby DennisBergkamp » 16 Apr 2010, 21:21

No, it just needs to be in selectButtonCancel().
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: help with Kjeldoran Outpost

Postby slapshot5 » 17 Apr 2010, 22:26

DennisBergkamp wrote:No, it just needs to be in selectButtonCancel().
Aargh! It's so obvious now. Thanks Dennis.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 50 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 50 users online :: 0 registered, 0 hidden and 50 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 50 guests

Login Form