mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Fixed a bug that put back auras always under owners control instead of abilities controller (e.g. triggered ability of It That Betrays).
This commit is contained in:
parent
b4e7403d82
commit
c4868cfa99
6 changed files with 80 additions and 42 deletions
|
|
@ -117,6 +117,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
game.applyEffects(); // So continuousEffects are removed if previous effect of the same ability did move objects that cuase continuous effects
|
||||
Player controllingPlayer = null;
|
||||
if (targetId == null) {
|
||||
SpellAbility spellAbility = card.getSpellAbility();
|
||||
if (spellAbility.getTargets().isEmpty()) {
|
||||
|
|
@ -145,8 +146,14 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
target.setNotTarget(true); // always not target because this way it's not handled targeted
|
||||
target.clearChosen(); // neccessary if e.g. aura is blinked multiple times
|
||||
}
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
if (target != null && player != null && player.choose(auraOutcome, target, card.getId(), game)) {
|
||||
|
||||
if (event.getPlayerId() != null) {
|
||||
controllingPlayer = game.getPlayer(event.getPlayerId());
|
||||
} else {
|
||||
controllingPlayer = game.getPlayer(card.getOwnerId());
|
||||
}
|
||||
|
||||
if (target != null && controllingPlayer != null && controllingPlayer.choose(auraOutcome, target, card.getId(), game)) {
|
||||
targetId = target.getFirstTarget();
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +169,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
|
||||
card.removeFromZone(game, fromZone, sourceId);
|
||||
card.updateZoneChangeCounter(game);
|
||||
PermanentCard permanent = new PermanentCard(card, card.getOwnerId(), game);
|
||||
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
|
||||
game.getBattlefield().addPermanent(permanent);
|
||||
card.setZone(Zone.BATTLEFIELD, game);
|
||||
if (permanent.entersBattlefield(event.getSourceId(), game, fromZone, true)) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ContinuousEffects implements Serializable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ContinuousEffects.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(ContinuousEffects.class);
|
||||
|
||||
private long order = 0;
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("No abilities for continuous effect: " + effect.toString());
|
||||
LOGGER.error("No abilities for continuous effect: " + effect.toString());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -462,17 +462,15 @@ public class ContinuousEffects implements Serializable {
|
|||
exists = permanent.getCard().getAbilities().contains(ability);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (object instanceof PermanentCard) {
|
||||
PermanentCard permanent = (PermanentCard) object;
|
||||
if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||
return false;
|
||||
}
|
||||
} else if (object instanceof Spell) {
|
||||
Spell spell = (Spell) object;
|
||||
if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||
return false;
|
||||
}
|
||||
} else if (object instanceof PermanentCard) {
|
||||
PermanentCard permanent = (PermanentCard) object;
|
||||
if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||
return false;
|
||||
}
|
||||
} else if (object instanceof Spell) {
|
||||
Spell spell = (Spell) object;
|
||||
if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return exists;
|
||||
|
|
@ -539,10 +537,8 @@ public class ContinuousEffects implements Serializable {
|
|||
if (effect.applies(objectId, ability, controllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (effect.applies(objectId, affectedAbility, ability, game)) {
|
||||
return true;
|
||||
}
|
||||
} else if (effect.applies(objectId, affectedAbility, ability, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1082,11 +1078,9 @@ public class ContinuousEffects implements Serializable {
|
|||
if (abilities == null) {
|
||||
abilities = new HashSet<>();
|
||||
temporaryEffects.put(effect, abilities);
|
||||
} else {
|
||||
if (abilities.contains(source)) {
|
||||
// this ability (for the continuous effect) is already added
|
||||
return;
|
||||
}
|
||||
} else if (abilities.contains(source)) {
|
||||
// this ability (for the continuous effect) is already added
|
||||
return;
|
||||
}
|
||||
abilities.add(source);
|
||||
|
||||
|
|
@ -1097,10 +1091,10 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
public void addEffect(ContinuousEffect effect, Ability source) {
|
||||
if (effect == null) {
|
||||
logger.error("Effect is null: " + source.toString());
|
||||
LOGGER.error("Effect is null: " + source.toString());
|
||||
return;
|
||||
} else if (source == null) {
|
||||
logger.warn("Adding effect without ability : " + effect.toString());
|
||||
LOGGER.warn("Adding effect without ability : " + effect.toString());
|
||||
}
|
||||
switch (effect.getEffectType()) {
|
||||
case REPLACEMENT:
|
||||
|
|
@ -1166,10 +1160,8 @@ public class ContinuousEffects implements Serializable {
|
|||
if (ability.getSourceId().equals(sourceId)) {
|
||||
ability.setControllerId(controllerId);
|
||||
}
|
||||
} else {
|
||||
if (!ability.getZone().equals(Zone.COMMAND)) {
|
||||
logger.fatal("Continuous effect for ability with no sourceId Ability: " + ability);
|
||||
}
|
||||
} else if (!ability.getZone().equals(Zone.COMMAND)) {
|
||||
LOGGER.fatal("Continuous effect for ability with no sourceId Ability: " + ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1240,7 +1232,7 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("Replacement effect without ability: " + entry.getKey().toString());
|
||||
LOGGER.error("Replacement effect without ability: " + entry.getKey().toString());
|
||||
}
|
||||
}
|
||||
return texts;
|
||||
|
|
@ -1278,7 +1270,7 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn("Ability without sourceId:" + ability.getRule());
|
||||
LOGGER.warn("Ability without sourceId:" + ability.getRule());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class AnnihilatorAbility extends TriggeredAbilityImpl {
|
|||
class AnnihilatorEffect extends OneShotEffect {
|
||||
|
||||
private final int count;
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent();
|
||||
private static final FilterControlledPermanent FILTER = new FilterControlledPermanent();
|
||||
|
||||
AnnihilatorEffect(int count) {
|
||||
super(Outcome.Sacrifice);
|
||||
|
|
@ -124,8 +124,8 @@ class AnnihilatorEffect extends OneShotEffect {
|
|||
player = game.getPlayer(defendingPlayerId);
|
||||
}
|
||||
if (player != null) {
|
||||
int amount = Math.min(count, game.getBattlefield().countAll(filter, player.getId(), game));
|
||||
Target target = new TargetControlledPermanent(amount, amount, filter, true);
|
||||
int amount = Math.min(count, game.getBattlefield().countAll(FILTER, player.getId(), game));
|
||||
Target target = new TargetControlledPermanent(amount, amount, FILTER, true);
|
||||
if (target.canChoose(player.getId(), game)) {
|
||||
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.canRespond()) {
|
||||
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue