* Fixed a bug of ConditionalTriggeredAbility if the ability triggered multiple times at the same time.

This commit is contained in:
LevelX2 2015-08-01 18:27:17 +02:00
parent 539603af3d
commit 2b617fa6f7
7 changed files with 137 additions and 79 deletions

View file

@ -44,7 +44,6 @@ import mage.target.targetpointer.FixedTarget;
*
* @author LevelX2
*/
public class PutCardIntoGraveFromAnywhereAllTriggeredAbility extends TriggeredAbilityImpl {
private final FilterCard filter;
@ -58,7 +57,7 @@ public class PutCardIntoGraveFromAnywhereAllTriggeredAbility extends TriggeredAb
public PutCardIntoGraveFromAnywhereAllTriggeredAbility(Effect effect, boolean optional, FilterCard filter, TargetController targetController) {
this(effect, optional, filter, targetController, SetTargetPointer.NONE);
}
public PutCardIntoGraveFromAnywhereAllTriggeredAbility(Effect effect, boolean optional, FilterCard filter, TargetController targetController, SetTargetPointer setTargetPointer) {
this(Zone.BATTLEFIELD, effect, optional, filter, targetController, setTargetPointer);
}
@ -110,13 +109,13 @@ public class PutCardIntoGraveFromAnywhereAllTriggeredAbility extends TriggeredAb
if (card != null && filter.match(card, getSourceId(), getControllerId(), game)) {
switch (setTargetPointer) {
case CARD:
for (Effect effect: getEffects()) {
effect.setTargetPointer(new FixedTarget(card.getId()));
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
}
break;
case PLAYER:
for (Effect effect: getEffects()) {
effect.setTargetPointer(new FixedTarget(card.getOwnerId()));
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(card.getOwnerId(), 0));
}
break;

View file

@ -28,8 +28,6 @@
package mage.abilities.decorator;
import java.util.UUID;
import mage.constants.Zone;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
@ -38,6 +36,7 @@ import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.constants.EffectType;
import mage.constants.Zone;
import mage.game.Game;
/**
@ -47,12 +46,12 @@ import mage.game.Game;
*/
public class ConditionalGainActivatedAbility extends ActivatedAbilityImpl {
private Condition condition;
private String staticText = "";
private final Condition condition;
private String staticText = "";
private static final Effects emptyEffects = new Effects();
private static final Effects emptyEffects = new Effects();
public ConditionalGainActivatedAbility(Zone zone, Effect effect, ManaCosts cost, Condition condition, String rule) {
public ConditionalGainActivatedAbility(Zone zone, Effect effect, ManaCosts cost, Condition condition, String rule) {
super(zone, effect, cost);
this.condition = condition;
this.staticText = rule;

View file

@ -1,9 +1,11 @@
package mage.abilities.decorator;
import mage.abilities.Modes;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.condition.Condition;
import mage.abilities.effects.Effects;
import mage.constants.EffectType;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -34,7 +36,7 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl {
public ConditionalTriggeredAbility(final ConditionalTriggeredAbility triggered) {
super(triggered);
this.ability = triggered.ability;
this.ability = triggered.ability.copy();
this.condition = triggered.condition;
this.text = triggered.text;
}
@ -74,4 +76,14 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl {
return ability.getEffects();
}
@Override
public Modes getModes() {
return ability.getModes();
}
@Override
public Effects getEffects(Game game, EffectType effectType) {
return ability.getEffects(game, effectType);
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -103,5 +102,4 @@ public class LoseLifeTargetEffect extends OneShotEffect {
return sb.toString();
}
}

View file

@ -693,7 +693,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public Cards discard(int amount, boolean random, Ability source, Game game) {
Cards discardedCards = new CardsImpl();
if (this.getHand().size() == 1) {
if (this.getHand().size() == 1 || this.getHand().size() == amount) {
discardedCards.addAll(this.getHand());
while (this.getHand().size() > 0) {
discard(this.getHand().get(this.getHand().iterator().next(), game), source, game);