merge latest trunk

This commit is contained in:
myk
2013-03-12 02:09:12 +00:00
8 changed files with 60 additions and 23 deletions

View File

@@ -194,6 +194,14 @@ public class CostPayment {
this.payCost();
}
/**
* Cancel cost (including CostPart for refunding).
*/
public final void cancelCost(final CostPart part) {
this.setPaidManaPart(part);
this.cancelCost();
}
/**
* Cancel cost.
*/

View File

@@ -106,7 +106,9 @@ public class CostRemoveCounter extends CostPartWithList {
@Override
public boolean isReusable() { return true; }
@Override
public boolean isUndoable() { return true; }
/*
* (non-Javadoc)
*
@@ -145,8 +147,9 @@ public class CostRemoveCounter extends CostPartWithList {
*/
@Override
public final void refund(final Card source) {
int refund = this.getList().size() == 1 ? this.lastPaidAmount : 1;
for (final Card c : this.getList()) {
c.addCounter(this.counter, this.lastPaidAmount, false);
c.addCounter(this.counter, refund, false);
}
}
@@ -224,6 +227,16 @@ public class CostRemoveCounter extends CostPartWithList {
int maxCounters = 0;
if (!this.isTargetingThis()) {
if (c == null) {
final String sVar = ability.getSVar(amount);
// Generalize this
if (sVar.equals("XChoice")) {
c = CostUtil.chooseXValue(source, ability, maxCounters);
} else {
c = AbilityUtils.calculateAmount(source, amount, ability);
}
}
if (this.getZone().equals(ZoneType.Battlefield)) {
final Input inp = CostRemoveCounter.removeCounterType(ability, this.getType(), payment, this, c);
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
@@ -341,14 +354,13 @@ public class CostRemoveCounter extends CostPartWithList {
final StringBuilder msg = new StringBuilder("Remove ");
final int nLeft = nNeeded - this.nRemove;
msg.append(nLeft).append(" ");
msg.append(costRemoveCounter.getCounter()).append(" from ");
msg.append(costRemoveCounter.getCounter().getName()).append(" counters from ");
msg.append(costRemoveCounter.getDescriptiveType());
if (nLeft > 1) {
msg.append("s");
}
this.typeList = CardLists.getValidCards(sa.getActivatingPlayer().getCardsIn(costRemoveCounter.getZone()), type.split(";"), sa.getActivatingPlayer(), sa.getSourceCard());
// TODO Tabulate typelist vs nNeeded to see if there are enough counters to remove
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -377,14 +389,14 @@ public class CostRemoveCounter extends CostPartWithList {
public void done() {
this.stop();
costRemoveCounter.addListToHash(sa, "CounterPut");
costRemoveCounter.addListToHash(sa, "CounterRemove");
payment.paidCost(costRemoveCounter);
}
public void cancel() {
this.stop();
costRemoveCounter.addListToHash(sa, "CounterPut");
payment.cancelCost();
costRemoveCounter.addListToHash(sa, "CounterRemove");
payment.cancelCost(costRemoveCounter);
}
};
@@ -464,13 +476,13 @@ public class CostRemoveCounter extends CostPartWithList {
public void done() {
this.stop();
costRemoveCounter.addListToHash(sa, "CounterPut");
costRemoveCounter.addListToHash(sa, "CounterRemove");
payment.paidCost(costRemoveCounter);
}
public void cancel() {
this.stop();
costRemoveCounter.addListToHash(sa, "CounterPut");
costRemoveCounter.addListToHash(sa, "CounterRemove");
payment.cancelCost();
}
};

View File

@@ -202,16 +202,7 @@ public class SpellAbilityRequirements {
* </p>
*/
public final void finishPaying() {
if (this.isFree || this.payment.isAllPaid()) {
if (this.skipStack) {
AbilityUtils.resolve(this.ability, false);
} else {
this.addAbilityToStack();
}
this.select.resetTargets();
Singletons.getModel().getGame().getAction().checkStateEffects();
} else if (this.payment.isCanceled()) {
if (this.payment.isCanceled()) {
final Card c = this.ability.getSourceCard();
// split cards transform back to full form if mana cost is not paid
@@ -234,6 +225,16 @@ public class SpellAbilityRequirements {
this.payment.cancelPayment();
Singletons.getModel().getGame().getStack().clearFrozen();
}
else if (this.isFree || this.payment.isAllPaid()) {
if (this.skipStack) {
AbilityUtils.resolve(this.ability, false);
} else {
this.addAbilityToStack();
}
this.select.resetTargets();
Singletons.getModel().getGame().getAction().checkStateEffects();
}
}
/**