mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Some changes to framework classes.
This commit is contained in:
parent
97d8715488
commit
799d7b1a23
3 changed files with 11 additions and 17 deletions
|
@ -30,14 +30,14 @@ package mage.abilities.effects.common.continious;
|
|||
|
||||
import java.util.Iterator;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -101,11 +101,14 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (this.affectedObjectsSet) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
Permanent permanent = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
} else {
|
||||
it.remove(); // no longer on the battlefield, remove reference to object
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -36,7 +36,6 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -110,7 +109,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
|
|||
Permanent perm = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
|
||||
if (perm != null) {
|
||||
for (Ability abilityToAdd : ability) {
|
||||
perm.addAbility(abilityToAdd, source.getSourceId(), game, false); // new id is neccessary if
|
||||
perm.addAbility(abilityToAdd, source.getSourceId(), game, false);
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
|
|
|
@ -137,17 +137,9 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
} else {
|
||||
for (UUID permanentId : targetPointer.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
boolean shortLivingLKI = false;
|
||||
if (permanent == null) {
|
||||
permanent = (Permanent) game.getShortLivingLKI(permanentId, Zone.BATTLEFIELD);
|
||||
shortLivingLKI = true;
|
||||
}
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
if (shortLivingLKI) { // needed for undying because TriggeredAbilities checks if the permanent has still the ability
|
||||
game.rememberLKI(permanentId, Zone.BATTLEFIELD, permanent);
|
||||
}
|
||||
permanent.addAbility(ability, source.getSourceId(), game, false);
|
||||
affectedTargets++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue