mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Master of Diversion - Fixed a bug that the target was not set properly.
This commit is contained in:
parent
121c6687de
commit
65da75b1bc
1 changed files with 17 additions and 42 deletions
|
@ -31,16 +31,14 @@ import java.util.UUID;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.TapTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +58,8 @@ public class MasterOfDiversion extends CardImpl<MasterOfDiversion> {
|
|||
this.toughness = new MageInt(2);
|
||||
|
||||
// Whenever Master of Diversion attacks, tap target creature defending player controls.
|
||||
Ability ability = new AttacksTriggeredAbility(new MasterOfDiversionEffect(), false);
|
||||
Ability ability = new AttacksTriggeredAbility(new TapTargetEffect(), false);
|
||||
ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature defending player controls")));
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
@ -69,45 +68,21 @@ public class MasterOfDiversion extends CardImpl<MasterOfDiversion> {
|
|||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) {
|
||||
ability.getTargets().clear();
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
||||
UUID defenderId = game.getCombat().getDefendingPlayer(ability.getControllerId());
|
||||
filter.add(new ControllerIdPredicate(defenderId));
|
||||
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
|
||||
target.setRequired(true);
|
||||
ability.addTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MasterOfDiversion copy() {
|
||||
return new MasterOfDiversion(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MasterOfDiversionEffect extends OneShotEffect<MasterOfDiversionEffect> {
|
||||
|
||||
public MasterOfDiversionEffect() {
|
||||
super(Outcome.Tap);
|
||||
staticText = "tap target creature defending player controls";
|
||||
}
|
||||
|
||||
public MasterOfDiversionEffect(final MasterOfDiversionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you == null) {
|
||||
return false;
|
||||
}
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
||||
filter.add(new ControllerIdPredicate(defenderId));
|
||||
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
|
||||
target.setRequired(true);
|
||||
if (you.choose(Outcome.Tap, target, source.getId(), game)) {
|
||||
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
|
||||
if (targetCreature != null) {
|
||||
return targetCreature.tap(game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MasterOfDiversionEffect copy() {
|
||||
return new MasterOfDiversionEffect(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue