mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
fixed implementation of Hunter's Insight
This commit is contained in:
parent
8bbdae4af6
commit
a07acc895e
1 changed files with 55 additions and 20 deletions
|
@ -1,37 +1,38 @@
|
||||||
|
|
||||||
package mage.cards.h;
|
package mage.cards.h;
|
||||||
|
|
||||||
import java.util.UUID;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.DelayedTriggeredAbility;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Outcome;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamagedEvent;
|
import mage.game.events.DamagedEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public final class HuntersInsight extends CardImpl {
|
public final class HuntersInsight extends CardImpl {
|
||||||
|
|
||||||
public HuntersInsight(UUID ownerId, CardSetInfo setInfo) {
|
public HuntersInsight(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}");
|
||||||
|
|
||||||
|
|
||||||
// Choose target creature you control. Whenever that creature deals combat damage to a player or planeswalker this turn, draw that many cards.
|
// Choose target creature you control. Whenever that creature deals combat damage to a player or planeswalker this turn, draw that many cards.
|
||||||
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(new HuntersInsightTriggeredAbility(), Duration.EndOfTurn));
|
this.getSpellAbility().addEffect(new HuntersInsightEffect());
|
||||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HuntersInsight(final HuntersInsight card) {
|
private HuntersInsight(final HuntersInsight card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +42,46 @@ public final class HuntersInsight extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HuntersInsightTriggeredAbility extends TriggeredAbilityImpl {
|
class HuntersInsightEffect extends OneShotEffect {
|
||||||
|
|
||||||
public HuntersInsightTriggeredAbility() {
|
HuntersInsightEffect() {
|
||||||
super(Zone.BATTLEFIELD, null, false);
|
super(Outcome.Benefit);
|
||||||
|
staticText = "Choose target creature you control. Whenever that creature deals combat damage " +
|
||||||
|
"to a player or planeswalker this turn, draw that many cards.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public HuntersInsightTriggeredAbility(final HuntersInsightTriggeredAbility ability) {
|
private HuntersInsightEffect(final HuntersInsightEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HuntersInsightEffect copy() {
|
||||||
|
return new HuntersInsightEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||||
|
if (permanent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
game.addDelayedTriggeredAbility(new HuntersInsightTriggeredAbility(new MageObjectReference(permanent, game)), source);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HuntersInsightTriggeredAbility extends DelayedTriggeredAbility {
|
||||||
|
|
||||||
|
private final MageObjectReference mor;
|
||||||
|
|
||||||
|
HuntersInsightTriggeredAbility(MageObjectReference mor) {
|
||||||
|
super(null, Duration.EndOfTurn, false, false);
|
||||||
|
this.mor = mor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HuntersInsightTriggeredAbility(final HuntersInsightTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
|
this.mor = ability.mor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,18 +91,20 @@ class HuntersInsightTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == EventType.DAMAGED_PLAYER || event.getType() == EventType.DAMAGED_PLANESWALKER;
|
return event.getType() == EventType.DAMAGED_PLAYER
|
||||||
|
|| event.getType() == EventType.DAMAGED_PLANESWALKER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getSourceId().equals(this.sourceId) && ((DamagedEvent) event).isCombatDamage()) {
|
if (!mor.refersTo(event.getSourceId(), game)
|
||||||
|
|| !((DamagedEvent) event).isCombatDamage()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.getEffects().clear();
|
this.getEffects().clear();
|
||||||
this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
|
this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
|
|
Loading…
Reference in a new issue