mirror of
https://github.com/correl/mage.git
synced 2025-01-13 19:11:33 +00: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
|
@ -1,28 +1,29 @@
|
|||
package mage.cards.b;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.continuous.GainControlAllOwnedEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.card.OwnerIdPredicate;
|
||||
import mage.filter.predicate.permanent.TokenPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class BroodingSaurian extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("nontoken permanents");
|
||||
|
||||
static {
|
||||
filter.add(TokenPredicate.FALSE);
|
||||
}
|
||||
|
||||
public BroodingSaurian(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
|
||||
this.subtype.add(SubType.LIZARD);
|
||||
|
@ -31,7 +32,9 @@ public final class BroodingSaurian extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// At the beginning of each end step, each player gains control of all nontoken permanents they own.
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(new BroodingSaurianControlEffect(), TargetController.ANY, false));
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(
|
||||
new GainControlAllOwnedEffect(filter), TargetController.ANY, false
|
||||
));
|
||||
}
|
||||
|
||||
private BroodingSaurian(final BroodingSaurian card) {
|
||||
|
@ -43,60 +46,3 @@ public final class BroodingSaurian extends CardImpl {
|
|||
return new BroodingSaurian(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BroodingSaurianControlEffect extends ContinuousEffectImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent();
|
||||
|
||||
static {
|
||||
filter.add(TokenPredicate.FALSE);
|
||||
}
|
||||
|
||||
public BroodingSaurianControlEffect() {
|
||||
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.staticText = "each player gains control of all nontoken permanents they own";
|
||||
}
|
||||
|
||||
public BroodingSaurianControlEffect(final BroodingSaurianControlEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BroodingSaurianControlEffect copy() {
|
||||
return new BroodingSaurianControlEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
// add all creatures in range
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
FilterPermanent playerFilter = filter.copy();
|
||||
playerFilter.add(new OwnerIdPredicate(playerId));
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
if (!creature.isControlledBy(creature.getOwnerId())) {
|
||||
creature.changeControllerId(creature.getOwnerId(), game, source);
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
44
Mage.Sets/src/mage/cards/f/FragmentOfKonda.java
Normal file
44
Mage.Sets/src/mage/cards/f/FragmentOfKonda.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package mage.cards.f;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.DiesSourceTriggeredAbility;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class FragmentOfKonda extends CardImpl {
|
||||
|
||||
public FragmentOfKonda(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "");
|
||||
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.NOBLE);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(3);
|
||||
this.color.setWhite(true);
|
||||
this.nightCard = true;
|
||||
|
||||
// Defender
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
|
||||
// When Fragment of Konda dies, draw a card.
|
||||
this.addAbility(new DiesSourceTriggeredAbility(new DrawCardSourceControllerEffect(1)));
|
||||
}
|
||||
|
||||
private FragmentOfKonda(final FragmentOfKonda card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FragmentOfKonda copy() {
|
||||
return new FragmentOfKonda(this);
|
||||
}
|
||||
}
|
|
@ -1,43 +1,31 @@
|
|||
|
||||
package mage.cards.h;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.continuous.GainControlAllOwnedEffect;
|
||||
import mage.abilities.mana.ColorlessManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.card.OwnerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.filter.StaticFilters;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class HomewardPath extends CardImpl {
|
||||
|
||||
public HomewardPath(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||
|
||||
// {tap}: Add {C}.
|
||||
this.addAbility(new ColorlessManaAbility());
|
||||
// {tap}: Each player gains control of all creatures they own.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new HomewardPathControlEffect(), new TapSourceCost()));
|
||||
|
||||
// {tap}: Each player gains control of all creatures they own.
|
||||
this.addAbility(new SimpleActivatedAbility(new GainControlAllOwnedEffect(
|
||||
StaticFilters.FILTER_PERMANENT_CREATURES
|
||||
), new TapSourceCost()));
|
||||
}
|
||||
|
||||
private HomewardPath(final HomewardPath card) {
|
||||
|
@ -49,56 +37,3 @@ public final class HomewardPath extends CardImpl {
|
|||
return new HomewardPath(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HomewardPathControlEffect extends ContinuousEffectImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
public HomewardPathControlEffect() {
|
||||
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.staticText = "Each player gains control of all creatures they own";
|
||||
}
|
||||
|
||||
public HomewardPathControlEffect(final HomewardPathControlEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HomewardPathControlEffect copy() {
|
||||
return new HomewardPathControlEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
// add all creatures in range
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
FilterPermanent playerFilter = filter.copy();
|
||||
playerFilter.add(new OwnerIdPredicate(playerId));
|
||||
for (Permanent permanent :game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
if (!creature.isControlledBy(creature.getOwnerId())) {
|
||||
creature.changeControllerId(creature.getOwnerId(), game, source);
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
73
Mage.Sets/src/mage/cards/t/TheFallOfLordKonda.java
Normal file
73
Mage.Sets/src/mage/cards/t/TheFallOfLordKonda.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.abilities.common.SagaAbility;
|
||||
import mage.abilities.effects.common.ExileSagaAndReturnTransformedEffect;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlAllOwnedEffect;
|
||||
import mage.abilities.keyword.TransformAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.SagaChapter;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterOpponentsCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class TheFallOfLordKonda extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter
|
||||
= new FilterOpponentsCreaturePermanent("creature an opponent controls with mana value 4 or greater");
|
||||
|
||||
static {
|
||||
filter.add(new ManaValuePredicate(ComparisonType.MORE_THAN, 3));
|
||||
}
|
||||
|
||||
public TheFallOfLordKonda(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||
|
||||
this.subtype.add(SubType.SAGA);
|
||||
this.secondSideCardClazz = mage.cards.f.FragmentOfKonda.class;
|
||||
|
||||
// (As this Saga enters and after your draw step, add a lore counter.)
|
||||
SagaAbility sagaAbility = new SagaAbility(this);
|
||||
|
||||
// I — Exile target creature an opponent controls with mana value 4 or greater.
|
||||
sagaAbility.addChapterEffect(
|
||||
this, SagaChapter.CHAPTER_I, SagaChapter.CHAPTER_I,
|
||||
new ExileTargetEffect(), new TargetPermanent(filter)
|
||||
);
|
||||
|
||||
// II — Each player gains control of all permanents they own.
|
||||
sagaAbility.addChapterEffect(
|
||||
this, SagaChapter.CHAPTER_II, SagaChapter.CHAPTER_II,
|
||||
new GainControlAllOwnedEffect(StaticFilters.FILTER_PERMANENTS)
|
||||
);
|
||||
|
||||
// III — Exile this Saga, then return it to the battlefield transformed under your control.
|
||||
this.addAbility(new TransformAbility());
|
||||
sagaAbility.addChapterEffect(
|
||||
this, SagaChapter.CHAPTER_III,
|
||||
new ExileSagaAndReturnTransformedEffect()
|
||||
);
|
||||
|
||||
this.addAbility(sagaAbility);
|
||||
}
|
||||
|
||||
private TheFallOfLordKonda(final TheFallOfLordKonda card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TheFallOfLordKonda copy() {
|
||||
return new TheFallOfLordKonda(this);
|
||||
}
|
||||
}
|
|
@ -1,37 +1,21 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostControlledEffect;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.abilities.effects.common.continuous.GainControlAllOwnedEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.card.OwnerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.permanent.token.SoldierLifelinkToken;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class TrostaniDiscordant extends CardImpl {
|
||||
|
@ -45,12 +29,9 @@ public final class TrostaniDiscordant extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// Other creatures you control get +1/+1.
|
||||
this.addAbility(new SimpleStaticAbility(
|
||||
Zone.BATTLEFIELD,
|
||||
new BoostControlledEffect(
|
||||
1, 1, Duration.WhileOnBattlefield, true
|
||||
)
|
||||
));
|
||||
this.addAbility(new SimpleStaticAbility(new BoostControlledEffect(
|
||||
1, 1, Duration.WhileOnBattlefield, true
|
||||
)));
|
||||
|
||||
// When Trostani Discordant enters the battlefield, create two 1/1 white Soldier creature tokens with lifelink.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(
|
||||
|
@ -59,7 +40,8 @@ public final class TrostaniDiscordant extends CardImpl {
|
|||
|
||||
// At the beginning of your end step, each player gains control of all creatures they own.
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(
|
||||
new TrostaniDiscordantEffect(), TargetController.YOU, false
|
||||
new GainControlAllOwnedEffect(StaticFilters.FILTER_PERMANENT_CREATURES),
|
||||
TargetController.YOU, false
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -72,54 +54,3 @@ public final class TrostaniDiscordant extends CardImpl {
|
|||
return new TrostaniDiscordant(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TrostaniDiscordantEffect extends ContinuousEffectImpl {
|
||||
|
||||
public TrostaniDiscordantEffect() {
|
||||
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.staticText = "each player gains control of all creatures they own";
|
||||
}
|
||||
|
||||
public TrostaniDiscordantEffect(final TrostaniDiscordantEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrostaniDiscordantEffect copy() {
|
||||
return new TrostaniDiscordantEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
// add all creatures in range
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
FilterPermanent playerFilter = new FilterCreaturePermanent();
|
||||
playerFilter.add(new OwnerIdPredicate(playerId));
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
if (!creature.isControlledBy(creature.getOwnerId())) {
|
||||
creature.changeControllerId(creature.getOwnerId(), game, source);
|
||||
}
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (affectedObjectList.isEmpty()) {
|
||||
this.discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Essence Capture", 52, Rarity.UNCOMMON, mage.cards.e.EssenceCapture.class));
|
||||
cards.add(new SetCardInfo("Fang of Shigeki", 183, Rarity.COMMON, mage.cards.f.FangOfShigeki.class));
|
||||
cards.add(new SetCardInfo("Forest", 291, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Fragment of Konda", 12, Rarity.UNCOMMON, mage.cards.f.FragmentOfKonda.class));
|
||||
cards.add(new SetCardInfo("Futurist Operative", 53, Rarity.UNCOMMON, mage.cards.f.FuturistOperative.class));
|
||||
cards.add(new SetCardInfo("Generous Visitor", 185, Rarity.UNCOMMON, mage.cards.g.GenerousVisitor.class));
|
||||
cards.add(new SetCardInfo("Geothermal Kami", 186, Rarity.COMMON, mage.cards.g.GeothermalKami.class));
|
||||
|
@ -115,6 +116,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Surgehacker Mech", 260, Rarity.RARE, mage.cards.s.SurgehackerMech.class));
|
||||
cards.add(new SetCardInfo("Swamp", 287, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Tempered in Solitude", 165, Rarity.UNCOMMON, mage.cards.t.TemperedInSolitude.class));
|
||||
cards.add(new SetCardInfo("The Fall of Lord Konda", 12, Rarity.UNCOMMON, mage.cards.t.TheFallOfLordKonda.class));
|
||||
cards.add(new SetCardInfo("The Modern Age", 66, Rarity.COMMON, mage.cards.t.TheModernAge.class));
|
||||
cards.add(new SetCardInfo("The Shattered States Era", 162, Rarity.COMMON, mage.cards.t.TheShatteredStatesEra.class));
|
||||
cards.add(new SetCardInfo("The Wandering Emperor", 42, Rarity.MYTHIC, mage.cards.t.TheWanderingEmperor.class));
|
||||
|
|
|
@ -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…
Reference in a new issue