mirror of
https://github.com/correl/mage.git
synced 2025-01-13 19:11:33 +00:00
BecomeCreatureAllEffect used to always calculate the permanent set to apply to every time it is applied
Now we calculate it either at init-time (for abilities with affected object sets) OR at apply-time (Static abilities etc.)
This commit is contained in:
parent
1b9ee1c6c4
commit
2f4b6ca713
1 changed files with 23 additions and 1 deletions
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.effects.common.continuous;
|
package mage.abilities.effects.common.continuous;
|
||||||
|
|
||||||
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
@ -40,6 +41,9 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*
|
*
|
||||||
|
@ -64,6 +68,16 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
||||||
this.filter = effect.filter.copy();
|
this.filter = effect.filter.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Ability source, Game game) {
|
||||||
|
super.init(source, game);
|
||||||
|
if (this.affectedObjectsSet) {
|
||||||
|
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||||
|
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BecomesCreatureAllEffect copy() {
|
public BecomesCreatureAllEffect copy() {
|
||||||
return new BecomesCreatureAllEffect(this);
|
return new BecomesCreatureAllEffect(this);
|
||||||
|
@ -71,7 +85,15 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
Set<Permanent> affectedPermanents = new HashSet<>();
|
||||||
|
if (this.affectedObjectsSet) {
|
||||||
|
for(MageObjectReference ref : affectedObjectList) {
|
||||||
|
affectedPermanents.add(ref.getPermanent(game));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
affectedPermanents = new HashSet<>(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game));
|
||||||
|
}
|
||||||
|
for(Permanent permanent : affectedPermanents) {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
case TypeChangingEffects_4:
|
case TypeChangingEffects_4:
|
||||||
|
|
Loading…
Reference in a new issue