fixed issue 141

This commit is contained in:
BetaSteward 2011-10-09 14:58:08 -04:00
parent f2c44688d0
commit 15f75f8d11
7 changed files with 27 additions and 19 deletions

View file

@ -91,16 +91,13 @@ class GhostlyPrisonReplacementEffect extends ReplacementEffectImpl<GhostlyPrison
if ( player != null && event.getTargetId().equals(source.getControllerId())) {
ManaCostsImpl propagandaTax = new ManaCostsImpl("{2}");
if ( propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Constants.Outcome.Benefit, "Pay {2} to declare attacker?", game) )
{
propagandaTax.pay(source, game, this.getId(), event.getPlayerId(), false);
if ( propagandaTax.isPaid() ) {
player.chooseUse(Constants.Outcome.Benefit, "Pay {2} to declare attacker?", game) ) {
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
return false;
}
}
return true;
}
return true;
}
return false;
}

View file

@ -91,9 +91,7 @@ class NornsAnnexReplacementEffect extends ReplacementEffectImpl<NornsAnnexReplac
ManaCostsImpl propagandaTax = new ManaCostsImpl("{WP}");
if (propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Constants.Outcome.Benefit, "Pay {WP} to declare attacker?", game)) {
propagandaTax.pay(source, game, this.getId(), event.getPlayerId(), false);
if (propagandaTax.isPaid()) {
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
return false;
}
}

View file

@ -105,9 +105,7 @@ class LeoninArbiterReplacementEffect extends ReplacementEffectImpl<LeoninArbiter
if ( arbiterTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Neutral, "Pay {2} to search your library?", game) )
{
arbiterTax.pay(source, game, this.getId(), event.getPlayerId(), false);
if ( arbiterTax.isPaid() ) {
if (arbiterTax.payOrRollback(source, game, this.getId(), event.getPlayerId()) ) {
paidPlayers.add(event.getPlayerId());
return false;
}

View file

@ -117,7 +117,7 @@ class VigilForTheLostEffect extends OneShotEffect<VigilForTheLostEffect> {
public boolean apply(Game game, Ability source) {
ManaCostsImpl cost = new ManaCostsImpl("{X}");
cost.clearPaid();
if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) {
if (cost.payOrRollback(source, game, source.getId(), source.getControllerId())) {
Player player = game.getPlayer(source.getControllerId());
player.gainLife(cost.getX(), game);
return true;

View file

@ -93,9 +93,7 @@ class PropagandaReplacementEffect extends ReplacementEffectImpl<PropagandaReplac
if ( propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Constants.Outcome.Neutral, "Pay {2} to declare attacker?", game) )
{
propagandaTax.pay(source, game, this.getId(), event.getPlayerId(), false);
if ( propagandaTax.isPaid() ) {
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId()) ) {
return false;
}
}

View file

@ -98,9 +98,7 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl<WindbornMuseRe
if ( propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Constants.Outcome.Benefit, "Pay {2} to declare attacker?", game) )
{
propagandaTax.pay(source, game, this.getId(), event.getPlayerId(), false);
if ( propagandaTax.isPaid() ) {
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
return false;
}
}

View file

@ -132,6 +132,25 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
return true;
}
/**
* bookmarks the current state and restores it if player doesn't pay the mana cost
*
* @param ability
* @param game
* @param sourceId
* @param controllerId
* @return true if the cost was paid
*/
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID controllerId) {
int bookmark = game.bookmarkState();
if (pay(ability, game, sourceId, controllerId, false)) {
game.removeBookmark(bookmark);
return true;
}
game.restoreState(bookmark);
return false;
}
@Override
public ManaCosts<T> getUnpaid() {
ManaCosts<T> unpaid = new ManaCostsImpl<T>();