forked from External/mage
Cleanup: GainAbilityControlledSpellsEffect (#10446)
* Hide reminder text on Zhulodok * Use logic from GainAbilitySpellsEffect, fix so that CastFromZonePredicate works * Text adjustments * Show cascade ability in hand for Abaddon the Despoiler * Remove redundant class * Simplify Cast Through Time * Don't add additional instances of redundant abilities * Remove redundant check * Add option to ignore mana validation when checking playable objects * Fix null errors * Fix GainAbilityControlledSpellsEffect to apply ability to playable cards rather than owned cards * Add unit test * Revert bad workaround code This reverts commit17f5be6a79. This reverts commit7ebd2f1815. This reverts commit00969d1fe7. * Remove ownership check on exiled cards * Another test (currently failing) * ignore test * fix test: strict choose mode
This commit is contained in:
parent
90d35e0543
commit
ec4c2e2170
22 changed files with 154 additions and 226 deletions
|
|
@ -23,10 +23,10 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
|||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.ability = ability;
|
||||
this.filter = filter;
|
||||
staticText = filter.getMessage() + " you cast have " + ability.getRule() + '.';
|
||||
staticText = filter.getMessage() + " have " + ability.getRule();
|
||||
}
|
||||
|
||||
public GainAbilityControlledSpellsEffect(final GainAbilityControlledSpellsEffect effect) {
|
||||
private GainAbilityControlledSpellsEffect(final GainAbilityControlledSpellsEffect effect) {
|
||||
super(effect);
|
||||
this.ability = effect.ability;
|
||||
this.filter = effect.filter;
|
||||
|
|
@ -45,9 +45,8 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (card.isOwnedBy(source.getControllerId())
|
||||
&& filter.match(card, game)) {
|
||||
for (Card card : game.getExile().getAllCardsByRange(game, source.getControllerId())) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
|
|
@ -71,22 +70,19 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
|||
game.getCommanderCardsFromCommandZone(player, CommanderCardType.ANY)
|
||||
.stream()
|
||||
.filter(card -> filter.match(card, game))
|
||||
.forEach(card -> {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
});
|
||||
.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;
|
||||
}
|
||||
if (!(stackObject instanceof Spell) || !stackObject.isControlledBy(source.getControllerId())) {
|
||||
continue;
|
||||
}
|
||||
// TODO: Distinguish "you cast" to exclude copies
|
||||
Card card = game.getCard(stackObject.getSourceId());
|
||||
if (card == null || !filter.match((Spell) stackObject, game)) {
|
||||
continue;
|
||||
}
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
return false; // TODO: Why is this returning false?
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue