* Pithing Needle - Fixed a bug that it did not respect the players range (added UT for #3156 - not reproducable).

This commit is contained in:
LevelX2 2017-05-17 17:52:31 +02:00
parent a068de8d18
commit 6bf7a89d45
3 changed files with 79 additions and 7 deletions

View file

@ -27,6 +27,8 @@
*/
package mage.cards.p;
import java.util.Optional;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
@ -39,9 +41,6 @@ import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.Optional;
import java.util.UUID;
/**
*
* @author jeffwadsworth, nox
@ -49,7 +48,7 @@ import java.util.UUID;
public class PithingNeedle extends CardImpl {
public PithingNeedle(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// As Pithing Needle enters the battlefield, name a card.
this.addAbility(new AsEntersBattlefieldAbility(new NameACardEffect(NameACardEffect.TypeOfName.ALL)));
@ -99,7 +98,8 @@ class PithingNeedleEffect extends ContinuousRuleModifyingEffectImpl {
MageObject object = game.getObject(event.getSourceId());
Optional<Ability> ability = game.getAbility(event.getTargetId(), event.getSourceId());
if (ability.isPresent() && object != null) {
if (ability.get().getAbilityType() != AbilityType.MANA
if (game.getState().getPlayersInRange(source.getControllerId(), game).contains(event.getPlayerId()) // controller in range
&& ability.get().getAbilityType() != AbilityType.MANA
&& object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
return true;
}

View file

@ -55,9 +55,9 @@ import mage.target.common.TargetCreaturePermanent;
public class ProteusStaff extends CardImpl {
public ProteusStaff(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// {2}{U}, {tap}: Put target creature on the bottom of its owner's library. That creature's controller reveals cards from the top of his or her library until he or she reveals a creature card. The player puts that card onto the battlefield and the rest on the bottom of his or her library in any order. Activate this ability only any time you could cast a sorcery.
// {2}{U}, {T}: Put target creature on the bottom of its owner's library. That creature's controller reveals cards from the top of his or her library until he or she reveals a creature card. The player puts that card onto the battlefield and the rest on the bottom of his or her library in any order. Activate this ability only any time you could cast a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new ProteusStaffEffect(), new ManaCostsImpl<>("{2}{U}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());