- Fixed Preacher

This commit is contained in:
Jeff 2019-03-15 09:22:07 -05:00
parent 9aae8c8db7
commit da5058d0ab

View file

@ -1,4 +1,3 @@
package mage.cards.p;
import java.util.UUID;
@ -25,6 +24,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponentsChoicePermanent;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -33,7 +33,7 @@ import mage.target.common.TargetOpponentsChoicePermanent;
public final class Preacher extends CardImpl {
public Preacher(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.CLERIC);
this.power = new MageInt(1);
@ -45,7 +45,6 @@ public final class Preacher extends CardImpl {
// {tap}: Gain control of target creature of an opponent's choice that he or she controls for as long as Preacher remains tapped.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreacherEffect(), new TapSourceCost());
ability.addTarget(new TargetOpponentsChoicePermanent(1, 1, new FilterControlledCreaturePermanent(), false, true));
this.addAbility(ability);
}
@ -60,7 +59,6 @@ public final class Preacher extends CardImpl {
}
}
class PreacherEffect extends OneShotEffect {
public PreacherEffect() {
@ -79,25 +77,22 @@ class PreacherEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && sourcePermanent != null
&& controller.getId().equals(sourcePermanent.getControllerId())) {
UUID target = source.getFirstTarget();
if (target != null && game.getPermanent(target) != null) {
Permanent targetPermanent = game.getPermanent(target);
SourceHasRemainedInSameZoneCondition condition = new SourceHasRemainedInSameZoneCondition(sourcePermanent.getId());
SourceHasRemainedInSameZoneCondition conditionTarget = new SourceHasRemainedInSameZoneCondition(target);
if (controller != null
&& sourcePermanent != null) {
Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
if (targetPermanent != null) {
SourceTappedCondition sourceTappedCondition = SourceTappedCondition.instance;
SourceHasRemainedInSameZoneCondition conditionSourceSameZone = new SourceHasRemainedInSameZoneCondition(sourcePermanent.getId());
SourceHasRemainedInSameZoneCondition conditionTargetSameZone = new SourceHasRemainedInSameZoneCondition(targetPermanent.getId());
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(
new GainControlTargetEffect(Duration.Custom),
new CompoundCondition(SourceTappedCondition.instance, new CompoundCondition (condition, conditionTarget)),
new CompoundCondition(sourceTappedCondition, new CompoundCondition(conditionSourceSameZone, conditionTargetSameZone)),
"Gain control of target creature of an opponent's choice that he or she controls for as long as {this} remains tapped");
effect.setTargetPointer(new FixedTarget(targetPermanent.getId()));
game.addEffect(effect, source);
return true;
}
}
return false;