diff --git a/Mage.Sets/src/mage/sets/magic2011/BloodcrazedGoblin.java b/Mage.Sets/src/mage/sets/magic2011/BloodcrazedGoblin.java index 32249715b4b..07d6d6d2340 100644 --- a/Mage.Sets/src/mage/sets/magic2011/BloodcrazedGoblin.java +++ b/Mage.Sets/src/mage/sets/magic2011/BloodcrazedGoblin.java @@ -31,23 +31,21 @@ package mage.sets.magic2011; import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; -import mage.Constants.Outcome; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.cards.CardImpl; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; import mage.watchers.Watcher; -import mage.watchers.WatcherImpl; /** * * @author BetaSteward_at_googlemail.com + * @author North */ public class BloodcrazedGoblin extends CardImpl { @@ -74,40 +72,33 @@ public class BloodcrazedGoblin extends CardImpl { } -class BloodcrazedGoblinEffect extends ReplacementEffectImpl { +class BloodcrazedGoblinEffect extends RestrictionEffect { - public BloodcrazedGoblinEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = "{this} can't attack unless an opponent has been dealt damage this turn"; - } + public BloodcrazedGoblinEffect() { + super(Duration.WhileOnBattlefield); + staticText = "{this} can't attack unless an opponent has been dealt damage this turn"; + } - public BloodcrazedGoblinEffect(final BloodcrazedGoblinEffect effect) { - super(effect); - } + public BloodcrazedGoblinEffect(final BloodcrazedGoblinEffect effect) { + super(effect); + } - @Override - public BloodcrazedGoblinEffect copy() { - return new BloodcrazedGoblinEffect(this); - } + @Override + public BloodcrazedGoblinEffect copy() { + return new BloodcrazedGoblinEffect(this); + } - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) { - Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents"); - if (watcher != null) - return !watcher.conditionMet(); - } - return false; - } + @Override + public boolean canAttack(Game game) { + return false; + } + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents"); + if (watcher != null) { + return !watcher.conditionMet(); + } + return false; + } } diff --git a/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java b/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java index 6d3e69986ca..9264d4b31fa 100644 --- a/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java +++ b/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java @@ -25,98 +25,81 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.magic2011; import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; -import mage.Constants.Outcome; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.abilities.keyword.IslandwalkAbility; import mage.cards.CardImpl; -import mage.filter.Filter.ComparisonScope; import mage.filter.common.FilterLandPermanent; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; /** * * @author BetaSteward_at_googlemail.com + * @author North */ public class HarborSerpent extends CardImpl { - public HarborSerpent(UUID ownerId) { - super(ownerId, 56, "Harbor Serpent", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}{U}"); - this.expansionSetCode = "M11"; - this.subtype.add("Serpent"); - this.color.setBlue(true); - this.power = new MageInt(5); - this.toughness = new MageInt(5); + public HarborSerpent(UUID ownerId) { + super(ownerId, 56, "Harbor Serpent", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}{U}"); + this.expansionSetCode = "M11"; + this.subtype.add("Serpent"); + this.color.setBlue(true); + this.power = new MageInt(5); + this.toughness = new MageInt(5); - this.addAbility(new IslandwalkAbility()); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HarborSerpentEffect())); - } + this.addAbility(new IslandwalkAbility()); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HarborSerpentEffect())); + } - public HarborSerpent(final HarborSerpent card) { - super(card); - } - - @Override - public HarborSerpent copy() { - return new HarborSerpent(this); - } + public HarborSerpent(final HarborSerpent card) { + super(card); + } + @Override + public HarborSerpent copy() { + return new HarborSerpent(this); + } } -class HarborSerpentEffect extends ReplacementEffectImpl { +class HarborSerpentEffect extends RestrictionEffect { - private static final FilterLandPermanent filter = new FilterLandPermanent("Island"); + private final FilterLandPermanent filter = new FilterLandPermanent("Island"); - static { - filter.getSubtype().add("Island"); - filter.setScopeSubtype(ComparisonScope.Any); - } + public HarborSerpentEffect() { + super(Duration.WhileOnBattlefield); + filter.getSubtype().add("Island"); + staticText = "{this} can't attack unless there are five or more Islands on the battlefield"; + } - public HarborSerpentEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = "{this} can't attack unless there are five or more Islands on the battlefield"; - } + public HarborSerpentEffect(final HarborSerpentEffect effect) { + super(effect); + } - public HarborSerpentEffect(final HarborSerpentEffect effect) { - super(effect); - } - - @Override - public HarborSerpentEffect copy() { - return new HarborSerpentEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) { - int count = game.getBattlefield().countAll(filter); - if (count < 5) - return true; - } - return false; - } + @Override + public HarborSerpentEffect copy() { + return new HarborSerpentEffect(this); + } + @Override + public boolean canAttack(Game game) { + return false; + } + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + if (game.getBattlefield().countAll(filter) < 5) { + return true; + } + return false; + } } diff --git a/Mage.Sets/src/mage/sets/magic2012/HuntersInsight.java b/Mage.Sets/src/mage/sets/magic2012/HuntersInsight.java index b9194383a04..9c94a43d7ab 100644 --- a/Mage.Sets/src/mage/sets/magic2012/HuntersInsight.java +++ b/Mage.Sets/src/mage/sets/magic2012/HuntersInsight.java @@ -37,6 +37,7 @@ import mage.abilities.effects.common.DrawCardControllerEffect; import mage.abilities.effects.common.continious.GainAbilityTargetEffect; import mage.cards.CardImpl; import mage.game.Game; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.target.common.TargetControlledCreaturePermanent; @@ -86,7 +87,7 @@ class HuntersInsightTriggeredAbility extends TriggeredAbilityImpl { - public QuestForTheHolyRelic(UUID ownerId) { super(ownerId, 33, "Quest for the Holy Relic", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}"); this.expansionSetCode = "ZEN"; @@ -84,46 +83,48 @@ public class QuestForTheHolyRelic extends CardImpl { } } -class QuestForTheHolyRelicEffect extends SearchLibraryPutInPlayEffect { - private static final FilterCard filter = new FilterCard("Equipment"); +class QuestForTheHolyRelicEffect extends OneShotEffect { - static { - filter.getSubtype().add("Equipment"); - filter.setScopeSubtype(Filter.ComparisonScope.Any); + public QuestForTheHolyRelicEffect() { + super(Outcome.PutCardInPlay); + this.staticText = "Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library"; } - QuestForTheHolyRelicEffect() { - super(new TargetCardInLibrary(filter)); - staticText = "Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library"; - } - - QuestForTheHolyRelicEffect(final QuestForTheHolyRelicEffect effect) { + public QuestForTheHolyRelicEffect(final QuestForTheHolyRelicEffect effect) { super(effect); } - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null && super.apply(game, source)) { - Target target = new TargetControlledCreaturePermanent(); - if (player.choose(Constants.Outcome.Benefit, target, game)) { - if (target.getTargets().size() > 0) { - Permanent permanent = game.getPermanent(target.getTargets().get(0)); - Permanent sourceEquipment = null; - if (super.getTargets().size() > 0) { - sourceEquipment = game.getPermanent(super.getTargets().get(0)); - } - if (permanent != null && sourceEquipment != null) { - return permanent.addAttachment(sourceEquipment.getId(), game); - } - } - } - } - return false; - } - @Override public QuestForTheHolyRelicEffect copy() { return new QuestForTheHolyRelicEffect(this); } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + + FilterCard filter = new FilterCard("Equipment"); + filter.getSubtype().add("Equipment"); + TargetCardInLibrary target = new TargetCardInLibrary(filter); + if (player.searchLibrary(target, game)) { + Card card = player.getLibrary().remove(target.getFirstTarget(), game); + if (card != null) { + card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId()); + Permanent equipment = game.getPermanent(card.getId()); + + Target targetCreature = new TargetControlledCreaturePermanent(); + if (equipment != null && player.choose(Outcome.BoostCreature, targetCreature, game)) { + Permanent permanent = game.getPermanent(targetCreature.getFirstTarget()); + permanent.addAttachment(equipment.getId(), game); + } + + player.shuffleLibrary(game); + } + } + + return true; + } } diff --git a/Mage/src/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java b/Mage/src/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java index c3af11fc016..21cd656085c 100644 --- a/Mage/src/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java @@ -32,6 +32,7 @@ import mage.Constants.Zone; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.game.Game; +import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.target.targetpointer.FixedTarget; @@ -64,7 +65,8 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)) { + if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId) + && ((DamagedPlayerEvent) event).isCombatDamage()) { if (setTargetPointer) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); diff --git a/Mage/src/mage/abilities/effects/common/MustBlockSourceTargetEffect.java b/Mage/src/mage/abilities/effects/common/MustBlockSourceTargetEffect.java index 491f07632e7..6db6ff1ee05 100644 --- a/Mage/src/mage/abilities/effects/common/MustBlockSourceTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/MustBlockSourceTargetEffect.java @@ -42,7 +42,7 @@ import mage.game.permanent.Permanent; public class MustBlockSourceTargetEffect extends RequirementEffect { public MustBlockSourceTargetEffect() { - this(Duration.WhileOnBattlefield); + this(Duration.EndOfTurn); } public MustBlockSourceTargetEffect(Duration duration) { diff --git a/Mage/src/mage/filter/FilterPermanent.java b/Mage/src/mage/filter/FilterPermanent.java index af7106e1b24..766f17062b0 100644 --- a/Mage/src/mage/filter/FilterPermanent.java +++ b/Mage/src/mage/filter/FilterPermanent.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import mage.Constants.TargetController; -import mage.abilities.Ability; import mage.game.Game; import mage.game.permanent.Permanent;