mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Bruna, Light of Alabaster - Fixed that the check what aura could be selected was not correct (e.g. Daybreak Coronet condition) fixes #3335.
This commit is contained in:
parent
ca9f596e4a
commit
c26968a096
1 changed files with 63 additions and 38 deletions
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
|
||||
|
@ -42,6 +45,8 @@ import mage.constants.SuperType;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardIdPredicate;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.other.AuraCardCanAttachToPermanentId;
|
||||
|
@ -53,14 +58,13 @@ import mage.target.Target;
|
|||
import mage.target.TargetCard;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
public class BrunaLightOfAlabaster extends CardImpl {
|
||||
|
||||
public BrunaLightOfAlabaster(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}{U}");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.subtype.add("Angel");
|
||||
|
||||
|
@ -103,8 +107,8 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
UUID bruna = source.getSourceId();
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
||||
FilterPermanent filterAura = new FilterPermanent("Aura");
|
||||
FilterCard filterAuraCard = new FilterCard("Aura card");
|
||||
|
||||
|
@ -114,65 +118,86 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
|||
filterAuraCard.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
filterAuraCard.add(new SubtypePredicate("Aura"));
|
||||
filterAuraCard.add(new AuraCardCanAttachToPermanentId(bruna));
|
||||
|
||||
if (player == null) {
|
||||
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - permanent.getAttachments().size();
|
||||
while (player.canRespond()
|
||||
List<Permanent> fromBattlefield = new ArrayList<>();
|
||||
List<Card> fromHandGraveyard = new ArrayList<>();
|
||||
|
||||
int countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - sourcePermanent.getAttachments().size();
|
||||
while (controller.canRespond()
|
||||
&& countBattlefield > 0
|
||||
&& player.chooseUse(Outcome.Benefit, "Attach an Aura from the battlefield?", source, game)) {
|
||||
&& controller.chooseUse(Outcome.Benefit, "Attach an Aura from the battlefield?", source, game)) {
|
||||
Target targetAura = new TargetPermanent(filterAura);
|
||||
if (player.choose(Outcome.Benefit, targetAura, source.getSourceId(), game)) {
|
||||
if (controller.choose(Outcome.Benefit, targetAura, source.getSourceId(), game)) {
|
||||
Permanent aura = game.getPermanent(targetAura.getFirstTarget());
|
||||
if (aura != null) {
|
||||
Permanent attachedTo = game.getPermanent(aura.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
attachedTo.removeAttachment(aura.getId(), game);
|
||||
Target target = aura.getSpellAbility().getTargets().get(0);
|
||||
if (target != null && target.canTarget(source.getSourceId(), source, game)) {
|
||||
fromBattlefield.add(aura);
|
||||
filterAura.add(Predicates.not(new CardIdPredicate(aura.getId())));
|
||||
}
|
||||
permanent.addAttachment(aura.getId(), game);
|
||||
}
|
||||
}
|
||||
countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - permanent.getAttachments().size();
|
||||
countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - sourcePermanent.getAttachments().size();
|
||||
}
|
||||
|
||||
int countHand = player.getHand().count(filterAuraCard, game);
|
||||
while (player.canRespond()
|
||||
&& countHand > 0
|
||||
&& player.chooseUse(Outcome.Benefit, "Attach an Aura from your hand?", source, game)) {
|
||||
int countHand = controller.getHand().count(filterAuraCard, game);
|
||||
while (controller.canRespond()
|
||||
&& countHand > 0
|
||||
&& controller.chooseUse(Outcome.Benefit, "Attach an Aura from your hand?", source, game)) {
|
||||
TargetCard targetAura = new TargetCard(Zone.HAND, filterAuraCard);
|
||||
if (player.choose(Outcome.Benefit, player.getHand(), targetAura, game)) {
|
||||
if (controller.choose(Outcome.Benefit, controller.getHand(), targetAura, game)) {
|
||||
Card aura = game.getCard(targetAura.getFirstTarget());
|
||||
if (aura != null) {
|
||||
game.getState().setValue("attachTo:" + aura.getId(), permanent);
|
||||
aura.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
|
||||
permanent.addAttachment(aura.getId(), game);
|
||||
Target target = aura.getSpellAbility().getTargets().get(0);
|
||||
if (target != null && target.canTarget(source.getSourceId(), source, game)) {
|
||||
fromHandGraveyard.add(aura);
|
||||
filterAuraCard.add(Predicates.not(new CardIdPredicate(aura.getId())));
|
||||
}
|
||||
}
|
||||
}
|
||||
countHand = player.getHand().count(filterAuraCard, game);
|
||||
countHand = controller.getHand().count(filterAuraCard, game);
|
||||
}
|
||||
|
||||
int countGraveyard = player.getGraveyard().count(filterAuraCard, game);
|
||||
while (player.canRespond()
|
||||
&& countGraveyard > 0
|
||||
&& player.chooseUse(Outcome.Benefit, "Attach an Aura from your graveyard?", source, game)) {
|
||||
int countGraveyard = controller.getGraveyard().count(filterAuraCard, game);
|
||||
while (controller.canRespond()
|
||||
&& countGraveyard > 0
|
||||
&& controller.chooseUse(Outcome.Benefit, "Attach an Aura from your graveyard?", source, game)) {
|
||||
TargetCard targetAura = new TargetCard(Zone.GRAVEYARD, filterAuraCard);
|
||||
if (player.choose(Outcome.Benefit, player.getGraveyard(), targetAura, game)) {
|
||||
if (controller.choose(Outcome.Benefit, controller.getGraveyard(), targetAura, game)) {
|
||||
Card aura = game.getCard(targetAura.getFirstTarget());
|
||||
if (aura != null) {
|
||||
game.getState().setValue("attachTo:" + aura.getId(), permanent);
|
||||
aura.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), player.getId());
|
||||
permanent.addAttachment(aura.getId(), game);
|
||||
Target target = aura.getSpellAbility().getTargets().get(0);
|
||||
if (target != null && target.canTarget(source.getSourceId(), source, game)) {
|
||||
fromHandGraveyard.add(aura);
|
||||
filterAuraCard.add(Predicates.not(new CardIdPredicate(aura.getId())));
|
||||
}
|
||||
}
|
||||
}
|
||||
countGraveyard = player.getGraveyard().count(filterAuraCard, game);
|
||||
countGraveyard = controller.getGraveyard().count(filterAuraCard, game);
|
||||
}
|
||||
// Move permanents
|
||||
for (Permanent aura : fromBattlefield) {
|
||||
Permanent attachedTo = game.getPermanent(aura.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
attachedTo.removeAttachment(aura.getId(), game);
|
||||
}
|
||||
sourcePermanent.addAttachment(aura.getId(), game);
|
||||
}
|
||||
// Move cards
|
||||
for (Card aura : fromHandGraveyard) {
|
||||
if (aura != null) {
|
||||
game.getState().setValue("attachTo:" + aura.getId(), sourcePermanent);
|
||||
controller.moveCards(aura, Zone.BATTLEFIELD, source, game);
|
||||
sourcePermanent.addAttachment(aura.getId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue