Page 1 of 1

help with Kjeldoran Outpost

PostPosted: 16 Apr 2010, 04:34
by slapshot5
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

Re: help with Kjeldoran Outpost

PostPosted: 16 Apr 2010, 21:13
by DennisBergkamp
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.

Re: help with Kjeldoran Outpost

PostPosted: 16 Apr 2010, 21:16
by jim
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:

Re: help with Kjeldoran Outpost

PostPosted: 16 Apr 2010, 21:21
by DennisBergkamp
No, it just needs to be in selectButtonCancel().

Re: help with Kjeldoran Outpost

PostPosted: 17 Apr 2010, 22:26
by slapshot5
DennisBergkamp wrote:No, it just needs to be in selectButtonCancel().
Aargh! It's so obvious now. Thanks Dennis.

-slapshot5