* Puppeteer Clique - Fixed that the ability also tiggered without a valid target.

This commit is contained in:
LevelX2 2015-05-18 21:46:22 +02:00
parent 04f9227349
commit e5a792a8f5
3 changed files with 34 additions and 6 deletions

View file

@ -69,7 +69,6 @@ public class PuppeteerClique extends CardImpl {
this.subtype.add("Faerie");
this.subtype.add("Wizard");
this.color.setBlack(true);
this.power = new MageInt(3);
this.toughness = new MageInt(2);
@ -115,7 +114,7 @@ class PuppeteerCliqueEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
Card card = game.getCard(source.getFirstTarget());
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
@ -125,7 +124,7 @@ class PuppeteerCliqueEffect extends OneShotEffect {
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
hasteEffect.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(hasteEffect, source);
ExileTargetEffect exileEffect = new ExileTargetEffect(new StringBuilder("exile ").append(permanent.getName()).toString());
ExileTargetEffect exileEffect = new ExileTargetEffect("exile " + permanent.getLogName());
exileEffect.setTargetPointer(new FixedTarget(card.getId()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU);
delayedAbility.setSourceId(source.getSourceId());

View file

@ -95,7 +95,6 @@ public class FilterCard extends FilterObject<Card> {
if (!this.match(card, game)) {
return false;
}
return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(card, sourceId, playerId), game);
}

View file

@ -8,6 +8,8 @@ import mage.game.Game;
import mage.target.TargetCard;
import java.util.UUID;
import mage.game.events.GameEvent;
import mage.players.Player;
public class TargetCardInOpponentsGraveyard extends TargetCard {
@ -52,9 +54,37 @@ public class TargetCardInOpponentsGraveyard extends TargetCard {
@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
return true;
return canChoose(null, sourceControllerId, game);
}
/**
* Checks if there are enough {@link Card} that can be chosen.
*
* @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source
* @param game
* @return - true if enough valid {@link Card} exist
*/
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int possibleTargets = 0;
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
if (!playerId.equals(sourceControllerId)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) {
if (sourceId == null || isNotTarget() || !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.TARGET, card.getId(), sourceId, sourceControllerId))) {
possibleTargets++;
if (possibleTargets >= this.minNumberOfTargets) {
return true;
}
}
}
}
}
}
return false;
}
@Override
public TargetCardInOpponentsGraveyard copy() {
return new TargetCardInOpponentsGraveyard(this);