merge latest trunk

This commit is contained in:
myk
2013-03-12 05:41:17 +00:00
23 changed files with 77 additions and 45 deletions

View File

@@ -180,7 +180,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (part instanceof CostDiscard) {
CostDiscard cd = (CostDiscard) part;
// this is mainly for typecycling
if (!cd.isTargetingThis() || !ComputerUtil.isWorseThanDraw(ai, source)) {
if (!cd.payCostFromSource() || !ComputerUtil.isWorseThanDraw(ai, source)) {
return false;
}
}

View File

@@ -87,7 +87,7 @@ public class DestroyAi extends SpellAbilityAi {
continue;
}
CostSacrifice sacCost = (CostSacrifice) part;
if (sacCost.isTargetingThis() && ComputerUtilCost.canPayCost(ability, c.getController())) {
if (sacCost.payCostFromSource() && ComputerUtilCost.canPayCost(ability, c.getController())) {
return false;
}
}

View File

@@ -69,7 +69,7 @@ public class CostDiscard extends CostPartWithList {
final Integer i = this.convertAmount();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
} else if (this.getType().equals("Hand")) {
sb.append("your hand");
@@ -108,7 +108,7 @@ public class CostDiscard extends CostPartWithList {
String type = this.getType();
final Integer amount = this.convertAmount();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
if (!source.isInZone(ZoneType.Hand)) {
return false;
}
@@ -174,7 +174,7 @@ public class CostDiscard extends CostPartWithList {
final String amount = this.getAmount();
this.resetList();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
if (!handList.contains(source)) {
return false;
}
@@ -272,7 +272,7 @@ public class CostDiscard extends CostPartWithList {
this.addToList(ai.getLastDrawnCard());
}
else if (this.isTargetingThis()) {
else if (this.payCostFromSource()) {
if (!hand.contains(source)) {
return false;
}

View File

@@ -492,7 +492,7 @@ public class CostExile extends CostPartWithList {
final Integer i = this.convertAmount();
sb.append("Exile ");
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
if (!this.from.equals(ZoneType.Battlefield)) {
sb.append(" from your ").append(this.from);
@@ -507,7 +507,7 @@ public class CostExile extends CostPartWithList {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), desc));
if (!this.isTargetingThis()) {
if (!this.payCostFromSource()) {
sb.append(" you control");
}
return sb.toString();
@@ -561,7 +561,7 @@ public class CostExile extends CostPartWithList {
typeList = new ArrayList<Card>(activator.getCardsIn(this.getFrom()));
}
}
if (!this.isTargetingThis()) {
if (!this.payCostFromSource()) {
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
final Integer amount = this.convertAmount();
@@ -652,7 +652,7 @@ public class CostExile extends CostPartWithList {
}
Input target = null;
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
target = new InputExileThis(payment, this, ability);
} else if (this.from.equals(ZoneType.Battlefield) || this.from.equals(ZoneType.Hand)) {
target = new InputExileType(this, payment, this.getType(), c, ability);
@@ -691,7 +691,7 @@ public class CostExile extends CostPartWithList {
@Override
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
this.getList().add(source);
} else if (this.getType().equals("All")) {
this.setList(new ArrayList<Card>(ability.getActivatingPlayer().getCardsIn(this.getFrom())));

View File

@@ -87,7 +87,7 @@ public abstract class CostPart {
*
* @return the this
*/
public final boolean isTargetingThis() {
public final boolean payCostFromSource() {
return this.getType().equals("CARDNAME");
}

View File

@@ -97,7 +97,7 @@ public class CostPutCounter extends CostPartWithList {
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), this.counter.getName() + " counter"));
sb.append(" on ");
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
} else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -128,7 +128,7 @@ public class CostPutCounter extends CostPartWithList {
*/
@Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
if (source.hasKeyword("CARDNAME can't have counters placed on it.")) {
return false;
}
@@ -161,7 +161,7 @@ public class CostPutCounter extends CostPartWithList {
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
}
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
source.addCounter(this.getCounter(), c, false);
} else {
// Put counter on chosen card
@@ -185,7 +185,7 @@ public class CostPutCounter extends CostPartWithList {
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
}
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
source.addCounter(this.getCounter(), c, false);
payment.setPaidManaPart(this);
this.addToList(source);
@@ -207,7 +207,7 @@ public class CostPutCounter extends CostPartWithList {
@Override
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
this.addToList(source);
return true;
} else {

View File

@@ -130,7 +130,7 @@ public class CostRemoveCounter extends CostPartWithList {
sb.append(" from ");
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
} else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -165,7 +165,7 @@ public class CostRemoveCounter extends CostPartWithList {
final CounterType cntrs = this.getCounter();
final Integer amount = this.convertAmount();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
if ((amount != null) && ((source.getCounters(cntrs) - amount) < 0)) {
return false;
}
@@ -203,7 +203,7 @@ public class CostRemoveCounter extends CostPartWithList {
}
}
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
source.subtractCounter(this.counter, c);
} else {
for (final Card card : this.getList()) {
@@ -226,7 +226,7 @@ public class CostRemoveCounter extends CostPartWithList {
Integer c = this.convertAmount();
int maxCounters = 0;
if (!this.isTargetingThis()) {
if (!this.payCostFromSource()) {
if (c == null) {
final String sVar = ability.getSVar(amount);
// Generalize this
@@ -302,7 +302,7 @@ public class CostRemoveCounter extends CostPartWithList {
}
}
if (!this.isTargetingThis()) {
if (!this.payCostFromSource()) {
this.getList().clear();
final List<Card> typeList =
CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source);

View File

@@ -69,7 +69,7 @@ public class CostReturn extends CostPartWithList {
final Integer i = this.convertAmount();
String pronoun = "its";
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
} else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -97,7 +97,7 @@ public class CostReturn extends CostPartWithList {
*/
@Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
if (!this.isTargetingThis()) {
if (!this.payCostFromSource()) {
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
@@ -149,7 +149,7 @@ public class CostReturn extends CostPartWithList {
c = AbilityUtils.calculateAmount(source, amount, ability);
}
}
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
final Input inp = CostReturn.returnThis(ability, payment, this);
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
} else {
@@ -169,7 +169,7 @@ public class CostReturn extends CostPartWithList {
@Override
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
this.getList().add(source);
} else {
Integer c = this.convertAmount();

View File

@@ -71,7 +71,7 @@ public class CostReveal extends CostPartWithList {
final String type = this.getType();
final Integer amount = this.convertAmount();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
if (!source.isInZone(ZoneType.Hand)) {
return false;
}
@@ -105,7 +105,7 @@ public class CostReveal extends CostPartWithList {
List<Card> hand = new ArrayList<Card>(ai.getCardsIn(ZoneType.Hand));
this.resetList();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
if (!hand.contains(source)) {
return false;
}
@@ -155,7 +155,7 @@ public class CostReveal extends CostPartWithList {
final String amount = this.getAmount();
this.resetList();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
this.addToList(source);
payment.setPaidManaPart(this);
} else if (this.getType().equals("Hand")) {
@@ -199,7 +199,7 @@ public class CostReveal extends CostPartWithList {
final Integer i = this.convertAmount();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
} else if (this.getType().equals("Hand")) {
return ("Reveal you hand");

View File

@@ -67,7 +67,7 @@ public class CostSacrifice extends CostPartWithList {
final Integer i = this.convertAmount();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
sb.append(this.getType());
} else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -90,7 +90,7 @@ public class CostSacrifice extends CostPartWithList {
@Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
// You can always sac all
if (!this.isTargetingThis()) {
if (!this.payCostFromSource()) {
// If the sacrificed type is dependant on an annoucement, can't necesarily rule out the CanPlay call
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
@@ -154,7 +154,7 @@ public class CostSacrifice extends CostPartWithList {
list = CardLists.getNotType(list, "Creature");
}
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
final Input inp = CostSacrifice.sacrificeThis(ability, payment, this);
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
} else if (amount.equals("All")) {
@@ -195,7 +195,7 @@ public class CostSacrifice extends CostPartWithList {
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList();
final Player activator = ability.getActivatingPlayer();
if (this.isTargetingThis()) {
if (this.payCostFromSource()) {
this.getList().add(source);
} else if (this.getAmount().equals("All")) {
/*List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));

View File

@@ -1701,7 +1701,8 @@ public abstract class SpellAbility implements ISpellAbility {
String value = this.getActivatingPlayer().getController().announceRequirements(this, aVar);
if (value == null || !StringUtils.isNumeric(value)) {
return false;
} else if (this.getPayCosts().getCostMana().isxCantBe0() && Integer.parseInt(value) == 0) {
} else if (this.getPayCosts().getCostMana() != null && this.getPayCosts().getCostMana().isxCantBe0()
&& Integer.parseInt(value) == 0) {
return false;
}
this.setSVar(aVar, "Number$" + value);

View File

@@ -86,7 +86,7 @@ public class ComputerUtilCost {
final CounterType type = remCounter.getCounter();
final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent;
final int currentNum = source.getCounters(type);
if (!part.isTargetingThis()) {
if (!part.payCostFromSource()) {
if (type.name().equals("P1P1")) {
return false;
}
@@ -224,7 +224,7 @@ public class ComputerUtilCost {
for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostSacrifice) {
final CostSacrifice sac = (CostSacrifice) part;
if (sac.isTargetingThis() && source.isCreature()) {
if (sac.payCostFromSource() && source.isCreature()) {
return false;
}
final String type = sac.getType();