Get ready for some fun. Necropotence

This is the code for both Yawgmoth's Bargain and Necropotence. I know we don't have Donate and Illusions Of Grandeur in MTG Forge to complete the combo, but this card is fun anyways.
Add this in CardFactory.java
Add this in CardFactory.java
- 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)
{
AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(1);
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);
}//*************** 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)
{
AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(1);
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);
}//*************** END ************ END **************************
- Code: Select all
import java.util.*;
public class Input_Draw extends Input
{
public void showMessage()
{
if(AllZone.Phase.getActivePlayer().equals(Constant.Player.Computer))
{
AllZone.GameAction.drawCard(Constant.Player.Computer);
//AllZone.Phase.nextPhase();
//for debugging: System.out.println("need to nextPhase(from Input_Draw on computer's draw) = true");
AllZone.Phase.setNeedToNextPhase(true);
return;
}
//check if human should skip their draw phase
CardList humanCards = new CardList();
humanCards.addAll(AllZone.Human_Play.getCards());
boolean humanSkipsDrawPhase = humanCards.containsName("Necropotence") || humanCards.containsName("Yawgmoth's Bargain");
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw) && humanSkipsDrawPhase){
AllZone.Phase.setNeedToNextPhase(true);
}
else{ //continue with draw phase
boolean drawCard = true;
if(0 < getDredge().size())
{
String choices[] = {"Yes", "No"};
Object o = AllZone.Display.getChoice("Do you want to dredge?", choices);
if(o.equals("Yes"))
{
drawCard = false;
Card c = (Card) AllZone.Display.getChoice("Select card to dredge", getDredge().toArray());
//might have to make this more sophisticated
//dredge library, put card in hand
AllZone.Human_Hand.add(c);
AllZone.Human_Graveyard.remove(c);
for(int i = 0; i < getDredgeNumber(c); i++)
{
Card c2 = AllZone.Human_Library.get(0);
AllZone.Human_Library.remove(0);
AllZone.Human_Graveyard.add(c2);
}
}
}//if(0 < getDredge().size())
if(drawCard)
AllZone.GameAction.drawCard(Constant.Player.Human);
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw))
{
Input_Main.canPlayLand = true;
//AllZone.Phase.nextPhase();
//for debugging: System.out.println("need to nextPhase(from Input_Draw on human's draw) = true");
AllZone.Phase.setNeedToNextPhase(true);
}
else
stop();
}
} //end necro check
public ArrayList getDredge()
{
ArrayList dredge = new ArrayList();
Card c[] = AllZone.Human_Graveyard.getCards();
for(int outer = 0; outer < c.length; outer++)
{
ArrayList a = c[outer].getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("Dredge"))
{
if(AllZone.Human_Library.size() >= getDredgeNumber(c[outer]))
dredge.add(c[outer]);
}
}
return dredge;
}//hasDredge()
public int getDredgeNumber(Card c)
{
ArrayList a = c.getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("Dredge"))
{
String s = a.get(i).toString();
return Integer.parseInt("" +s.charAt(s.length() -1));
}
throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " +c.getName());
}//getDredgeNumber()
}
- Code: Select all
Necropotence
B B B
Enchantment
Skip your draw step. If you would discard a card from your hand, remove that card from the game instead. Pay 1 life: Set aside the top card of your library face down. At the end of your turn, put that card into your hand.
Yawgmoth's Bargain
4 B B
Enchantment
Skip your draw step. Pay 1 life: Draw a card.