mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
[NEO] Implemented The Fall of Lord Konda / Fragment of Konda
This commit is contained in:
parent
6343866b41
commit
076b08d07b
7 changed files with 219 additions and 222 deletions
|
|
@ -0,0 +1,66 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
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;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class GainControlAllOwnedEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public GainControlAllOwnedEffect(FilterPermanent filter) {
|
||||
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.filter = filter;
|
||||
this.staticText = "each player gains control of all " + filter + " they own";
|
||||
}
|
||||
|
||||
public GainControlAllOwnedEffect(final GainControlAllOwnedEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainControlAllOwnedEffect copy() {
|
||||
return new GainControlAllOwnedEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
filter, source.getControllerId(), source.getSourceId(), game
|
||||
)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent == null) {
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
if (!permanent.isControlledBy(permanent.getOwnerId())) {
|
||||
permanent.changeControllerId(permanent.getOwnerId(), game, source);
|
||||
}
|
||||
}
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue