mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Cruel Ultimatum - Fixed that wrongly creatures in all graveyards could be selected.
This commit is contained in:
parent
13b8cad131
commit
9609480109
3 changed files with 52 additions and 17 deletions
|
@ -239,6 +239,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
updateGameStatePriority("choose(5)", game);
|
||||
while (!abort) {
|
||||
Set<UUID> cards = target.possibleTargets(null, playerId, game);
|
||||
if (cards == null || cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean required = target.isRequired(sourceId, game);
|
||||
if (target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
|
@ -278,9 +281,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (!target.isRequired(sourceId, game)) {
|
||||
return false;
|
||||
}
|
||||
if (cards == null || cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -27,17 +27,20 @@
|
|||
*/
|
||||
package mage.sets.shardsofalara;
|
||||
|
||||
import mage.abilities.effects.common.discard.DiscardTargetEffect;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||
import mage.abilities.effects.common.SacrificeEffect;
|
||||
import mage.abilities.effects.common.discard.DiscardTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -59,7 +62,8 @@ public class CruelUltimatum extends CardImpl {
|
|||
this.color.setBlue(true);
|
||||
this.color.setBlack(true);
|
||||
|
||||
// Target opponent sacrifices a creature, discards three cards, then loses 5 life. You return a creature card from your graveyard to your hand, draw three cards, then gain 5 life.
|
||||
// Target opponent sacrifices a creature, discards three cards, then loses 5 life.
|
||||
// You return a creature card from your graveyard to your hand, draw three cards, then gain 5 life.
|
||||
this.getSpellAbility().addTarget(new TargetOpponent());
|
||||
this.getSpellAbility().addEffect(new SacrificeEffect(new FilterCreaturePermanent(), 1, "Target opponent"));
|
||||
this.getSpellAbility().addEffect(new DiscardTargetEffect(3));
|
||||
|
@ -99,13 +103,17 @@ class CruelUltimatumEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
|
||||
if (player != null && player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
return card.moveToZone(Zone.HAND, source.getId(), game, true);
|
||||
}
|
||||
}
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
|
||||
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
return player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,13 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -87,6 +90,29 @@ public class TargetCardInYourGraveyard extends TargetCard {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
for (Card card : player.getGraveyard().getCards(filter, game)) {
|
||||
if (sourceId == null || isNotTarget() || !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.TARGET, card.getId(), sourceId, sourceControllerId))) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Cards cards, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
for (Card card: cards.getCards(filter, game)) {
|
||||
if (player.getGraveyard().getCards(game).contains(card)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
/**
|
||||
* Checks if there are enough {@link Card} that can be selected.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue