Page 1 of 1

help with Phyrexian War Beast

PostPosted: 18 Apr 2010, 05:19
by slapshot5
Hi all,

I'm currently working on Phyrexian War Beast (among other things...)

Two parts here - when Phyrexian War Beast leaves play
1) It does one damage to controller
2) controller must sacrifice a land

First pass code implements the one damage:

CardFactory_Creatures.java:
Code: Select all
   //*************** START *********** START **************************
        else if(cardName.equals("Phyrexian War Beast")) {
      /* When Phyrexian War Beast leaves the battlefield, sacrifice a land
      * and Phyrexian War Beast deals 1 damage to you.
      */
           final SpellAbility ability = new Spell(card) {
         private static final long serialVersionUID = -3829801813561677938L;

         public void resolve() {
                 AllZone.GameAction.addDamage(card.getController(), 1, card);
              }
           };
           
      final Command oneDamage = new Command() {
         private static final long serialVersionUID = -8829001394137848084L;
         
         public void execute() {
            String player = card.getController();
            ability.setStackDescription(card.getName() + " - does 1 damage to "+player +"and sacrifice one land.");
            AllZone.Stack.add(ability);
         }//execute
      };
      card.addLeavesPlayCommand(oneDamage);
        }//*************** END ************ END **************************
That works fine. Now, I try to add in the second addLeavesPlayCommand:

CardFactory_Creatures.java:
Code: Select all
   //*************** START *********** START **************************
        else if(cardName.equals("Phyrexian War Beast")) {
      /* When Phyrexian War Beast leaves the battlefield, sacrifice a land
      * and Phyrexian War Beast deals 1 damage to you.
      */
           final SpellAbility ability = new Spell(card) {
            private static final long serialVersionUID = -3829801813561677938L;

            public void resolve() {
                 AllZone.GameAction.addDamage(card.getController(), 1, card);
              }
           };
           final Ability ability2 = new Ability(card, "0") {
              public void resolve() {
                 Card c = getTargetCard();
                 AllZone.GameAction.sacrifice(c);
              }
           };
           
           final Command sacrificeLand = new Command() {
            private static final long serialVersionUID = -1793348608291550952L;

            public void execute() {
               AllZone.InputControl.setInput(CardFactoryUtil.input_targetType(ability2, "Land"));
               ButtonUtil.disableAll();
               ability.setStackDescription(card.getName() + " - sacrifice a land");
               //AllZone.Stack.add(ability2);
              }
           };
            final Command oneDamage = new Command() {
            private static final long serialVersionUID = -8829001394137848084L;

            public void execute() {
               String player = card.getController();
               ability.setStackDescription(card.getName() + " - does 1 damage to "+player +"and sacrifice one land.");
                    AllZone.Stack.add(ability);
                }//execute
            };
            card.addLeavesPlayCommand(oneDamage);
            card.addLeavesPlayCommand(sacrificeLand);
        }//*************** END ************ END **************************
The second ability doesn't get put correctly on the stack. I'm not positive what the desired order is. What goes on the stack and in what order?

Probably:
1) Immediately put both things on the stack
2) have the one damage resolve
3) ask for input for a land to sacrifice
4) have that resolve

Thoughts? Tweaks?

Thanks,
slapshot5

Re: help with Phyrexian War Beast

PostPosted: 19 Apr 2010, 15:24
by Rob Cashwalker
I'd say to combine the two effects as one Command. The effects are part of one sentence, so they "stack" together.

Re: help with Phyrexian War Beast

PostPosted: 19 Apr 2010, 16:17
by DennisBergkamp
Yeah, I agree. Might not be 100% rules-compliant (or maybe it is ?), but in this case it's not a big deal at all.

Re: help with Phyrexian War Beast

PostPosted: 20 Apr 2010, 04:38
by slapshot5
Ok, I'm getting close. The problem I have now is that when I select the land to sacrifice, it asks to Pay Mana Cost. I just click Cancel and the land is not sacrificed.

current code:
Code: Select all
//*************** START *********** START **************************
        else if(cardName.equals("Phyrexian War Beast")) {
           /* When Phyrexian War Beast leaves the battlefield, sacrifice a land
            * and Phyrexian War Beast deals 1 damage to you.
            */
           final SpellAbility ability = new Spell(card) {
              private static final long serialVersionUID = -3829801813561677938L;

              public void resolve() {
                 Card c = getTargetCard();
                 AllZone.GameAction.sacrifice(c);
                 AllZone.GameAction.addDamage(card.getController(), 1, card);
              }
           };

           final Command sacrificeLandAndOneDamage = new Command() {
              private static final long serialVersionUID = -1793348608291550952L;

              public void execute() {
                 String player = card.getController();
                 ability.setStackDescription(card.getName() + " - does 1 damage to "+player +" and sacrifice one land.");
                 AllZone.Stack.add(ability);
                 //probably want to check that there are lands in play
                 
                 PlayerZone play = AllZone.getZone(Constant.Zone.Play,player);
                 CardList choice = new CardList(play.getCards());
                 choice  = choice.getType("Land");
                 AllZone.InputControl.setInput(CardFactoryUtil.input_sacrifice(ability,choice,"Select a land to sacrifice"));                
              }
           };
           
           card.addLeavesPlayCommand(sacrificeLandAndOneDamage);
        }//*************** END ************ END **************************
-slapshot5

Re: help with Phyrexian War Beast

PostPosted: 24 Apr 2010, 05:55
by slapshot5
bump.

Can anyone help me get this card fixed up? The reason being this: This is the only card that needs to be implemented in Forge to completely build the deck that won the 1996 world championship (minus the mistakenly added Sleight of Mind).

http://www.wizards.com/Magic/Magazine/Article.aspx?x=mtgcom/arcana/91

I think that would be an awesome addition to Forge to be able to ship with a complete deck that won a world championship.

-slapshot5

Re: help with Phyrexian War Beast

PostPosted: 24 Apr 2010, 06:11
by DennisBergkamp
Oh wow, cool! I suppose that's a good enough reason :mrgreen:

After a bunch of tries I got it to work. You were really close, the only minor thing that was wrong is that it should be Ability instead of Spell. Also, you don't need the "AllZone.Stack.add(ability)" because the input itself will add it after selecting a land:

Code: Select all
//*************** START *********** START **************************
        else if(cardName.equals("Phyrexian War Beast")) {
           /* When Phyrexian War Beast leaves the battlefield, sacrifice a land
            * and Phyrexian War Beast deals 1 damage to you.
            */
           final Ability ability = new Ability(card, "0") {
              private static final long serialVersionUID = -3829801813561677938L;

              public void resolve() {
                 Card c = getTargetCard();
                 AllZone.GameAction.sacrifice(c);
                 AllZone.GameAction.addDamage(card.getController(), 1, card);
              }
           };

           final Command sacrificeLandAndOneDamage = new Command() {
              private static final long serialVersionUID = -1793348608291550952L;

              public void execute() {
                 String player = card.getController();
                 ability.setStackDescription(card.getName() + " - does 1 damage to "+player +" and sacrifice one land.");
                 //AllZone.Stack.add(ability);
                 //probably want to check that there are lands in play
                 
                 PlayerZone play = AllZone.getZone(Constant.Zone.Play,player);
                 CardList choice = new CardList(play.getCards());
                 choice  = choice.getType("Land");
                 AllZone.InputControl.setInput(CardFactoryUtil.input_sacrifice(ability,choice,"Select a land to sacrifice"));               
              }
           };
           
           card.addLeavesPlayCommand(sacrificeLandAndOneDamage);
        }//*************** END ************ END **************************
I'll just commit it to SVN, so you won't have to :)

Re: help with Phyrexian War Beast

PostPosted: 24 Apr 2010, 10:42
by Chris H.
slapshot5 wrote:I think that would be an awesome addition to Forge to be able to ship with a complete deck that won a world championship.
`
Yes, a wonderful idea, thank you. :D