This commit is contained in:
jeffwadsworth 2020-06-09 10:04:59 -05:00
parent eb846c0499
commit 2e8ece1dbd
2 changed files with 14 additions and 3 deletions

View file

@ -13,12 +13,20 @@ import java.util.UUID;
*/
public class CantAttackYouEffect extends RestrictionEffect {
UUID controllerId;
public CantAttackYouEffect(Duration duration) {
super(duration);
}
public CantAttackYouEffect(Duration duration, UUID controllerId) {
super(duration);
this.controllerId = controllerId;
}
public CantAttackYouEffect(final CantAttackYouEffect effect) {
super(effect);
this.controllerId = effect.controllerId;
}
@Override
@ -36,6 +44,9 @@ public class CantAttackYouEffect extends RestrictionEffect {
if (defenderId == null) {
return true;
}
return !defenderId.equals(source.getControllerId());
if (controllerId == null) {
controllerId = source.getControllerId();
}
return !defenderId.equals(controllerId);
}
}

View file

@ -41,7 +41,7 @@ public class GoadTargetEffect extends OneShotEffect {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (targetCreature != null && controller != null) {
// TODO: impoves goad to allows to target controller, current AttacksIfAbleTargetEffect is not support it
// TODO: Allow goad to target controller, current AttacksIfAbleTargetEffect is not support it
// https://github.com/magefree/mage/issues/5283
/*
If the creature doesnt meet any of the above exceptions and can attack, it must attack a player other than
@ -52,7 +52,7 @@ public class GoadTargetEffect extends OneShotEffect {
ContinuousEffect effect = new AttacksIfAbleTargetEffect(Duration.UntilYourNextTurn);
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source)));
game.addEffect(effect, source);
effect = new CantAttackYouEffect(Duration.UntilYourNextTurn);
effect = new CantAttackYouEffect(Duration.UntilYourNextTurn, source.getControllerId()); // remember current controller
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source)));
game.addEffect(effect, source);
game.informPlayers(controller.getLogName() + " is goading " + targetCreature.getLogName());