mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Fixed that curses selected with Bitterheart Witch or Curse of Misfortunes could be retargeted (fixes #3858).
This commit is contained in:
parent
da797ced89
commit
04afe73f28
3 changed files with 30 additions and 26 deletions
|
@ -98,21 +98,21 @@ class BitterheartWitchEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
if (player != null && targetPlayer != null) {
|
||||
if (controller != null && targetPlayer != null) {
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary(filter);
|
||||
if (player.searchLibrary(targetCard, game)) {
|
||||
if (controller.searchLibrary(targetCard, game)) {
|
||||
Card card = game.getCard(targetCard.getFirstTarget());
|
||||
if (card != null) {
|
||||
game.getState().setValue("attachTo:" + card.getId(), targetPlayer.getId());
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
||||
targetPlayer.addAttachment(card.getId(), game);
|
||||
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
targetPlayer.addAttachment(card.getId(), game);
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.OnEventTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -51,8 +52,6 @@ import mage.target.TargetPlayer;
|
|||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward
|
||||
|
@ -97,13 +96,14 @@ class CurseOfMisfortunesEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterCard filter = new FilterCard("Curse card that doesn't have the same name as a Curse attached to enchanted player");
|
||||
filter.add(new SubtypePredicate(SubType.CURSE));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
if (controller != null && enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Player targetPlayer = game.getPlayer(enchantment.getAttachedTo());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && targetPlayer != null) {
|
||||
FilterCard filter = new FilterCard("Curse card that doesn't have the same name as a Curse attached to enchanted player");
|
||||
filter.add(new SubtypePredicate(SubType.CURSE));
|
||||
// get the names of attached Curses
|
||||
for (UUID attachmentId: targetPlayer.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
|
@ -111,19 +111,20 @@ class CurseOfMisfortunesEffect extends OneShotEffect {
|
|||
filter.add(Predicates.not(new NamePredicate(attachment.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary(filter);
|
||||
if (player.searchLibrary(targetCard, game)) {
|
||||
Card card = game.getCard(targetCard.getFirstTarget());
|
||||
if (card != null) {
|
||||
this.setTargetPointer(new FixedTarget(targetPlayer.getId()));
|
||||
game.getState().setValue("attachTo:" + card.getId(), targetPlayer.getId());
|
||||
player.shuffleLibrary(source, game);
|
||||
return card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
||||
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
targetPlayer.addAttachment(card.getId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
@ -44,8 +45,6 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Cards with the Aura subtype don't change the zone they are in, if there is no
|
||||
* valid target on the battlefield. Also, when entering the battlefield and it
|
||||
|
@ -98,19 +97,23 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
// Aura enters the battlefield attached
|
||||
Object object = game.getState().getValue("attachTo:" + card.getId());
|
||||
if (object != null && object instanceof PermanentCard) {
|
||||
return false;
|
||||
if (object != null) {
|
||||
if (object instanceof PermanentCard) {
|
||||
// Aura is attached to a permanent on the battlefield
|
||||
return false;
|
||||
}
|
||||
if (object instanceof UUID) {
|
||||
Player player = game.getPlayer((UUID) object);
|
||||
if (player != null) {
|
||||
// Aura is attached to a player
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID targetId = null;
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
boolean enchantCardInGraveyard = false;
|
||||
// if (sourceObject instanceof Spell) {
|
||||
// if (fromZone.equals(Zone.EXILED)) {
|
||||
// // cast from exile (e.g. Neightveil Spector) -> no replacement
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
if (sourceObject instanceof StackAbility) {
|
||||
StackAbility stackAbility = (StackAbility) sourceObject;
|
||||
if (!stackAbility.getEffects().isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue