[AER] Inspiring Statuary display fix (#9214)

This commit is contained in:
Alex Vasile 2022-07-08 21:37:31 -04:00 committed by GitHub
parent ea6cbcc962
commit f6ff32e38b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 62 deletions

View file

@ -9,6 +9,7 @@ import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate;
import java.util.UUID;
@ -21,13 +22,17 @@ public final class InspiringStatuary extends CardImpl {
static {
filter.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
filter.add(Predicates.not(CardType.LAND.getPredicate()));
filter.add(Predicates.not(new AbilityPredicate(ImproviseAbility.class))); // So there are not redundant copies being added to each card
}
public InspiringStatuary(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// Non-artifact spells you cast have improvise.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledSpellsEffect(new ImproviseAbility(), filter)));
ImproviseAbility improviseAbility = new ImproviseAbility();
improviseAbility.setRuleAtTheTop(false);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledSpellsEffect(improviseAbility, filter)));
}

View file

@ -41,50 +41,52 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
for (Card card : game.getExile().getAllCards(game)) {
if (card.isOwnedBy(source.getControllerId())
&& filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getLibrary().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getHand().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getGraveyard().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
if (player == null || permanent == null) {
return false;
}
// workaround to gain cost reduction abilities to commanders before cast (make it playable)
game.getCommanderCardsFromCommandZone(player, CommanderCardType.ANY)
.stream()
.filter(card -> filter.match(card, game))
.forEach(card -> {
game.getState().addOtherAbility(card, ability);
});
for (Card card : game.getExile().getAllCards(game)) {
if (card.isOwnedBy(source.getControllerId())
&& filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getLibrary().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getHand().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getGraveyard().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (StackObject stackObject : game.getStack()) {
// only spells cast, so no copies of spells
if ((stackObject instanceof Spell)
&& !stackObject.isCopy()
&& stackObject.isControlledBy(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId());
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
return true;
}
// workaround to gain cost reduction abilities to commanders before cast (make it playable)
game.getCommanderCardsFromCommandZone(player, CommanderCardType.ANY)
.stream()
.filter(card -> filter.match(card, game))
.forEach(card -> {
game.getState().addOtherAbility(card, ability);
});
for (StackObject stackObject : game.getStack()) {
// only spells cast, so no copies of spells
if ((stackObject instanceof Spell)
&& !stackObject.isCopy()
&& stackObject.isControlledBy(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId());
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
return true;
}
}
}
return false;
return false; // TODO: Why is this returning false?
}
}

View file

@ -153,28 +153,28 @@ class ImproviseEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = game.getStack().getSpell(source.getSourceId());
if (controller != null && spell != null) {
for (UUID artifactId : this.getTargetPointer().getTargets(game, source)) {
Permanent perm = game.getPermanent(artifactId);
if (perm == null) {
continue;
}
if (!perm.isTapped() && perm.tap(source, game)) {
ManaPool manaPool = controller.getManaPool();
manaPool.addMana(Mana.ColorlessMana(1), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
if (!game.isSimulation()) {
game.informPlayers("Improvise: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay {1}");
}
// can't use mana abilities after that (improvise cost must be payed after mana abilities only)
spell.setCurrentActivatingManaAbilitiesStep(ActivationManaAbilityStep.AFTER);
}
}
return true;
if (controller == null || spell == null) {
return false;
}
return false;
for (UUID artifactId : this.getTargetPointer().getTargets(game, source)) {
Permanent perm = game.getPermanent(artifactId);
if (perm == null) {
continue;
}
if (!perm.isTapped() && perm.tap(source, game)) {
ManaPool manaPool = controller.getManaPool();
manaPool.addMana(Mana.ColorlessMana(1), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
if (!game.isSimulation()) {
game.informPlayers("Improvise: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay {1}");
}
// can't use mana abilities after that (improvise cost must be payed after mana abilities only)
spell.setCurrentActivatingManaAbilitiesStep(ActivationManaAbilityStep.AFTER);
}
}
return true;
}
}