Page 1 of 1

Updated Necropotence and Yawgmoth's Bargain

PostPosted: 27 Oct 2008, 23:50
by mtgrares
This is updated code for Necropotence and Yawgmoth's Bargain. When you use the ability your life points are subtracted and the ability is added to that stack.

Attached also is a new version of the class Gui_Deckeditor_Menu.java which lets users upload and download sealed and draft decks. Also when you export any deck, a text file is created that lists the contents of that deck.

Code: Select all
else if(cardName.equals("Yawgmoth's Bargain")){
      final SpellAbility ability = new Ability(card, "0")
      {
        public void resolve()
        {
          PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
          PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
          if(library.size() != 0)
          {
            Card c = library.get(0);
            library.remove(0);
            hand.add(c);
          }
        }

        public boolean canPlayAI()
        {
          return false;
        }
      };//SpellAbility

      ability.setDescription("Pay 1 life: Draw a card.");
      ability.setStackDescription(card.getName() +" - Pay 1 life: Draw a card.");

      card.addSpellAbility(ability);

      //instead of paying mana, pay life and add to stack
      //Input showMessage() is always the first method called
      Input payLife = new Input()
      {
        public void showMessage()
        {
          AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(1);

          //this order is very important, do not change
          stop();
          AllZone.Stack.push(ability);
        }
      };//Input
      ability.setBeforePayMana(payLife);
    }//*************** END ************ END **************************


    //*************** START *********** START **************************
    else if(cardName.equals("Necropotence"))
    {
      final CardList necroCards = new CardList();

      final Command necro = new Command()
      {
        public void execute()
        {
          if(AllZone.GameAction.isCardInPlay(card))
          {
            //put cards removed by Necropotence into player's hand
            if(necroCards.size() > 0){
              PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());

              for(int i = 0;i<necroCards.size();i++){
                hand.add(necroCards.get(i));
              }
              necroCards.clear();
            }
          }
        }
      };

      final SpellAbility ability = new Ability(card, "0")
      {
        public void resolve()
        {
          PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());

          if(library.size() != 0)
          {
            Card c = library.get(0);
            library.remove(0);
            necroCards.add(c); //add card to necro so that it goes into hand at end of turn
            AllZone.EndOfTurn.addAt(necro);
          }
        }

        public boolean canPlayAI()
        {
          return false;
        }
      };//SpellAbility

      ability.setDescription("1 life: Set aside the top card of your library face down. At the end of your turn, put that card into your hand.");
      ability.setStackDescription(card.getName() +" - 1 life: Set aside the top card of your library face down. At the end of your turn, put that card into your hand.");

      card.addSpellAbility(ability);

      //instead of paying mana, pay life and add to stack
      //Input showMessage() is always the first method called
      Input payLife = new Input()
      {
        public void showMessage()
        {
          AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(1);

          //this order is very important, do not change
          stop();
          AllZone.Stack.push(ability);
        }
      };//Input
      ability.setBeforePayMana(payLife);

    }//*************** END ************ END **************************

Re: Updated Necropotence and Yawgmoth's Bargain

PostPosted: 28 Oct 2008, 02:11
by GandoTheBard
Now we just need someone to compile and upload that :)

Re: Updated Necropotence and Yawgmoth's Bargain

PostPosted: 28 Oct 2008, 17:41
by jpb
Whenever anyone compiles the new version, remember to include the fix for laying a land when Necropotence or Yawgmoth's Bargain are in play.