mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
parent
04cb20f46a
commit
263c9acfcc
3 changed files with 23 additions and 9 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.c;
|
||||
|
||||
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.
|
||||
Effect effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn);
|
||||
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
|
||||
// {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));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -104,8 +112,9 @@ class CrownOfDoomEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player newController = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (controller != null && newController != null && !Objects.equals(controller.getId(), newController.getId())) {
|
||||
// Duration.Custom = effect ends if Artifact leaves the current zone (battlefield)
|
||||
if (controller != null
|
||||
&& newController != null
|
||||
&& !Objects.equals(controller.getId(), newController.getId())) {
|
||||
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, newController.getId());
|
||||
effect.setTargetPointer(new FixedTarget(source.getSourceId()));
|
||||
game.addEffect(effect, source);
|
||||
|
|
|
@ -35,13 +35,17 @@ public class ControlEnchantedEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
if (enchantment != null
|
||||
&& enchantment.getAttachedTo() != null) {
|
||||
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case ControlChangingEffects_2:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.changeControllerId(enchantment.getControllerId(), game);
|
||||
permanent.getAbilities().forEach((ability) -> {
|
||||
ability.setControllerId(enchantment.getControllerId());
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -98,12 +97,14 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!targetStillExists) {
|
||||
// no valid target exists, effect can be discarded
|
||||
// no valid target exists and the controller is no longer in the game, effect can be discarded
|
||||
if (!targetStillExists
|
||||
|| !controller.isInGame()) {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
discard(); // controller no longer exists
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue