mirror of
https://github.com/correl/mage.git
synced 2024-11-29 03:00:12 +00:00
[CMR] fixed multiple copies of Imoti, Celebrant of Bounty only giving cascade once
This commit is contained in:
parent
852aa562d2
commit
f52753ad61
1 changed files with 47 additions and 42 deletions
|
@ -1,6 +1,7 @@
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.MageSingleton;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.FilterObject;
|
import mage.filter.FilterObject;
|
||||||
|
@ -21,7 +22,7 @@ public class GainAbilitySpellsEffect extends ContinuousEffectImpl {
|
||||||
staticText = filter.getMessage() + " have " + ability.getRule();
|
staticText = filter.getMessage() + " have " + ability.getRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GainAbilitySpellsEffect(final GainAbilitySpellsEffect effect) {
|
private GainAbilitySpellsEffect(final GainAbilitySpellsEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.ability = effect.ability;
|
this.ability = effect.ability;
|
||||||
this.filter = effect.filter;
|
this.filter = effect.filter;
|
||||||
|
@ -36,47 +37,51 @@ public class GainAbilitySpellsEffect extends ContinuousEffectImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
if (player != null && permanent != null) {
|
if (player == null || permanent == null) {
|
||||||
for (Card card : game.getExile().getAllCards(game)) {
|
return false;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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()) {
|
|
||||||
if (stackObject.isControlledBy(source.getControllerId())) {
|
|
||||||
Card card = game.getCard(stackObject.getSourceId());
|
|
||||||
if (card != null && filter.match(stackObject, game)) {
|
|
||||||
if (!card.hasAbility(ability, game)) {
|
|
||||||
game.getState().addOtherAbility(card, ability);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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()) {
|
||||||
|
if (!stackObject.isControlledBy(source.getControllerId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Card card = game.getCard(stackObject.getSourceId());
|
||||||
|
if (card == null || !filter.match(stackObject, game)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ability instanceof MageSingleton && card.hasAbility(ability, game)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
game.getState().addOtherAbility(card, ability);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue