input class for phyrexian dreadnought - from annonymous to nested

This commit is contained in:
Maxmtg
2013-05-19 21:06:32 +00:00
parent b78cc19e1c
commit 8791cd9400
3 changed files with 44 additions and 36 deletions

View File

@@ -48,7 +48,6 @@ import forge.game.ai.ComputerUtilCard;
import forge.game.ai.ComputerUtilCombat;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.Zone;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
import forge.util.Aggregates;
@@ -62,6 +61,42 @@ import forge.util.Aggregates;
* @version $Id$
*/
public class CardFactoryCreatures {
/**
* TODO: Write javadoc for this type.
*
*/
public static final class InputSelectCardsForDreadnought extends InputSelectCards {
private static final long serialVersionUID = 2698036349873486664L;
public InputSelectCardsForDreadnought(int min, int max) {
super(min, max);
}
@Override
protected String getMessage() {
return String.format(message, selected.size(), getTotalPower());
}
@Override
protected boolean isValidChoice(Card c) {
return c.isCreature() && player.getZone(ZoneType.Battlefield).contains(c);
} // selectCard()
@Override
protected boolean hasEnoughTargets() {
return getTotalPower() >= 12;
}
private int getTotalPower() {
int sum = 0;
for (final Card c : selected) {
sum += c.getNetAttack();
}
return sum;
}
}
private static void getCard_SphinxJwar(final Card card) {
final SpellAbility ability1 = new AbilityStatic(card, ManaCost.ZERO) {
@Override
@@ -308,37 +343,10 @@ public class CardFactoryCreatures {
public void resolve() {
final GameState game = player.getGame();
if (player.isHuman()) {
final InputSelectCards target = new InputSelectCards(0, Integer.MAX_VALUE) {
private static final long serialVersionUID = 2698036349873486664L;
@Override
public String getMessage() {
String toDisplay = cardName + " - Select any number of creatures to sacrifice. ";
toDisplay += "Currently, (" + selected.size() + ") selected with a total power of: " + getTotalPower();
toDisplay += " Click OK when Done.";
return toDisplay;
}
@Override
protected boolean isValidChoice(Card c) {
Zone zone = game.getZoneOf(c);
return c.isCreature() && zone.is(ZoneType.Battlefield, player);
} // selectCard()
@Override
protected boolean hasEnoughTargets() {
return getTotalPower() >= 12;
};
private int getTotalPower() {
int sum = 0;
for (final Card c : selected) {
sum += c.getNetAttack();
}
return sum;
}
}; // Input
final InputSelectCards target = new InputSelectCardsForDreadnought(0, Integer.MAX_VALUE); // Input
String toDisplay = cardName + " - Select any number of creatures to sacrifice.\n" +
"Currently, (%d) selected with a total power of: %d\n\n" + "Click OK when Done.";
target.setMessage(toDisplay);
target.setCancelAllowed(true);
FThreads.setInputAndWait(target);
if(!target.hasCancelled()) {

View File

@@ -41,7 +41,7 @@ public class CostPutCounter extends CostPartWithList {
* TODO: Write javadoc for this type.
*
*/
public static final class InputPayCostPutCounter extends InputSelectCards {
public static final class InputSelectCardToPutCounter extends InputSelectCards {
private static final long serialVersionUID = 2685832214519141903L;
private List<Card> validChoices;
@@ -55,7 +55,7 @@ public class CostPutCounter extends CostPartWithList {
* @param payment
* @param sa
*/
public InputPayCostPutCounter(int cntCounters, List<Card> targets) {
public InputSelectCardToPutCounter(int cntCounters, List<Card> targets) {
super(cntCounters, cntCounters);
validChoices = targets;
cardsChosen = cntCounters > 1 ? new HashMap<Card, Integer>() : null;
@@ -261,7 +261,7 @@ public class CostPutCounter extends CostPartWithList {
final Player actor = ability.getActivatingPlayer();
List<Card> typeList = CardLists.getValidCards(actor.getCardsIn(ZoneType.Battlefield), getType().split(";"), actor, ability.getSourceCard());
InputPayCostPutCounter inp = new InputPayCostPutCounter(c, typeList);
InputSelectCardToPutCounter inp = new InputSelectCardToPutCounter(c, typeList);
inp.setMessage("Put %d " + getCounter().getName() + " counter on " + getDescriptiveType());
inp.setCancelAllowed(true);
FThreads.setInputAndWait(inp);

View File

@@ -87,7 +87,7 @@ public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyn
}
public void setMessage(String message0) {
this.message = message0; // TODO: Add 0 to parameter's name.
this.message = message0;
}
// must define these