mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08: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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue