Merge pull request #4450 from BenDawes/bugfix/becomesCreateAllEffectSetCalculation

Fix becomesCreatureAllEffect set calculation
This commit is contained in:
LevelX2 2018-01-27 19:03:54 +01:00 committed by GitHub
commit afaa1149e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
@ -40,6 +41,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import java.util.HashSet;
import java.util.Set;
/**
* @author LevelX2
*
@ -64,6 +68,16 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
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
public BecomesCreatureAllEffect copy() {
return new BecomesCreatureAllEffect(this);
@ -71,7 +85,15 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
@Override
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) {
switch (layer) {
case TypeChangingEffects_4: