- Fixed Orator of Ojutai. Intervening If clause.

This commit is contained in:
Jeff 2017-04-24 09:25:27 -05:00
parent 1607849c19
commit 7479cd5668

View file

@ -31,9 +31,10 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.RevealTargetFromHandCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.keyword.DefenderAbility;
@ -47,6 +48,7 @@ import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
@ -65,7 +67,7 @@ public class OratorOfOjutai extends CardImpl {
}
public OratorOfOjutai(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.subtype.add("Bird");
this.subtype.add("Monk");
this.power = new MageInt(0);
@ -79,7 +81,7 @@ public class OratorOfOjutai extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("As an additional cost to cast {this}, you may reveal a Dragon card from your hand")));
// When Orator of Ojutai enters the battlefield, if you revealed a Dragon card or controlled a Dragon as you cast Orator of Ojutai, draw a card.
this.addAbility(new EntersBattlefieldTriggeredAbility(new OratorOfOjutaiEffect()), new DragonOnTheBattlefieldWhileSpellWasCastWatcher());
this.addAbility(new OratorOfOjutaiTriggeredAbility(new OratorOfOjutaiEffect()), new DragonOnTheBattlefieldWhileSpellWasCastWatcher());
}
@Override
@ -88,7 +90,7 @@ public class OratorOfOjutai extends CardImpl {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
if (controller.getHand().count(filter, game) > 0) {
ability.addCost(new RevealTargetFromHandCost(new TargetCardInHand(0,1, filter)));
ability.addCost(new RevealTargetFromHandCost(new TargetCardInHand(0, 1, filter)));
}
}
}
@ -104,6 +106,42 @@ public class OratorOfOjutai extends CardImpl {
}
}
class OratorOfOjutaiTriggeredAbility extends TriggeredAbilityImpl {
public OratorOfOjutaiTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect, false);
}
public OratorOfOjutaiTriggeredAbility(final OratorOfOjutaiTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
//Intervening if must be checked
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher");
return event.getTargetId().equals(getSourceId())
&& watcher != null
&& watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId());
}
@Override
public String getRule() {
return "When {this} enters the battlefield, " + super.getRule();
}
@Override
public OratorOfOjutaiTriggeredAbility copy() {
return new OratorOfOjutaiTriggeredAbility(this);
}
}
class OratorOfOjutaiEffect extends OneShotEffect {
public OratorOfOjutaiEffect() {
@ -122,6 +160,7 @@ class OratorOfOjutaiEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
//Intervening if is checked again on resolution
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
@ -129,9 +168,9 @@ class OratorOfOjutaiEffect extends OneShotEffect {
DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher");
if (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())) {
controller.drawCards(1, game);
return true;
}
}
return true;
}
return false;
}