mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +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;
|
package mage.cards.b;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
|
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
|
||||||
|
@ -42,6 +45,8 @@ import mage.constants.SuperType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.filter.FilterPermanent;
|
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.CardTypePredicate;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.filter.predicate.other.AuraCardCanAttachToPermanentId;
|
import mage.filter.predicate.other.AuraCardCanAttachToPermanentId;
|
||||||
|
@ -53,14 +58,13 @@ import mage.target.Target;
|
||||||
import mage.target.TargetCard;
|
import mage.target.TargetCard;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
/**
|
/**
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public class BrunaLightOfAlabaster extends CardImpl {
|
public class BrunaLightOfAlabaster extends CardImpl {
|
||||||
|
|
||||||
public BrunaLightOfAlabaster(UUID ownerId, CardSetInfo setInfo) {
|
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);
|
addSuperType(SuperType.LEGENDARY);
|
||||||
this.subtype.add("Angel");
|
this.subtype.add("Angel");
|
||||||
|
|
||||||
|
@ -103,7 +107,7 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID bruna = source.getSourceId();
|
UUID bruna = source.getSourceId();
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
|
||||||
FilterPermanent filterAura = new FilterPermanent("Aura");
|
FilterPermanent filterAura = new FilterPermanent("Aura");
|
||||||
FilterCard filterAuraCard = new FilterCard("Aura card");
|
FilterCard filterAuraCard = new FilterCard("Aura card");
|
||||||
|
@ -115,64 +119,85 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
||||||
filterAuraCard.add(new SubtypePredicate("Aura"));
|
filterAuraCard.add(new SubtypePredicate("Aura"));
|
||||||
filterAuraCard.add(new AuraCardCanAttachToPermanentId(bruna));
|
filterAuraCard.add(new AuraCardCanAttachToPermanentId(bruna));
|
||||||
|
|
||||||
if (player == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
if (permanent == null) {
|
if (sourcePermanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
List<Permanent> fromBattlefield = new ArrayList<>();
|
||||||
|
List<Card> fromHandGraveyard = new ArrayList<>();
|
||||||
|
|
||||||
int countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - permanent.getAttachments().size();
|
int countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - sourcePermanent.getAttachments().size();
|
||||||
while (player.canRespond()
|
while (controller.canRespond()
|
||||||
&& countBattlefield > 0
|
&& 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);
|
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());
|
Permanent aura = game.getPermanent(targetAura.getFirstTarget());
|
||||||
if (aura != null) {
|
if (aura != null) {
|
||||||
|
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())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - sourcePermanent.getAttachments().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (controller.choose(Outcome.Benefit, controller.getHand(), targetAura, game)) {
|
||||||
|
Card aura = game.getCard(targetAura.getFirstTarget());
|
||||||
|
if (aura != null) {
|
||||||
|
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 = controller.getHand().count(filterAuraCard, 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 (controller.choose(Outcome.Benefit, controller.getGraveyard(), targetAura, game)) {
|
||||||
|
Card aura = game.getCard(targetAura.getFirstTarget());
|
||||||
|
if (aura != null) {
|
||||||
|
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 = controller.getGraveyard().count(filterAuraCard, game);
|
||||||
|
}
|
||||||
|
// Move permanents
|
||||||
|
for (Permanent aura : fromBattlefield) {
|
||||||
Permanent attachedTo = game.getPermanent(aura.getAttachedTo());
|
Permanent attachedTo = game.getPermanent(aura.getAttachedTo());
|
||||||
if (attachedTo != null) {
|
if (attachedTo != null) {
|
||||||
attachedTo.removeAttachment(aura.getId(), game);
|
attachedTo.removeAttachment(aura.getId(), game);
|
||||||
}
|
}
|
||||||
permanent.addAttachment(aura.getId(), game);
|
sourcePermanent.addAttachment(aura.getId(), game);
|
||||||
}
|
}
|
||||||
}
|
// Move cards
|
||||||
countBattlefield = game.getBattlefield().getAllActivePermanents(filterAura, game).size() - permanent.getAttachments().size();
|
for (Card aura : fromHandGraveyard) {
|
||||||
}
|
|
||||||
|
|
||||||
int countHand = player.getHand().count(filterAuraCard, game);
|
|
||||||
while (player.canRespond()
|
|
||||||
&& countHand > 0
|
|
||||||
&& player.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)) {
|
|
||||||
Card aura = game.getCard(targetAura.getFirstTarget());
|
|
||||||
if (aura != null) {
|
if (aura != null) {
|
||||||
game.getState().setValue("attachTo:" + aura.getId(), permanent);
|
game.getState().setValue("attachTo:" + aura.getId(), sourcePermanent);
|
||||||
aura.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
|
controller.moveCards(aura, Zone.BATTLEFIELD, source, game);
|
||||||
permanent.addAttachment(aura.getId(), game);
|
sourcePermanent.addAttachment(aura.getId(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
countHand = player.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)) {
|
|
||||||
TargetCard targetAura = new TargetCard(Zone.GRAVEYARD, filterAuraCard);
|
|
||||||
if (player.choose(Outcome.Benefit, player.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
countGraveyard = player.getGraveyard().count(filterAuraCard, game);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue