minor cleanups in CardFactory classes

This commit is contained in:
jendave
2011-08-06 14:15:24 +00:00
parent 2f849b741e
commit eea8f37930
4 changed files with 146 additions and 192 deletions

View File

@@ -7548,7 +7548,6 @@ public class CardFactory implements NewConstants {
}
};//SpellAbility
//card.clearSpellKeepManaAbility();
card.addSpellAbility(a1);
StringBuilder sb = new StringBuilder();
@@ -7566,6 +7565,7 @@ public class CardFactory implements NewConstants {
a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if (cardName.equals("An-Zerrin Ruins")) {
@@ -7645,6 +7645,7 @@ public class CardFactory implements NewConstants {
card.addSpellAbility(ability);
}//*************** END ************ END **************************
//*************** START ************ START **************************
else if(cardName.equals("Black Mana Battery") || cardName.equals("Blue Mana Battery")
|| cardName.equals("Green Mana Battery") || cardName.equals("Red Mana Battery")
@@ -8166,6 +8167,8 @@ public class CardFactory implements NewConstants {
else JOptionPane.showMessageDialog(null, "Error in "+cardName+". freeCard is null", "", JOptionPane.INFORMATION_MESSAGE);
}
@Override
public boolean canPlayAI() {
return false;
}

View File

@@ -926,6 +926,7 @@ public class CardFactory_Creatures {
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Lava Hounds")) {
final SpellAbility ability = new Ability(card, "0") {
@@ -952,25 +953,25 @@ public class CardFactory_Creatures {
//*************** START *********** START **************************
else if(cardName.equals("Thunder Dragon")) {
final SpellAbility ability = new Ability(card, "0") {
@Override
public void resolve() {
CardList all = AllZoneUtil.getCreaturesInPlay();
all = all.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return !c.getKeyword().contains("Flying") &&
CardFactoryUtil.canDamage(card, c);
}
});
for(int i = 0; i < all.size(); i++)
all.get(i).addDamage(3, card);
}
};
final SpellAbility ability = new Ability(card, "0") {
@Override
public void resolve() {
CardList all = AllZoneUtil.getCreaturesInPlay();
all = all.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return !c.getKeyword().contains("Flying") &&
CardFactoryUtil.canDamage(card, c);
}
});
for(int i = 0; i < all.size(); i++)
all.get(i).addDamage(3, card);
}
};
Command intoPlay = new Command() {
private static final long serialVersionUID = 9072052875006010434L;
@@ -989,28 +990,28 @@ public class CardFactory_Creatures {
//*************** START *********** START **************************
else if(cardName.equals("Cloudthresher")) {
final SpellAbility ability = new Ability(card, "0") {
@Override
public void resolve() {
final SpellAbility ability = new Ability(card, "0") {
@Override
public void resolve() {
CardList all = AllZoneUtil.getCreaturesInPlay();
all = all.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.getKeyword().contains("Flying") &&
CardFactoryUtil.canDamage(card, c);
}
});
CardList all = AllZoneUtil.getCreaturesInPlay();
all = all.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.getKeyword().contains("Flying") &&
CardFactoryUtil.canDamage(card, c);
}
});
for(int i = 0; i < all.size(); i++)
all.get(i).addDamage(2, card);
for(int i = 0; i < all.size(); i++)
all.get(i).addDamage(2, card);
AllZone.HumanPlayer.addDamage(2, card);
AllZone.ComputerPlayer.addDamage(2, card);
AllZone.HumanPlayer.addDamage(2, card);
AllZone.ComputerPlayer.addDamage(2, card);
}
};
}
};
Command intoPlay = new Command() {
private static final long serialVersionUID = 9072052875006010410L;
@@ -1412,36 +1413,36 @@ public class CardFactory_Creatures {
}//getKeywordBoost()
String getChosenColor() {
// Choose color for protection in Brave the Elements
String color = "";
if (card.getController().equals(AllZone.HumanPlayer)) {
// Choose color for protection in Brave the Elements
String color = "";
if (card.getController().equals(AllZone.HumanPlayer)) {
String[] colors = Constant.Color.Colors;
colors[colors.length-1] = null;
String[] colors = Constant.Color.Colors;
colors[colors.length-1] = null;
Object o = AllZone.Display.getChoice("Choose color", colors);
color = (String)o;
}
else {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer);
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.HumanPlayer);
CardList list = new CardList();
list.addAll(lib.getCards());
list.addAll(hand.getCards());
Object o = AllZone.Display.getChoice("Choose color", colors);
color = (String)o;
}
else {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer);
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.HumanPlayer);
CardList list = new CardList();
list.addAll(lib.getCards());
list.addAll(hand.getCards());
if (list.size() > 0) {
String mpcolor = CardFactoryUtil.getMostProminentColor(list);
if (!mpcolor.equals(""))
color = mpcolor;
else
color = "black";
}
else {
color = "black";
}
}
return color;
} // getChosenColor
if (list.size() > 0) {
String mpcolor = CardFactoryUtil.getMostProminentColor(list);
if (!mpcolor.equals(""))
color = mpcolor;
else
color = "black";
}
else {
color = "black";
}
}
return color;
} // getChosenColor
@Override
public void resolve() {
@@ -2025,7 +2026,6 @@ public class CardFactory_Creatures {
@Override
public void resolve() {
Player opponent = card.getController().getOpponent();
//AllZone.GameAction.addDamage(opponent, card, 4);
opponent.addDamage(4, card);
}
};
@@ -3835,7 +3835,6 @@ public class CardFactory_Creatures {
@Override
public void selectPlayer(Player player) {
int damage = ((Integer) countZubera.execute()).intValue();
//AllZone.GameAction.addDamage(player, card, damage);
player.addDamage(damage, card);
stop();
}//selectPlayer()
@@ -5629,51 +5628,6 @@ public class CardFactory_Creatures {
card.addSpellAbility(ability2);
}//*************** END ************ END **************************
/*
//*************** START *********** START **************************
else if(cardName.equals("Turtleshell Changeling")) {
//mana ability - targets itself - until EOT
//mana ability
final Ability ability = new Ability(card, "1 U") {
@Override
public boolean canPlayAI() {
return CardFactoryUtil.AI_doesCreatureAttack(card) && card.getNetAttack() == 1;
}
@Override
public void resolve() {
//in case ability is played twice
final int[] oldAttack = new int[1];
final int[] oldDefense = new int[1];
oldAttack[0] = card.getBaseAttack();
oldDefense[0] = card.getBaseDefense();
card.setBaseAttack(oldDefense[0]);
card.setBaseDefense(oldAttack[0]);
//EOT
final Command untilEOT = new Command() {
private static final long serialVersionUID = -5494886974452901728L;
public void execute() {
card.setBaseAttack(oldAttack[0]);
card.setBaseDefense(oldDefense[0]);
}
};
AllZone.EndOfTurn.addUntil(untilEOT);
}//resolve()
};//SpellAbility
StringBuilder sb = new StringBuilder();
sb.append(card).append(" - switch power and toughness until EOT.");
ability.setStackDescription(sb.toString());
ability.setDescription("1 U: Switch Turtleshell Changeling's power and toughness until end of turn.");
card.addSpellAbility(ability);
}//*************** END ************ END **************************
*/
//*************** START *********** START **************************
else if(cardName.equals("Jugan, the Rising Star")) {

View File

@@ -2467,7 +2467,6 @@ class CardFactory_Planeswalkers {
for(int i = 0; i < dragons.size(); i++) {
Card dragon = dragons.get(i);
int damage = dragon.getNetAttack();
//AllZone.GameAction.addDamage(target, dragon, damage);
target.addDamage(damage, dragon);
}

View File

@@ -4526,30 +4526,30 @@ public class CardFactory_Sorceries {
//*************** START *********** START **************************
else if(cardName.equals("Stream of Life"))
{
final SpellAbility spell = new Spell(card){
private static final long serialVersionUID = 851280814064291421L;
final SpellAbility spell = new Spell(card){
private static final long serialVersionUID = 851280814064291421L;
public void resolve()
{
getTargetPlayer().gainLife(card.getXManaCostPaid(), card);
card.setXManaCostPaid(0);
}
public boolean canPlayAI()
{
int humanLife = AllZone.HumanPlayer.getLife();
int computerLife = AllZone.ComputerPlayer.getLife();
final int maxX = ComputerUtil.getAvailableMana().size() - 1;
return maxX > 3 && (humanLife >= computerLife);
}
};
spell.setDescription("Target player gains X life.");
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
spell.setChooseTargetAI(CardFactoryUtil.AI_targetComputer());
card.clearSpellAbility();
card.addSpellAbility(spell);
public void resolve()
{
getTargetPlayer().gainLife(card.getXManaCostPaid(), card);
card.setXManaCostPaid(0);
}
public boolean canPlayAI()
{
int humanLife = AllZone.HumanPlayer.getLife();
int computerLife = AllZone.ComputerPlayer.getLife();
final int maxX = ComputerUtil.getAvailableMana().size() - 1;
return maxX > 3 && (humanLife >= computerLife);
}
};
spell.setDescription("Target player gains X life.");
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
spell.setChooseTargetAI(CardFactoryUtil.AI_targetComputer());
card.clearSpellAbility();
card.addSpellAbility(spell);
}
//*************** END ************ END **************************
@@ -4557,63 +4557,61 @@ public class CardFactory_Sorceries {
//*************** START *********** START **************************
else if (cardName.equals("Lavalanche"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 3571646571415945308L;
public void resolve()
{
int damage = card.getXManaCostPaid();
Player player = getTargetPlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player);
CardList list = new CardList(play.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.isCreature() && CardFactoryUtil.canDamage(card, c);
}
});
for(int i = 0; i < list.size(); i++) {
list.get(i).addDamage(card.getXManaCostPaid(), card);
}
//AllZone.GameAction.addDamage(player, card, damage);
player.addDamage(damage, card);
card.setXManaCostPaid(0);
}
public boolean canPlayAI()
{
final int maxX = ComputerUtil.getAvailableMana().size() - 3;
if (AllZone.HumanPlayer.getLife() <= maxX)
return true;
CardListFilter filter = new CardListFilter(){
public boolean addCard(Card c)
{
return c.isCreature() && CardFactoryUtil.canDamage(card, c) &&
maxX >= (c.getNetDefense() + c.getDamage());
}
};
CardList killableCreatures = new CardList(AllZone.Human_Battlefield.getCards());
killableCreatures = killableCreatures.filter(filter);
return (killableCreatures.size() >= 2); // kill at least two of the human's creatures
}
};
spell.setDescription("Lavalanche deals X damage to target player and each creature he or she controls.");
spell.setStackDescription("Lavalanche - deals X damage to target player and each creature he or she controls.");
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 3571646571415945308L;
public void resolve()
{
int damage = card.getXManaCostPaid();
card.clearSpellAbility();
card.addSpellAbility(spell);
}
//*************** END ************ END **************************
Player player = getTargetPlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player);
CardList list = new CardList(play.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.isCreature() && CardFactoryUtil.canDamage(card, c);
}
});
for(int i = 0; i < list.size(); i++) {
list.get(i).addDamage(card.getXManaCostPaid(), card);
}
player.addDamage(damage, card);
card.setXManaCostPaid(0);
}
public boolean canPlayAI()
{
final int maxX = ComputerUtil.getAvailableMana().size() - 3;
if (AllZone.HumanPlayer.getLife() <= maxX)
return true;
CardListFilter filter = new CardListFilter(){
public boolean addCard(Card c)
{
return c.isCreature() && CardFactoryUtil.canDamage(card, c) &&
maxX >= (c.getNetDefense() + c.getDamage());
}
};
CardList killableCreatures = new CardList(AllZone.Human_Battlefield.getCards());
killableCreatures = killableCreatures.filter(filter);
return (killableCreatures.size() >= 2); // kill at least two of the human's creatures
}
};
spell.setDescription("Lavalanche deals X damage to target player and each creature he or she controls.");
spell.setStackDescription("Lavalanche - deals X damage to target player and each creature he or she controls.");
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
//*************** START *********** START **************************