This commit is contained in:
Jeff 2019-03-21 16:21:46 -05:00
parent 04cb20f46a
commit 263c9acfcc
3 changed files with 23 additions and 9 deletions

View file

@ -1,4 +1,3 @@
package mage.cards.c; package mage.cards.c;
import java.util.Objects; import java.util.Objects;
@ -44,11 +43,20 @@ public final class CrownOfDoom extends CardImpl {
// Whenever a creature attacks you or a planeswalker you control, it gets +2/+0 until end of turn. // Whenever a creature attacks you or a planeswalker you control, it gets +2/+0 until end of turn.
Effect effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn); Effect effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn);
effect.setText("it gets +2/+0 until end of turn"); effect.setText("it gets +2/+0 until end of turn");
this.addAbility(new AttacksAllTriggeredAbility(effect, false, StaticFilters.FILTER_PERMANENT_CREATURE, SetTargetPointer.PERMANENT, true)); this.addAbility(new AttacksAllTriggeredAbility(
effect,
false,
StaticFilters.FILTER_PERMANENT_CREATURE,
SetTargetPointer.PERMANENT,
true));
//TODO: Make ability properly copiable //TODO: Make ability properly copiable
// {2}: Target player other than Crown of Doom's owner gains control of it. Activate this ability only during your turn. // {2}: Target player other than Crown of Doom's owner gains control of it. Activate this ability only during your turn.
Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD, new CrownOfDoomEffect(), new ManaCostsImpl("{2}"), MyTurnCondition.instance); Ability ability = new ActivateIfConditionActivatedAbility(
Zone.BATTLEFIELD,
new CrownOfDoomEffect(),
new ManaCostsImpl("{2}"),
MyTurnCondition.instance);
ability.addTarget(new TargetPlayer(1, 1, false, filter)); ability.addTarget(new TargetPlayer(1, 1, false, filter));
this.addAbility(ability); this.addAbility(ability);
} }
@ -104,8 +112,9 @@ class CrownOfDoomEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player newController = game.getPlayer(getTargetPointer().getFirst(game, source)); Player newController = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && newController != null && !Objects.equals(controller.getId(), newController.getId())) { if (controller != null
// Duration.Custom = effect ends if Artifact leaves the current zone (battlefield) && newController != null
&& !Objects.equals(controller.getId(), newController.getId())) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, newController.getId()); ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, newController.getId());
effect.setTargetPointer(new FixedTarget(source.getSourceId())); effect.setTargetPointer(new FixedTarget(source.getSourceId()));
game.addEffect(effect, source); game.addEffect(effect, source);

View file

@ -35,13 +35,17 @@ public class ControlEnchantedEffect 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) {
Permanent enchantment = game.getPermanent(source.getSourceId()); Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) { if (enchantment != null
&& enchantment.getAttachedTo() != null) {
Permanent permanent = game.getPermanent(enchantment.getAttachedTo()); Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
if (permanent != null) { if (permanent != null) {
switch (layer) { switch (layer) {
case ControlChangingEffects_2: case ControlChangingEffects_2:
if (sublayer == SubLayer.NA) { if (sublayer == SubLayer.NA) {
permanent.changeControllerId(enchantment.getControllerId(), game); permanent.changeControllerId(enchantment.getControllerId(), game);
permanent.getAbilities().forEach((ability) -> {
ability.setControllerId(enchantment.getControllerId());
});
} }
break; break;
} }

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import java.util.UUID; import java.util.UUID;
@ -98,12 +97,14 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
} }
} }
} }
if (!targetStillExists) { // no valid target exists and the controller is no longer in the game, effect can be discarded
// no valid target exists, effect can be discarded if (!targetStillExists
|| !controller.isInGame()) {
discard(); discard();
} }
return true; return true;
} }
discard(); // controller no longer exists
return false; return false;
} }