mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
fixed targeting of Nicol Bolas, God-Pharaoh -4 ability
This commit is contained in:
parent
7465e89b96
commit
f4e2e6fdf1
1 changed files with 72 additions and 60 deletions
|
|
@ -12,6 +12,7 @@ import mage.cards.*;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.common.FilterCreaturePlayerOrPlaneswalker;
|
||||||
import mage.filter.common.FilterNonlandPermanent;
|
import mage.filter.common.FilterNonlandPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Library;
|
import mage.players.Library;
|
||||||
|
|
@ -31,10 +32,15 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public final class NicolBolasGodPharaoh extends CardImpl {
|
public final class NicolBolasGodPharaoh extends CardImpl {
|
||||||
|
|
||||||
private static final FilterPermanent opponentsNonlandPermanentsFilter = new FilterNonlandPermanent("non-land permanents your opponents control");
|
private static final FilterPermanent filter = new FilterNonlandPermanent();
|
||||||
|
private static final FilterCreaturePlayerOrPlaneswalker filter2
|
||||||
|
= new FilterCreaturePlayerOrPlaneswalker("opponent, creature an opponent controls, or planeswalker an opponent controls.");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
opponentsNonlandPermanentsFilter.add(TargetController.OPPONENT.getControllerPredicate());
|
filter.add(TargetController.OPPONENT.getControllerPredicate());
|
||||||
|
filter2.getPlayerFilter().add(TargetController.OPPONENT.getPlayerPredicate());
|
||||||
|
filter2.getCreatureFilter().add(TargetController.OPPONENT.getControllerPredicate());
|
||||||
|
filter2.getPlaneswalkerFilter().add(TargetController.OPPONENT.getControllerPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicolBolasGodPharaoh(UUID ownerId, CardSetInfo setInfo) {
|
public NicolBolasGodPharaoh(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
|
@ -54,14 +60,15 @@ public final class NicolBolasGodPharaoh extends CardImpl {
|
||||||
|
|
||||||
// -4: Nicol Bolas, God-Pharaoh deals 7 damage to any target.
|
// -4: Nicol Bolas, God-Pharaoh deals 7 damage to any target.
|
||||||
ability = new LoyaltyAbility(new DamageTargetEffect(7), -4);
|
ability = new LoyaltyAbility(new DamageTargetEffect(7), -4);
|
||||||
ability.addTarget(new TargetAnyTarget());
|
ability.addTarget(new TargetAnyTarget(filter2));
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// -12: Exile each nonland permanent your opponents control.
|
// -12: Exile each nonland permanent your opponents control.
|
||||||
this.addAbility(new LoyaltyAbility(new ExileAllEffect(opponentsNonlandPermanentsFilter), -12));
|
this.addAbility(new LoyaltyAbility(new ExileAllEffect(filter)
|
||||||
|
.setText("exile each nonland permanent your opponents control"), -12));
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicolBolasGodPharaoh(final NicolBolasGodPharaoh card) {
|
private NicolBolasGodPharaoh(final NicolBolasGodPharaoh card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +85,7 @@ class NicolBolasGodPharaohPlusOneEffect extends OneShotEffect {
|
||||||
this.staticText = "Each opponent exiles two cards from their hand.";
|
this.staticText = "Each opponent exiles two cards from their hand.";
|
||||||
}
|
}
|
||||||
|
|
||||||
NicolBolasGodPharaohPlusOneEffect(final NicolBolasGodPharaohPlusOneEffect effect) {
|
private NicolBolasGodPharaohPlusOneEffect(final NicolBolasGodPharaohPlusOneEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +103,9 @@ class NicolBolasGodPharaohPlusOneEffect extends OneShotEffect {
|
||||||
// Each player chooses 2 cards to discard
|
// Each player chooses 2 cards to discard
|
||||||
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
||||||
Player opponent = game.getPlayer(opponentId);
|
Player opponent = game.getPlayer(opponentId);
|
||||||
if (opponent != null) {
|
if (opponent == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int numberOfCardsToExile = Math.min(2, opponent.getHand().size());
|
int numberOfCardsToExile = Math.min(2, opponent.getHand().size());
|
||||||
if (numberOfCardsToExile > 0) {
|
if (numberOfCardsToExile > 0) {
|
||||||
Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard());
|
Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard());
|
||||||
|
|
@ -109,32 +118,31 @@ class NicolBolasGodPharaohPlusOneEffect extends OneShotEffect {
|
||||||
cardsToExile.put(opponentId, new CardsImpl());
|
cardsToExile.put(opponentId, new CardsImpl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Exile all chosen cards at the same time
|
// Exile all chosen cards at the same time
|
||||||
Cards cardsOpponentsChoseToExile = new CardsImpl();
|
Cards cardsOpponentsChoseToExile = new CardsImpl();
|
||||||
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
||||||
Player opponent = game.getPlayer(opponentId);
|
Player opponent = game.getPlayer(opponentId);
|
||||||
if (opponent != null && cardsToExile.containsKey(opponentId)) {
|
if (opponent == null || !cardsToExile.containsKey(opponentId)) {
|
||||||
|
}
|
||||||
cardsOpponentsChoseToExile.addAll(cardsToExile.get(opponentId));
|
cardsOpponentsChoseToExile.addAll(cardsToExile.get(opponentId));
|
||||||
opponent.moveCards(cardsOpponentsChoseToExile, Zone.EXILED, source, game);
|
opponent.moveCards(cardsOpponentsChoseToExile, Zone.EXILED, source, game);
|
||||||
applied = true;
|
applied = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NicolBolasGodPharaohPlusTwoEffect extends OneShotEffect {
|
class NicolBolasGodPharaohPlusTwoEffect extends OneShotEffect {
|
||||||
|
|
||||||
public NicolBolasGodPharaohPlusTwoEffect() {
|
NicolBolasGodPharaohPlusTwoEffect() {
|
||||||
super(Outcome.Detriment);
|
super(Outcome.Detriment);
|
||||||
this.staticText = "Target opponent exiles cards from the top of their "
|
this.staticText = "Target opponent exiles cards from the top of their "
|
||||||
+ "library until they exile a nonland card. Until end of turn, "
|
+ "library until they exile a nonland card. Until end of turn, "
|
||||||
+ "you may cast that card without paying its mana cost";
|
+ "you may cast that card without paying its mana cost";
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicolBolasGodPharaohPlusTwoEffect(final NicolBolasGodPharaohPlusTwoEffect effect) {
|
private NicolBolasGodPharaohPlusTwoEffect(final NicolBolasGodPharaohPlusTwoEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,37 +154,39 @@ class NicolBolasGodPharaohPlusTwoEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
|
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
if (opponent != null) {
|
if (opponent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Library library = opponent.getLibrary();
|
Library library = opponent.getLibrary();
|
||||||
Card card;
|
Card card;
|
||||||
do {
|
do {
|
||||||
card = library.getFromTop(game);
|
card = library.getFromTop(game);
|
||||||
if (card != null) {
|
if (card == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
opponent.moveCards(card, Zone.EXILED, source, game);
|
opponent.moveCards(card, Zone.EXILED, source, game);
|
||||||
if (!card.isLand()) {
|
if (card.isLand()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ContinuousEffect effect = new NicolBolasGodPharaohFromExileEffect();
|
ContinuousEffect effect = new NicolBolasGodPharaohFromExileEffect();
|
||||||
effect.setTargetPointer(new FixedTarget(card.getId(),
|
effect.setTargetPointer(new FixedTarget(card.getId(),
|
||||||
game.getState().getZoneChangeCounter(card.getId())));
|
game.getState().getZoneChangeCounter(card.getId())));
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (library.hasCards()
|
} while (library.hasCards()
|
||||||
&& card != null);
|
&& card != null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class NicolBolasGodPharaohFromExileEffect extends AsThoughEffectImpl {
|
class NicolBolasGodPharaohFromExileEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
public NicolBolasGodPharaohFromExileEffect() {
|
NicolBolasGodPharaohFromExileEffect() {
|
||||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||||
staticText = "You may cast card from exile";
|
staticText = "You may cast card from exile";
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicolBolasGodPharaohFromExileEffect(final NicolBolasGodPharaohFromExileEffect effect) {
|
private NicolBolasGodPharaohFromExileEffect(final NicolBolasGodPharaohFromExileEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,22 +202,24 @@ class NicolBolasGodPharaohFromExileEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
if (sourceId != null
|
if (sourceId == null
|
||||||
&& sourceId.equals(getTargetPointer().getFirst(game, source))
|
|| !sourceId.equals(getTargetPointer().getFirst(game, source))
|
||||||
&& affectedControllerId.equals(source.getControllerId())) {
|
|| !affectedControllerId.equals(source.getControllerId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Card card = game.getCard(sourceId);
|
Card card = game.getCard(sourceId);
|
||||||
if (card != null
|
if (card == null
|
||||||
&& game.getState().getZone(sourceId) == Zone.EXILED) {
|
|| game.getState().getZone(sourceId) != Zone.EXILED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Player controller = game.getPlayer(affectedControllerId);
|
Player controller = game.getPlayer(affectedControllerId);
|
||||||
if (controller != null) {
|
if (controller == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
controller.setCastSourceIdWithAlternateMana(
|
controller.setCastSourceIdWithAlternateMana(
|
||||||
sourceId,
|
sourceId,
|
||||||
null,
|
null,
|
||||||
card.getSpellAbility().getCosts());
|
card.getSpellAbility().getCosts());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue