* Goaded creatures able to attack the goading player (in multiplayer) (fixes #3891).

* Grenzo, Havoc Raiser - Fixed trigger handling and null pointer exception.
This commit is contained in:
LevelX2 2017-08-27 22:28:13 +02:00
parent c6543a89ff
commit ea4af25c77
2 changed files with 21 additions and 14 deletions

View file

@ -54,7 +54,9 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.ManaPoolItem;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
@ -77,7 +79,7 @@ public class GrenzoHavocRaiser extends CardImpl {
this.toughness = new MageInt(2);
// Whenever a creature you control deals combat damage to a player, choose one —
//Goad target creature that player controls;
//Goad target creature that player controls;
Effect effect = new GoadTargetEffect();
effect.setText("goad target creature that player controls");
Ability ability = new GrenzoHavocRaiserTriggeredAbility(effect);
@ -120,10 +122,13 @@ class GrenzoHavocRaiserTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null && game.getPermanent(event.getSourceId()).getControllerId() == this.controllerId) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
Player damagedPlayer = game.getPlayer(event.getPlayerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (damagedPlayer != null && permanent != null
&& ((DamageEvent) event).isCombatDamage()
&& getControllerId().equals(permanent.getControllerId())) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + damagedPlayer.getLogName() + " controls");
filter.add(new ControllerIdPredicate(damagedPlayer.getId()));
this.getTargets().clear();
this.addTarget(new TargetCreaturePermanent(filter));
for (Effect effect : this.getAllEffects()) {
@ -171,11 +176,6 @@ class GrenzoHavocRaiserEffect extends OneShotEffect {
if (card != null) {
// move card to exile
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
// player gains life
// int cmc = card.getConvertedManaCost();
// if (cmc > 0) {
// controller.gainLife(cmc, game);
// }
// Add effects only if the card has a spellAbility (e.g. not for lands).
if (card.getSpellAbility() != null) {
// allow to cast the card

View file

@ -41,6 +41,13 @@ import mage.target.targetpointer.FixedTarget;
*/
public class GoadTargetEffect extends OneShotEffect {
/**
* 701.36. Goad
*
* 701.36a Certain spells and abilities can goad a creature. Until the next
* turn of the controller of that spell or ability, that creature attacks
* each combat if able and attacks a player other than that player if able.
*/
public GoadTargetEffect() {
super(Outcome.Benefit);
}
@ -57,11 +64,11 @@ public class GoadTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
ContinuousEffect effect = new AttacksIfAbleTargetEffect(Duration.UntilYourNextTurn);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source)));
game.addEffect(effect, source);
effect = new CantAttackYouEffect(Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
effect = new CantAttackYouEffect(Duration.UntilYourNextTurn, true);
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source)));
game.addEffect(effect, source);
return true;
}
}
}