mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
* Fixed a bug that prevented most continuous effects from recognizing if a permanent made zone changes and so the permanent was considered as a valid target even if the permanent changed zones (e.g. was Cloudshifted).
This commit is contained in:
parent
042552aa1e
commit
d031b93fd4
15 changed files with 39 additions and 41 deletions
|
|
@ -137,8 +137,6 @@ class LilianaOfTheDarkRealmsEffect extends ContinuousEffectImpl<LilianaOfTheDark
|
|||
if (player != null && player.chooseUse(Outcome.Neutral, message, game)) {
|
||||
this.amount *= -1;
|
||||
}
|
||||
|
||||
targetPointer.init(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class SharedAnimosityEffect extends ContinuousEffectImpl<SharedAnimosityEffect>
|
|||
}
|
||||
}
|
||||
if(!isChangeling){
|
||||
ArrayList<Predicate<MageObject>> predicateList = new ArrayList<Predicate<MageObject>>();
|
||||
ArrayList<Predicate<MageObject>> predicateList = new ArrayList<>();
|
||||
for(String subtype : permanent.getSubtype()){
|
||||
predicateList.add(new SubtypePredicate(subtype));
|
||||
}
|
||||
|
|
@ -122,7 +122,6 @@ class SharedAnimosityEffect extends ContinuousEffectImpl<SharedAnimosityEffect>
|
|||
|
||||
power = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getId(), game).size();
|
||||
}
|
||||
targetPointer.init(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class RescueFromTheUnderworldCreateDelayedTriggeredAbilityEffect extends OneShot
|
|||
for(Effect effect : delayedAbility.getEffects()) {
|
||||
effect.getTargetPointer().init(game, source);
|
||||
}
|
||||
// add the scraificed creature as target
|
||||
// add the sacrificed creature as target
|
||||
for (Cost cost :source.getCosts()) {
|
||||
if (cost instanceof SacrificeTargetCost) {
|
||||
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
|
||||
|
|
@ -193,10 +193,7 @@ class RescueFromTheUnderworldDelayedTriggeredAbility extends DelayedTriggeredAbi
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import java.util.UUID;
|
|||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ContinuousEffect<T extends ContinuousEffect<T>> extends Effect<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
|
|||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
targetPointer.init(game, source);
|
||||
//20100716 - 611.2c
|
||||
if (source instanceof ActivatedAbility || source instanceof TriggeredAbility) {
|
||||
if (layer != null) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import java.util.UUID;
|
|||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
|||
this.staticText = effect.staticText;
|
||||
this.targetPointer = effect.targetPointer.copy();
|
||||
if (effect.values != null) {
|
||||
values = new HashMap<String, Object>();
|
||||
values = new HashMap<>();
|
||||
Map<String, Object> map = effect.values;
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
|
|
@ -120,7 +121,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
|||
public void setValue(String key, Object value) {
|
||||
synchronized (this) {
|
||||
if (values == null) {
|
||||
values = new HashMap<String, Object>();
|
||||
values = new HashMap<>();
|
||||
}
|
||||
}
|
||||
values.put(key, value);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class DetainAllEffect extends OneShotEffect<DetainAllEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<FixedTarget> detainedObjects = new ArrayList<FixedTarget>();
|
||||
List<FixedTarget> detainedObjects = new ArrayList<>();
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
game.informPlayers("Detained permanent: " + permanent.getName());
|
||||
FixedTarget fixedTarget = new FixedTarget(permanent.getId());
|
||||
|
|
@ -86,7 +86,7 @@ public class DetainAllEffect extends OneShotEffect<DetainAllEffect> {
|
|||
|
||||
class DetainAllRestrictionEffect extends RestrictionEffect<DetainAllRestrictionEffect> {
|
||||
|
||||
private List<FixedTarget> detainedObjects;
|
||||
private final List<FixedTarget> detainedObjects;
|
||||
|
||||
public DetainAllRestrictionEffect(List<FixedTarget> detainedObjects) {
|
||||
super(Duration.Custom);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ public class DetainTargetEffect extends OneShotEffect<DetainTargetEffect> {
|
|||
}
|
||||
}
|
||||
DetainRestrictionEffect effect = new DetainRestrictionEffect();
|
||||
effect.getTargetPointer().init(game, source); // needed to init zoneChangeCounter
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,15 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -66,14 +68,17 @@ public class ExileTargetForSourceEffect extends OneShotEffect<ExileTargetForSour
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
UUID exileId = source.getSourceId();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(exileId, exileZone, source.getId(), game);
|
||||
return controller.moveCardToExileWithInfo(permanent, exileId, exileZone, source.getSourceId(), game, Zone.BATTLEFIELD);
|
||||
} else {
|
||||
Card card = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (card != null) {
|
||||
return card.moveToExile(exileId, exileZone, source.getId(), game);
|
||||
return controller.moveCardToExileWithInfo(card, exileId, exileZone, source.getSourceId(), game, game.getState().getZone(card.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -57,13 +58,17 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (card != null) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
if (card.putOntoBattlefield(game, currentZone, source.getId(), source.getControllerId())) {
|
||||
if (controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
|||
power = new StaticValue(power.calculate(game, source));
|
||||
toughness = new StaticValue(toughness.calculate(game, source));
|
||||
}
|
||||
targetPointer.init(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -79,12 +79,6 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl<GainAbilityTar
|
|||
return new GainAbilityTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
targetPointer.init(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public enum CardRepository {
|
|||
|
||||
private static final String JDBC_URL = "jdbc:sqlite:db/cards.db";
|
||||
private static final String VERSION_ENTITY_NAME = "card";
|
||||
private static final long CARD_DB_VERSION = 21;
|
||||
private static final long CARD_DB_VERSION = 22;
|
||||
|
||||
private final Random random = new Random();
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
|
|
|
|||
|
|
@ -1227,8 +1227,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
}
|
||||
}
|
||||
|
||||
List<Permanent> planeswalkers = new ArrayList<Permanent>();
|
||||
List<Permanent> legendary = new ArrayList<Permanent>();
|
||||
List<Permanent> planeswalkers = new ArrayList<>();
|
||||
List<Permanent> legendary = new ArrayList<>();
|
||||
for (Permanent perm: getBattlefield().getAllActivePermanents()) {
|
||||
if (perm.getCardType().contains(CardType.CREATURE)) {
|
||||
//20091005 - 704.5f
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
public interface TargetPointer extends Serializable {
|
||||
void init(Game game, Ability source);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue