* Gruul Ragebeast - added your fighting creature name to stack trigger as additional hint and arrow (#6918);

This commit is contained in:
Oleg Agafonov 2020-12-16 19:51:05 +04:00
parent 2beffbae89
commit 9c56ff90d3
2 changed files with 33 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package mage.cards.g;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -11,9 +12,12 @@ import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.common.TargetOpponentsCreaturePermanent; import mage.target.common.TargetOpponentsCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -49,7 +53,8 @@ class GruulRagebeastTriggeredAbility extends TriggeredAbilityImpl {
GruulRagebeastTriggeredAbility() { GruulRagebeastTriggeredAbility() {
super(Zone.BATTLEFIELD, new GruulRagebeastEffect(), false); super(Zone.BATTLEFIELD, new GruulRagebeastEffect(), false);
this.addTarget(new TargetOpponentsCreaturePermanent()); this.addTarget(new TargetOpponentsCreaturePermanent().withChooseHint("for fighting"));
this.addTarget(new TargetPermanent(1, 1, StaticFilters.FILTER_PERMANENT, true)); // for info only
} }
private GruulRagebeastTriggeredAbility(final GruulRagebeastTriggeredAbility ability) { private GruulRagebeastTriggeredAbility(final GruulRagebeastTriggeredAbility ability) {
@ -70,13 +75,21 @@ class GruulRagebeastTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
UUID targetId = event.getTargetId(); UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (permanent != null Permanent sourceObject = game.getPermanent(this.getSourceId());
if (sourceObject != null
&& permanent != null
&& permanent.isControlledBy(this.getControllerId()) && permanent.isControlledBy(this.getControllerId())
&& permanent.isCreature() && permanent.isCreature()) {
&& (targetId.equals(this.getSourceId())
|| !targetId.equals(this.getSourceId()))) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
if (effect instanceof GruulRagebeastEffect) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId()));
// triggered creature info stores as target
Target targetInfo = this.getTargets().get(1);
targetInfo.clearChosen();
targetInfo.add(permanent.getId(), game);
targetInfo.withChooseHint(permanent.getLogName());
}
} }
return true; return true;
} }
@ -85,7 +98,7 @@ class GruulRagebeastTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public String getRule() { public String getRule() {
return "Whenever {this} or another creature enters the battlefield under your control, that creature fights target creature an opponent controls."; return "Whenever {this} or another creature enters the battlefield under your control, " + super.getRule();
} }
} }
@ -101,6 +114,7 @@ class GruulRagebeastEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
// second target for info only, so use only first
Permanent triggeredCreature = game.getPermanent(targetPointer.getFirst(game, source)); Permanent triggeredCreature = game.getPermanent(targetPointer.getFirst(game, source));
Permanent target = game.getPermanent(source.getFirstTarget()); Permanent target = game.getPermanent(source.getFirstTarget());
if (triggeredCreature != null if (triggeredCreature != null
@ -116,4 +130,13 @@ class GruulRagebeastEffect extends OneShotEffect {
public GruulRagebeastEffect copy() { public GruulRagebeastEffect copy() {
return new GruulRagebeastEffect(this); return new GruulRagebeastEffect(this);
} }
@Override
public String getText(Mode mode) {
// additional info for stack ability about triggered permanent (it store info in second target)
Target target = mode.getTargets().get(1);
String info = (target.getChooseHint() == null ? "" : " (your fighting creature: " + target.getChooseHint() + ")");
return "that creature fights target creature an opponent controls" + info;
}
} }

View file

@ -13,6 +13,9 @@ import java.util.*;
* Calcs commanders play count only from command zone (spell or land) * Calcs commanders play count only from command zone (spell or land)
* Cards like Remand can put command to hand and cast it without commander tax increase * Cards like Remand can put command to hand and cast it without commander tax increase
* *
* Warning, if your code can be called in non commander games then you must watcher in your ability
* (example: you are using watcher in trigger, hint or effect, but do not checking another things like commander source or cost)
*
* @author JayDi85 * @author JayDi85
*/ */
public class CommanderPlaysCountWatcher extends Watcher { public class CommanderPlaysCountWatcher extends Watcher {