mirror of
https://github.com/correl/mage.git
synced 2024-12-01 03:00:09 +00:00
refactored and encapsulated card name choosing effects
This commit is contained in:
parent
0297a00156
commit
9604a9c3ea
16 changed files with 326 additions and 498 deletions
|
@ -6,14 +6,13 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.effects.common.ExileTargetEffect;
|
import mage.abilities.effects.common.ExileTargetEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||||
import mage.abilities.keyword.HasteAbility;
|
import mage.abilities.keyword.HasteAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.filter.predicate.mageobject.NamePredicate;
|
import mage.filter.predicate.mageobject.NamePredicate;
|
||||||
|
@ -34,7 +33,7 @@ public final class AchHansRun extends CardImpl {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}{G}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}{G}{G}");
|
||||||
|
|
||||||
// At the beginning of your upkeep, you may say "Ach! Hans, run! It’s the …" and the name of a creature card. If you do, search your library for a card with that name, put it onto the battlefield, then shuffle your library. That creature gains haste. Exile it at the beginning of the next end step.
|
// At the beginning of your upkeep, you may say "Ach! Hans, run! It’s the …" and the name of a creature card. If you do, search your library for a card with that name, put it onto the battlefield, then shuffle your library. That creature gains haste. Exile it at the beginning of the next end step.
|
||||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new AchHansRunEffect(), TargetController.YOU, true));
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AchHansRunEffect(), TargetController.YOU, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AchHansRun(final AchHansRun card) {
|
private AchHansRun(final AchHansRun card) {
|
||||||
|
@ -51,7 +50,9 @@ class AchHansRunEffect extends OneShotEffect {
|
||||||
|
|
||||||
AchHansRunEffect() {
|
AchHansRunEffect() {
|
||||||
super(Outcome.PutCreatureInPlay);
|
super(Outcome.PutCreatureInPlay);
|
||||||
this.staticText = "you may say \"Ach! Hans, run! It's the …\" and the name of a creature card. If you do, search your library for a card with that name, put it onto the battlefield, then shuffle. That creature gains haste. Exile it at the beginning of the next end step";
|
this.staticText = "you may say \"Ach! Hans, run! It's the …\" and the name of a creature card. " +
|
||||||
|
"If you do, search your library for a card with that name, put it onto the battlefield, " +
|
||||||
|
"then shuffle. That creature gains haste. Exile it at the beginning of the next end step";
|
||||||
}
|
}
|
||||||
|
|
||||||
private AchHansRunEffect(final AchHansRunEffect effect) {
|
private AchHansRunEffect(final AchHansRunEffect effect) {
|
||||||
|
@ -69,13 +70,7 @@ class AchHansRunEffect extends OneShotEffect {
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChoiceImpl cardChoice = new ChoiceImpl(true);
|
String cardName = ChooseACardNameEffect.TypeOfName.CREATURE_NAME.getChoice(controller, game, source, false);
|
||||||
cardChoice.setChoices(CardRepository.instance.getCreatureNames());
|
|
||||||
cardChoice.setMessage("Choose a creature card name");
|
|
||||||
if (!controller.choose(Outcome.Detriment, cardChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
game.informPlayers(controller.getLogName() + ": \"Ach! Hans, run! It's the " + cardName + "!\"");
|
game.informPlayers(controller.getLogName() + ": \"Ach! Hans, run! It's the " + cardName + "!\"");
|
||||||
FilterCard nameFilter = new FilterCard();
|
FilterCard nameFilter = new FilterCard();
|
||||||
nameFilter.add(new NamePredicate(cardName));
|
nameFilter.add(new NamePredicate(cardName));
|
||||||
|
|
|
@ -5,11 +5,9 @@ import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksTriggeredAbility;
|
import mage.abilities.common.AttacksTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
@ -55,7 +53,9 @@ class ConundrumSphinxEffect extends OneShotEffect {
|
||||||
|
|
||||||
public ConundrumSphinxEffect() {
|
public ConundrumSphinxEffect() {
|
||||||
super(Outcome.DrawCard);
|
super(Outcome.DrawCard);
|
||||||
staticText = "each player names a card. Then each player reveals the top card of their library. If the card a player revealed is the card they named, that player puts it into their hand. If it's not, that player puts it on the bottom of their library";
|
staticText = "each player chooses a card name. Then each player reveals the top card of their library. " +
|
||||||
|
"If the card a player revealed has the name they chose, that player puts it into their hand. " +
|
||||||
|
"If it doesn’t, that player puts it on the bottom of their library";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConundrumSphinxEffect(final ConundrumSphinxEffect effect) {
|
public ConundrumSphinxEffect(final ConundrumSphinxEffect effect) {
|
||||||
|
@ -66,42 +66,32 @@ class ConundrumSphinxEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null && sourceObject != null) {
|
if (controller == null || sourceObject == null) {
|
||||||
Choice cardChoice = new ChoiceImpl();
|
return false;
|
||||||
cardChoice.setChoices(CardRepository.instance.getNames());
|
|
||||||
Players:
|
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
|
||||||
Player player = game.getPlayer(playerId);
|
|
||||||
if (player != null) {
|
|
||||||
if (player.getLibrary().hasCards()) {
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
cardChoice.setMessage("Name a card");
|
|
||||||
if (!player.choose(Outcome.DrawCard, cardChoice, game) && player.canRespond()) {
|
|
||||||
continue Players;
|
|
||||||
}
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
|
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
|
||||||
if (card != null) {
|
|
||||||
Cards cards = new CardsImpl(card);
|
|
||||||
player.revealCards(source, player.getName(), cards, game);
|
|
||||||
if (CardUtil.haveSameNames(card, cardName, game)) {
|
|
||||||
player.moveCards(cards, Zone.HAND, source, game);
|
|
||||||
} else {
|
|
||||||
player.putCardsOnBottomOfLibrary(cards, game, source, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player == null || !player.getLibrary().hasCards()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(player, game, source, false);
|
||||||
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
|
if (card == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Cards cards = new CardsImpl(card);
|
||||||
|
player.revealCards(source, cards, game);
|
||||||
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
|
player.moveCards(cards, Zone.HAND, source, game);
|
||||||
|
} else {
|
||||||
|
player.putCardsOnBottomOfLibrary(cards, game, source, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConundrumSphinxEffect copy() {
|
public ConundrumSphinxEffect copy() {
|
||||||
return new ConundrumSphinxEffect(this);
|
return new ConundrumSphinxEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
|
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
|
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public final class CranialExtraction extends CardImpl {
|
public final class CranialExtraction extends CardImpl {
|
||||||
|
@ -30,7 +25,7 @@ public final class CranialExtraction extends CardImpl {
|
||||||
this.subtype.add(SubType.ARCANE);
|
this.subtype.add(SubType.ARCANE);
|
||||||
|
|
||||||
/* Name a nonland card. Search target player's graveyard, hand, and library for
|
/* Name a nonland card. Search target player's graveyard, hand, and library for
|
||||||
* all cards with that name and exile them. Then that player shuffles their library. */
|
* all cards with that name and exile them. Then that player shuffles their library. */
|
||||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||||
this.getSpellAbility().addEffect(new CranialExtractionEffect());
|
this.getSpellAbility().addEffect(new CranialExtractionEffect());
|
||||||
}
|
}
|
||||||
|
@ -43,7 +38,6 @@ public final class CranialExtraction extends CardImpl {
|
||||||
public CranialExtraction copy() {
|
public CranialExtraction copy() {
|
||||||
return new CranialExtraction(this);
|
return new CranialExtraction(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CranialExtractionEffect extends SearchTargetGraveyardHandLibraryForCardNameAndExileEffect {
|
class CranialExtractionEffect extends SearchTargetGraveyardHandLibraryForCardNameAndExileEffect {
|
||||||
|
@ -59,23 +53,14 @@ class CranialExtractionEffect extends SearchTargetGraveyardHandLibraryForCardNam
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
if (player == null) {
|
||||||
if (player != null && controller != null) {
|
return true;
|
||||||
Choice cardChoice = new ChoiceImpl();
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
cardChoice.setMessage("Name a nonland card");
|
|
||||||
|
|
||||||
if (!controller.choose(Outcome.Exile, cardChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
|
||||||
if (sourceObject != null) {
|
|
||||||
game.informPlayers(sourceObject.getName() + " named card: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
super.applySearchAndExile(game, source, cardName, player.getId());
|
|
||||||
}
|
}
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.NON_LAND_NAME.getChoice(player, game, source, false);
|
||||||
|
if (cardName == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
super.applySearchAndExile(game, source, cardName, player.getId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
|
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
*/
|
*/
|
||||||
public final class DemonicConsultation extends CardImpl {
|
public final class DemonicConsultation extends CardImpl {
|
||||||
|
@ -42,7 +40,9 @@ class DemonicConsultationEffect extends OneShotEffect {
|
||||||
|
|
||||||
DemonicConsultationEffect() {
|
DemonicConsultationEffect() {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
this.staticText = "Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way";
|
this.staticText = "choose a card name. Exile the top six cards of your library, " +
|
||||||
|
"then reveal cards from the top of your library until you reveal a card with the chosen name. " +
|
||||||
|
"Put that card into your hand and exile all other cards revealed this way";
|
||||||
}
|
}
|
||||||
|
|
||||||
DemonicConsultationEffect(final DemonicConsultationEffect effect) {
|
DemonicConsultationEffect(final DemonicConsultationEffect effect) {
|
||||||
|
@ -57,39 +57,31 @@ class DemonicConsultationEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (controller != null && sourceObject != null) {
|
if (controller == null || sourceObject == null) {
|
||||||
// Name a card.
|
return false;
|
||||||
Choice choice = new ChoiceImpl();
|
|
||||||
choice.setChoices(CardRepository.instance.getNames());
|
|
||||||
if (!controller.choose(Outcome.Benefit, choice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String name = choice.getChoice();
|
|
||||||
game.informPlayers("Card named: " + name);
|
|
||||||
|
|
||||||
// Exile the top six cards of your library,
|
|
||||||
controller.moveCards(controller.getLibrary().getTopCards(game, 6), Zone.EXILED, source, game);
|
|
||||||
|
|
||||||
// then reveal cards from the top of your library until you reveal the named card.
|
|
||||||
Cards cardsToReaveal = new CardsImpl();
|
|
||||||
Card cardToHand = null;
|
|
||||||
for (Card card : controller.getLibrary().getCards(game)) {
|
|
||||||
if (card != null) {
|
|
||||||
cardsToReaveal.add(card);
|
|
||||||
// Put that card into your hand
|
|
||||||
if (card.getName().equals(name)) {
|
|
||||||
cardToHand = card;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.moveCards(cardToHand, Zone.HAND, source, game);
|
|
||||||
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
|
|
||||||
cardsToReaveal.remove(cardToHand);
|
|
||||||
controller.moveCards(cardsToReaveal, Zone.EXILED, source, game);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
// Name a card.
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(controller, game, source, false);
|
||||||
|
|
||||||
|
// Exile the top six cards of your library,
|
||||||
|
controller.moveCards(controller.getLibrary().getTopCards(game, 6), Zone.EXILED, source, game);
|
||||||
|
|
||||||
|
// then reveal cards from the top of your library until you reveal the named card.
|
||||||
|
Cards cardsToReveal = new CardsImpl();
|
||||||
|
Card cardToHand = null;
|
||||||
|
for (Card card : controller.getLibrary().getCards(game)) {
|
||||||
|
cardsToReveal.add(card);
|
||||||
|
// Put that card into your hand
|
||||||
|
if (CardUtil.haveSameNames(card.getName(), cardName)) {
|
||||||
|
cardToHand = card;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controller.moveCards(cardToHand, Zone.HAND, source, game);
|
||||||
|
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
|
||||||
|
cardsToReveal.remove(cardToHand);
|
||||||
|
controller.moveCards(cardsToReveal, Zone.EXILED, source, game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,18 @@ import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -73,16 +72,10 @@ class DivinersLockboxEffect extends OneShotEffect {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Choice choice = new ChoiceImpl();
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(player, game, source, false);
|
||||||
choice.setChoices(CardRepository.instance.getNames());
|
|
||||||
choice.setMessage("Choose a card name");
|
|
||||||
if (!player.choose(outcome, choice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
game.informPlayers(source.getSourceObject(game).getLogName() + ", chosen name: [" + choice.getChoice() + ']');
|
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
player.revealCards(source, new CardsImpl(card), game);
|
player.revealCards(source, new CardsImpl(card), game);
|
||||||
if (choice.getChoice().equals(card.getName())) {
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
sacEffect.apply(game, source);
|
sacEffect.apply(game, source);
|
||||||
player.drawCards(3, source, game);
|
player.drawCards(3, source, game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,8 @@ import mage.abilities.costs.common.DiscardTargetCost;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
@ -56,7 +54,9 @@ public final class DiviningWitch extends CardImpl {
|
||||||
|
|
||||||
DiviningWitchEffect() {
|
DiviningWitchEffect() {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
this.staticText = "Name a card. Exile the top six cards of your library. Reveal cards from the top of your library until you reveal the named card, then put that card into your hand. Exile all other cards revealed this way";
|
this.staticText = "choose a card name. Exile the top six cards of your library, " +
|
||||||
|
"then reveal cards from the top of your library until you reveal a card with the chosen name. " +
|
||||||
|
"Put that card into your hand and exile all other cards revealed this way";
|
||||||
}
|
}
|
||||||
|
|
||||||
DiviningWitchEffect(final DiviningWitchEffect effect) {
|
DiviningWitchEffect(final DiviningWitchEffect effect) {
|
||||||
|
@ -72,39 +72,30 @@ public final class DiviningWitch extends CardImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (controller != null && sourceObject != null) {
|
if (controller == null || sourceObject == null) {
|
||||||
// Name a card.
|
return false;
|
||||||
Choice choice = new ChoiceImpl();
|
|
||||||
choice.setChoices(CardRepository.instance.getNames());
|
|
||||||
if (!controller.choose(Outcome.Benefit, choice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String name = choice.getChoice();
|
|
||||||
game.informPlayers("Card named: " + name);
|
|
||||||
|
|
||||||
// Exile the top six cards of your library,
|
|
||||||
controller.moveCards(controller.getLibrary().getTopCards(game, 6), Zone.EXILED, source, game);
|
|
||||||
|
|
||||||
// then reveal cards from the top of your library until you reveal the named card.
|
|
||||||
Cards cardsToReaveal = new CardsImpl();
|
|
||||||
Card cardToHand = null;
|
|
||||||
for (Card card : controller.getLibrary().getCards(game)) {
|
|
||||||
if (card != null) {
|
|
||||||
cardsToReaveal.add(card);
|
|
||||||
// Put that card into your hand
|
|
||||||
if (CardUtil.haveSameNames(card, name, game)) {
|
|
||||||
cardToHand = card;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.moveCards(cardToHand, Zone.HAND, source, game);
|
|
||||||
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
|
|
||||||
cardsToReaveal.remove(cardToHand);
|
|
||||||
controller.moveCards(cardsToReaveal, Zone.EXILED, source, game);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
// Name a card.
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(controller, game, source, false);
|
||||||
|
// Exile the top six cards of your library,
|
||||||
|
controller.moveCards(controller.getLibrary().getTopCards(game, 6), Zone.EXILED, source, game);
|
||||||
|
|
||||||
|
// then reveal cards from the top of your library until you reveal the named card.
|
||||||
|
Cards cardsToReveal = new CardsImpl();
|
||||||
|
Card cardToHand = null;
|
||||||
|
for (Card card : controller.getLibrary().getCards(game)) {
|
||||||
|
cardsToReveal.add(card);
|
||||||
|
// Put that card into your hand
|
||||||
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
|
cardToHand = card;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controller.moveCards(cardToHand, Zone.HAND, source, game);
|
||||||
|
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
|
||||||
|
cardsToReveal.remove(cardToHand);
|
||||||
|
controller.moveCards(cardsToReveal, Zone.EXILED, source, game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
|
|
||||||
package mage.cards.i;
|
package mage.cards.i;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
|
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class InfiniteObliteration extends CardImpl {
|
public final class InfiniteObliteration extends CardImpl {
|
||||||
|
@ -56,24 +53,11 @@ class InfiniteObliterationEffect extends SearchTargetGraveyardHandLibraryForCard
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (player != null && controller != null) {
|
if (player == null || controller == null) {
|
||||||
Choice cardChoice = new ChoiceImpl();
|
return true;
|
||||||
cardChoice.setChoices(CardRepository.instance.getCreatureNames());
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
cardChoice.setMessage("Name a creature card");
|
|
||||||
|
|
||||||
if (!controller.choose(Outcome.Exile, cardChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String cardName;
|
|
||||||
cardName = cardChoice.getChoice();
|
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
|
||||||
if (sourceObject != null) {
|
|
||||||
game.informPlayers(sourceObject.getName() + " named card: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
|
|
||||||
super.applySearchAndExile(game, source, cardName, player.getId());
|
|
||||||
}
|
}
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.CREATURE_NAME.getChoice(player, game, source, false);
|
||||||
|
super.applySearchAndExile(game, source, cardName, player.getId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,5 +70,4 @@ class InfiniteObliterationEffect extends SearchTargetGraveyardHandLibraryForCard
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
return "Choose a creature card name. " + super.getText(mode);
|
return "Choose a creature card name. " + super.getText(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,10 @@ import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
@ -66,39 +64,32 @@ class LiarsPendulumEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (controller != null && opponent != null) {
|
if (controller == null || opponent == null) {
|
||||||
// Name a card.
|
return false;
|
||||||
Choice choice = new ChoiceImpl();
|
|
||||||
choice.setChoices(CardRepository.instance.getNames());
|
|
||||||
choice.setMessage("Choose a card name");
|
|
||||||
if (!controller.choose(Outcome.Benefit, choice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String cardName = choice.getChoice();
|
|
||||||
game.informPlayers("Card named: " + cardName);
|
|
||||||
boolean opponentGuess = false;
|
|
||||||
|
|
||||||
if (opponent.chooseUse(Outcome.Neutral, "Is the chosen card (" + cardName + ") in " + controller.getLogName() + "'s hand?", source, game)) {
|
|
||||||
opponentGuess = true;
|
|
||||||
}
|
|
||||||
boolean rightGuess = !opponentGuess;
|
|
||||||
|
|
||||||
for (Card card : controller.getHand().getCards(game)) {
|
|
||||||
if (CardUtil.haveSameNames(card, cardName, game)) {
|
|
||||||
rightGuess = opponentGuess;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
game.informPlayers(opponent.getLogName() + " guesses that " + cardName + " is " + (opponentGuess ? "" : "not") + " in " + controller.getLogName() + "'s hand");
|
|
||||||
|
|
||||||
if (controller.chooseUse(outcome, "Reveal your hand?", source, game)) {
|
|
||||||
controller.revealCards("hand of " + controller.getName(), controller.getHand(), game);
|
|
||||||
if (!rightGuess) {
|
|
||||||
controller.drawCards(1, source, game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
// Name a card.
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(controller, game, source, false);
|
||||||
|
boolean opponentGuess = false;
|
||||||
|
|
||||||
|
if (opponent.chooseUse(Outcome.Neutral, "Is the chosen card (" + cardName + ") in " + controller.getLogName() + "'s hand?", source, game)) {
|
||||||
|
opponentGuess = true;
|
||||||
|
}
|
||||||
|
boolean rightGuess = !opponentGuess;
|
||||||
|
|
||||||
|
for (Card card : controller.getHand().getCards(game)) {
|
||||||
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
|
rightGuess = opponentGuess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game.informPlayers(opponent.getLogName() + " guesses that " + cardName + " is " + (opponentGuess ? "" : "not") + " in " + controller.getLogName() + "'s hand");
|
||||||
|
|
||||||
|
if (controller.chooseUse(outcome, "Reveal your hand?", source, game)) {
|
||||||
|
controller.revealCards("hand of " + controller.getName(), controller.getHand(), game);
|
||||||
|
if (!rightGuess) {
|
||||||
|
controller.drawCards(1, source, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ package mage.cards.m;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.choices.ChoiceImpl;
|
import mage.choices.ChoiceImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
@ -53,7 +53,9 @@ class MindblazeEffect extends OneShotEffect {
|
||||||
|
|
||||||
MindblazeEffect() {
|
MindblazeEffect() {
|
||||||
super(Outcome.Damage);
|
super(Outcome.Damage);
|
||||||
staticText = "Choose a nonland card name and a number greater than 0. Target player reveals their library. If that library contains exactly the chosen number of cards with the chosen name, {this} deals 8 damage to that player. Then that player shuffles";
|
staticText = "Choose a nonland card name and a number greater than 0. Target player reveals their library. " +
|
||||||
|
"If that library contains exactly the chosen number of cards with the chosen name, " +
|
||||||
|
"{this} deals 8 damage to that player. Then that player shuffles";
|
||||||
}
|
}
|
||||||
|
|
||||||
MindblazeEffect(final MindblazeEffect effect) {
|
MindblazeEffect(final MindblazeEffect effect) {
|
||||||
|
@ -65,45 +67,36 @@ class MindblazeEffect extends OneShotEffect {
|
||||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
Player playerControls = game.getPlayer(source.getControllerId());
|
Player playerControls = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (player != null && playerControls != null && sourceObject != null) {
|
if (player == null || playerControls == null || sourceObject == null) {
|
||||||
Choice cardChoice = new ChoiceImpl();
|
return false;
|
||||||
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
Choice numberChoice = new ChoiceImpl();
|
|
||||||
numberChoice.setMessage("Choose a number greater than 0");
|
|
||||||
Set<String> numbers = new HashSet<>();
|
|
||||||
for (int i = 1; i <= 4; i++) {
|
|
||||||
numbers.add(Integer.toString(i));
|
|
||||||
}
|
|
||||||
numberChoice.setChoices(numbers);
|
|
||||||
|
|
||||||
if (!playerControls.choose(Outcome.Neutral, cardChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.informPlayers(sourceObject.getIdName() + " - Named card: [" + cardChoice.getChoice() + "] - Chosen number: [" + numberChoice.getChoice() + ']');
|
|
||||||
|
|
||||||
Cards cards = new CardsImpl();
|
|
||||||
cards.addAll(player.getLibrary().getCards(game));
|
|
||||||
playerControls.revealCards("Library", cards, game);
|
|
||||||
FilterCard filter = new FilterCard();
|
|
||||||
filter.add(new NamePredicate(cardChoice.getChoice()));
|
|
||||||
int count = Integer.parseInt(numberChoice.getChoice());
|
|
||||||
if (player.getLibrary().count(filter, game) == count) {
|
|
||||||
player.damage(8, source.getSourceId(), source, game);
|
|
||||||
}
|
|
||||||
player.shuffleLibrary(source, game);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
Choice numberChoice = new ChoiceImpl();
|
||||||
|
numberChoice.setMessage("Choose a number greater than 0");
|
||||||
|
Set<String> numbers = new HashSet<>();
|
||||||
|
for (int i = 1; i <= 4; i++) {
|
||||||
|
numbers.add(Integer.toString(i));
|
||||||
|
}
|
||||||
|
numberChoice.setChoices(numbers);
|
||||||
|
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.NON_LAND_NAME.getChoice(playerControls, game, source, false);
|
||||||
|
playerControls.choose(Outcome.Neutral, numberChoice, game);
|
||||||
|
game.informPlayers(sourceObject.getIdName() + " - Chosen number: [" + numberChoice.getChoice() + ']');
|
||||||
|
|
||||||
|
Cards cards = new CardsImpl();
|
||||||
|
cards.addAll(player.getLibrary().getCards(game));
|
||||||
|
playerControls.revealCards("Library", cards, game);
|
||||||
|
FilterCard filter = new FilterCard();
|
||||||
|
filter.add(new NamePredicate(cardName));
|
||||||
|
int count = Integer.parseInt(numberChoice.getChoice());
|
||||||
|
if (player.getLibrary().count(filter, game) == count) {
|
||||||
|
player.damage(8, source.getSourceId(), source, game);
|
||||||
|
}
|
||||||
|
player.shuffleLibrary(source, game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MindblazeEffect copy() {
|
public MindblazeEffect copy() {
|
||||||
return new MindblazeEffect(this);
|
return new MindblazeEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,12 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
|
@ -56,7 +53,7 @@ class NullChamberChooseEffect extends OneShotEffect {
|
||||||
|
|
||||||
public NullChamberChooseEffect() {
|
public NullChamberChooseEffect() {
|
||||||
super(Outcome.AIDontUseIt);
|
super(Outcome.AIDontUseIt);
|
||||||
staticText = "you and an opponent each name a card other than a basic land card";
|
staticText = "you and an opponent each choose a card name other than a basic land card name";
|
||||||
}
|
}
|
||||||
|
|
||||||
public NullChamberChooseEffect(final NullChamberChooseEffect effect) {
|
public NullChamberChooseEffect(final NullChamberChooseEffect effect) {
|
||||||
|
@ -69,41 +66,32 @@ class NullChamberChooseEffect extends OneShotEffect {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
||||||
if (sourceObject == null) {
|
if (sourceObject == null) {
|
||||||
sourceObject = game.getObject(source.getSourceId());
|
sourceObject = source.getSourceObject(game);
|
||||||
}
|
}
|
||||||
if (controller != null
|
if (controller == null || sourceObject == null) {
|
||||||
&& sourceObject != null
|
return false;
|
||||||
&& controller.choose(Outcome.Neutral, chosenOpponent, source.getSourceId(), game)) {
|
}
|
||||||
Player opponent = game.getPlayer(chosenOpponent.getFirstTarget());
|
controller.choose(Outcome.Neutral, chosenOpponent, source.getSourceId(), game);
|
||||||
Choice cardChoice = new ChoiceImpl();
|
Player opponent = game.getPlayer(chosenOpponent.getFirstTarget());
|
||||||
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
|
String cardName = ChooseACardNameEffect.TypeOfName.NOT_BASIC_LAND_NAME.getChoice(controller, game, source, false);
|
||||||
cardChoice.setMessage("Choose a card name other than a basic land card name");
|
if (cardName != null) {
|
||||||
cardChoice.clearChoice();
|
game.getState().setValue(source.getSourceId().toString() + INFO_KEY_CONTROLLER, cardName);
|
||||||
if (controller.choose(Outcome.Detriment, cardChoice, game)) {
|
if (sourceObject instanceof Permanent) {
|
||||||
String cardName = cardChoice.getChoice();
|
((Permanent) sourceObject).addInfo(INFO_KEY_CONTROLLER, CardUtil.addToolTipMarkTags("Named card (Controller): " + cardName), game);
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ", controller named card: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
game.getState().setValue(source.getSourceId().toString() + INFO_KEY_CONTROLLER, cardName);
|
|
||||||
if (sourceObject instanceof Permanent) {
|
|
||||||
((Permanent) sourceObject).addInfo(INFO_KEY_CONTROLLER, CardUtil.addToolTipMarkTags("Named card (Controller): " + cardName), game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
if (opponent != null
|
|
||||||
&& opponent.choose(Outcome.Detriment, cardChoice, game)) {
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ",chosen opponent named card: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
game.getState().setValue(source.getSourceId().toString() + INFO_KEY_OPPONENT, cardName);
|
|
||||||
if (sourceObject instanceof Permanent) {
|
|
||||||
((Permanent) sourceObject).addInfo(INFO_KEY_OPPONENT, CardUtil.addToolTipMarkTags("Named card (Opponent): " + cardName), game);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
if (opponent == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
cardName = ChooseACardNameEffect.TypeOfName.NOT_BASIC_LAND_NAME.getChoice(opponent, game, source, false);
|
||||||
|
if (cardName == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
game.getState().setValue(source.getSourceId().toString() + INFO_KEY_OPPONENT, cardName);
|
||||||
|
if (sourceObject instanceof Permanent) {
|
||||||
|
((Permanent) sourceObject).addInfo(INFO_KEY_OPPONENT, CardUtil.addToolTipMarkTags("Named card (Opponent): " + cardName), game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,10 +5,8 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
@ -64,35 +62,26 @@ class PetraSphinxEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
if (controller != null && player != null) {
|
if (controller == null || player == null || !player.getLibrary().hasCards()) {
|
||||||
if (player.getLibrary().hasCards()) {
|
|
||||||
Choice cardChoice = new ChoiceImpl();
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNames());
|
|
||||||
cardChoice.setMessage("Name a card");
|
|
||||||
if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
game.informPlayers(CardUtil.createObjectRealtedWindowTitle(source, game, null) + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
|
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
|
||||||
if (card != null) {
|
|
||||||
Cards cards = new CardsImpl(card);
|
|
||||||
player.revealCards(source, cards, game);
|
|
||||||
if (CardUtil.haveSameNames(card, cardName, game)) {
|
|
||||||
player.moveCards(cards, Zone.HAND, source, game);
|
|
||||||
} else {
|
|
||||||
player.moveCards(cards, Zone.GRAVEYARD, source, game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(player, game, source, false);
|
||||||
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
|
if (card == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Cards cards = new CardsImpl(card);
|
||||||
|
player.revealCards(source, cards, game);
|
||||||
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
|
player.moveCards(cards, Zone.HAND, source, game);
|
||||||
|
} else {
|
||||||
|
player.moveCards(cards, Zone.GRAVEYARD, source, game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PetraSphinxEffect copy() {
|
public PetraSphinxEffect copy() {
|
||||||
return new PetraSphinxEffect(this);
|
return new PetraSphinxEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,9 @@ import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
@ -121,18 +119,12 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Choice choice = new ChoiceImpl();
|
String cardName = ChooseACardNameEffect.TypeOfName.NON_LAND_NAME.getChoice(player, game, source, false);
|
||||||
choice.setChoices(CardRepository.instance.getNonLandNames());
|
|
||||||
choice.setMessage("Choose a nonland card name");
|
|
||||||
if (!player.choose(outcome, choice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
game.informPlayers(source.getSourceObject(game).getLogName() + ", chosen name: [" + choice.getChoice() + ']');
|
|
||||||
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 4));
|
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 4));
|
||||||
Cards cards2 = new CardsImpl();
|
Cards cards2 = new CardsImpl();
|
||||||
player.revealCards(source, cards, game);
|
player.revealCards(source, cards, game);
|
||||||
for (Card card : cards.getCards(game)) {
|
for (Card card : cards.getCards(game)) {
|
||||||
if (CardUtil.haveSameNames(card, choice.getChoice(), game)) {
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
cards2.add(card);
|
cards2.add(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,5 +133,4 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
|
||||||
player.moveCards(cards2, Zone.HAND, source, game);
|
player.moveCards(cards2, Zone.HAND, source, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,8 @@ import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
@ -50,7 +48,9 @@ class VexingArcanixEffect extends OneShotEffect {
|
||||||
|
|
||||||
public VexingArcanixEffect() {
|
public VexingArcanixEffect() {
|
||||||
super(Outcome.DrawCard);
|
super(Outcome.DrawCard);
|
||||||
staticText = "Target player chooses a card name, then reveals the top card of their library. If that card has the chosen name, the player puts it into their hand. Otherwise, the player puts it into their graveyard and {this} deals 2 damage to them";
|
staticText = "Target player chooses a card name, then reveals the top card of their library. " +
|
||||||
|
"If that card has the chosen name, the player puts it into their hand. Otherwise, " +
|
||||||
|
"the player puts it into their graveyard and {this} deals 2 damage to them";
|
||||||
}
|
}
|
||||||
|
|
||||||
public VexingArcanixEffect(final VexingArcanixEffect effect) {
|
public VexingArcanixEffect(final VexingArcanixEffect effect) {
|
||||||
|
@ -61,34 +61,27 @@ class VexingArcanixEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
if (sourceObject != null && player != null) {
|
if (sourceObject == null || player == null) {
|
||||||
Choice cardChoice = new ChoiceImpl();
|
return false;
|
||||||
cardChoice.setChoices(CardRepository.instance.getNames());
|
}
|
||||||
cardChoice.setMessage("Name a card");
|
String cardName = ChooseACardNameEffect.TypeOfName.ALL.getChoice(player, game, source, false);
|
||||||
if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
return false;
|
if (card == null) {
|
||||||
}
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
|
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
|
||||||
if (card != null) {
|
|
||||||
Cards cards = new CardsImpl(card);
|
|
||||||
player.revealCards(sourceObject.getIdName(), cards, game);
|
|
||||||
if (CardUtil.haveSameNames(card, cardName, game)) {
|
|
||||||
player.moveCards(cards, Zone.HAND, source, game);
|
|
||||||
} else {
|
|
||||||
player.moveCards(cards, Zone.GRAVEYARD, source, game);
|
|
||||||
player.damage(2, source.getSourceId(), source, game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
Cards cards = new CardsImpl(card);
|
||||||
|
player.revealCards(sourceObject.getIdName(), cards, game);
|
||||||
|
if (CardUtil.haveSameNames(card, cardName, game)) {
|
||||||
|
player.moveCards(cards, Zone.HAND, source, game);
|
||||||
|
} else {
|
||||||
|
player.moveCards(cards, Zone.GRAVEYARD, source, game);
|
||||||
|
player.damage(2, source.getSourceId(), source, game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VexingArcanixEffect copy() {
|
public VexingArcanixEffect copy() {
|
||||||
return new VexingArcanixEffect(this);
|
return new VexingArcanixEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
|
|
||||||
package mage.cards.w;
|
package mage.cards.w;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||||
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
|
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.choices.Choice;
|
|
||||||
import mage.choices.ChoiceImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
@ -23,8 +19,9 @@ import mage.filter.predicate.mageobject.NamePredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class WoodSage extends CardImpl {
|
public final class WoodSage extends CardImpl {
|
||||||
|
@ -37,8 +34,7 @@ public final class WoodSage extends CardImpl {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// {tap}: Name a creature card. Reveal the top four cards of your library and put all of them with that name into your hand. Put the rest into your graveyard.
|
// {tap}: Name a creature card. Reveal the top four cards of your library and put all of them with that name into your hand. Put the rest into your graveyard.
|
||||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WoodSageEffect(), new TapSourceCost()));
|
this.addAbility(new SimpleActivatedAbility(new WoodSageEffect(), new TapSourceCost()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WoodSage(final WoodSage card) {
|
private WoodSage(final WoodSage card) {
|
||||||
|
@ -55,7 +51,8 @@ class WoodSageEffect extends OneShotEffect {
|
||||||
|
|
||||||
public WoodSageEffect() {
|
public WoodSageEffect() {
|
||||||
super(Outcome.DrawCard);
|
super(Outcome.DrawCard);
|
||||||
this.staticText = "Name a creature card. Reveal the top four cards of your library and put all of them with that name into your hand. Put the rest into your graveyard";
|
this.staticText = "choose a creature card name. Reveal the top four cards of your library " +
|
||||||
|
"and put all of them with that name into your hand. Put the rest into your graveyard";
|
||||||
}
|
}
|
||||||
|
|
||||||
public WoodSageEffect(final WoodSageEffect effect) {
|
public WoodSageEffect(final WoodSageEffect effect) {
|
||||||
|
@ -70,26 +67,15 @@ class WoodSageEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (controller != null && sourceObject != null) {
|
if (controller == null || sourceObject == null) {
|
||||||
Choice cardChoice = new ChoiceImpl();
|
return false;
|
||||||
cardChoice.setChoices(CardRepository.instance.getCreatureNames());
|
|
||||||
cardChoice.setMessage("Name a creature card");
|
|
||||||
if (!controller.choose(Outcome.Detriment, cardChoice, game)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
|
|
||||||
FilterCreatureCard filter = new FilterCreatureCard("all of them with that name");
|
|
||||||
filter.add(new NamePredicate(cardName));
|
|
||||||
new RevealLibraryPutIntoHandEffect(4, filter, Zone.GRAVEYARD).apply(game, source);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
String cardName = ChooseACardNameEffect.TypeOfName.CREATURE_NAME.getChoice(controller, game, source, false);
|
||||||
|
FilterCreatureCard filter = new FilterCreatureCard("all of them with that name");
|
||||||
|
filter.add(new NamePredicate(cardName));
|
||||||
|
new RevealLibraryPutIntoHandEffect(4, filter, Zone.GRAVEYARD).apply(game, source);
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
@ -20,14 +23,65 @@ public class ChooseACardNameEffect extends OneShotEffect {
|
||||||
public static final String INFO_KEY = "NAMED_CARD";
|
public static final String INFO_KEY = "NAMED_CARD";
|
||||||
|
|
||||||
public enum TypeOfName {
|
public enum TypeOfName {
|
||||||
ALL,
|
ALL("card name", CardRepository.instance::getNames),
|
||||||
NOT_BASIC_LAND_NAME,
|
NOT_BASIC_LAND_NAME("card name other than a basic land card", CardRepository.instance::getNotBasicLandNames),
|
||||||
NONBASIC_LAND_NAME,
|
NONBASIC_LAND_NAME("nonbasic land card name", CardRepository.instance::getNonbasicLandNames),
|
||||||
NON_ARTIFACT_AND_NON_LAND_NAME,
|
NON_ARTIFACT_AND_NON_LAND_NAME("nonartifact, nonland card name", CardRepository.instance::getNonArtifactAndNonLandNames),
|
||||||
NON_LAND_NAME,
|
NON_LAND_AND_NON_CREATURE_NAME("nonland and non creature name", CardRepository.instance::getNonLandAndNonCreatureNames),
|
||||||
NON_LAND_AND_NON_CREATURE_NAME,
|
NON_LAND_NAME("nonland card name", CardRepository.instance::getNonLandNames),
|
||||||
CREATURE_NAME,
|
CREATURE_NAME("creature card name", CardRepository.instance::getCreatureNames),
|
||||||
ARTIFACT_NAME
|
ARTIFACT_NAME("artifact card name", CardRepository.instance::getArtifactNames);
|
||||||
|
|
||||||
|
private final String description;
|
||||||
|
private final Supplier<Set<String>> nameSupplier;
|
||||||
|
|
||||||
|
TypeOfName(String description, Supplier<Set<String>> nameSupplier) {
|
||||||
|
this.description = description;
|
||||||
|
this.nameSupplier = nameSupplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String getMessage() {
|
||||||
|
return "choose " + CardUtil.addArticle(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Set<String> getNames() {
|
||||||
|
return nameSupplier.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChoice(Game game, Ability source) {
|
||||||
|
return getChoice(game.getPlayer(source.getControllerId()), game, source, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChoice(Player player, Game game, Ability source, boolean setValue) {
|
||||||
|
if (player == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Choice cardChoice = new ChoiceImpl(true);
|
||||||
|
cardChoice.setChoices(this.getNames());
|
||||||
|
cardChoice.setMessage(CardUtil.getTextWithFirstCharUpperCase(this.getMessage()));
|
||||||
|
cardChoice.clearChoice();
|
||||||
|
player.choose(Outcome.Detriment, cardChoice, game);
|
||||||
|
String cardName = cardChoice.getChoice();
|
||||||
|
if (cardName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
||||||
|
if (sourceObject == null) {
|
||||||
|
sourceObject = source.getSourceObject(game);
|
||||||
|
}
|
||||||
|
if (sourceObject == null) {
|
||||||
|
return cardName;
|
||||||
|
}
|
||||||
|
game.informPlayers(sourceObject.getLogName() + ": " + player.getName() + ", chosen name: [" + cardName + ']');
|
||||||
|
if (!setValue) {
|
||||||
|
return cardName;
|
||||||
|
}
|
||||||
|
game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
|
||||||
|
if (sourceObject instanceof Permanent) {
|
||||||
|
((Permanent) sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Chosen name: " + cardName), game);
|
||||||
|
}
|
||||||
|
return cardName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TypeOfName typeOfName;
|
private final TypeOfName typeOfName;
|
||||||
|
@ -35,7 +89,7 @@ public class ChooseACardNameEffect extends OneShotEffect {
|
||||||
public ChooseACardNameEffect(TypeOfName typeOfName) {
|
public ChooseACardNameEffect(TypeOfName typeOfName) {
|
||||||
super(Outcome.Detriment);
|
super(Outcome.Detriment);
|
||||||
this.typeOfName = typeOfName;
|
this.typeOfName = typeOfName;
|
||||||
staticText = setText();
|
staticText = "choose " + CardUtil.addArticle(typeOfName.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChooseACardNameEffect(final ChooseACardNameEffect effect) {
|
public ChooseACardNameEffect(final ChooseACardNameEffect effect) {
|
||||||
|
@ -45,97 +99,11 @@ public class ChooseACardNameEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
return typeOfName.getChoice(game, source) != null;
|
||||||
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
|
||||||
if (sourceObject == null) {
|
|
||||||
sourceObject = game.getObject(source.getSourceId());
|
|
||||||
}
|
|
||||||
if (controller != null && sourceObject != null) {
|
|
||||||
Choice cardChoice = new ChoiceImpl(true);
|
|
||||||
switch (typeOfName) {
|
|
||||||
case ALL:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNames());
|
|
||||||
cardChoice.setMessage("Choose a card name");
|
|
||||||
break;
|
|
||||||
case NOT_BASIC_LAND_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
|
|
||||||
cardChoice.setMessage("Choose a card name other than a basic land card name");
|
|
||||||
break;
|
|
||||||
case NONBASIC_LAND_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNonbasicLandNames());
|
|
||||||
cardChoice.setMessage("Choose a nonbasic land card name");
|
|
||||||
break;
|
|
||||||
case NON_ARTIFACT_AND_NON_LAND_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNonArtifactAndNonLandNames());
|
|
||||||
cardChoice.setMessage("Choose a nonartifact, nonland card name");
|
|
||||||
break;
|
|
||||||
case NON_LAND_AND_NON_CREATURE_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNonLandAndNonCreatureNames());
|
|
||||||
cardChoice.setMessage("Choose a nonland and non creature card");
|
|
||||||
break;
|
|
||||||
case NON_LAND_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
|
|
||||||
cardChoice.setMessage("Choose a nonland card name");
|
|
||||||
break;
|
|
||||||
case CREATURE_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getCreatureNames());
|
|
||||||
cardChoice.setMessage("Choose a creature card name");
|
|
||||||
break;
|
|
||||||
case ARTIFACT_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getArtifactNames());
|
|
||||||
cardChoice.setMessage("Choose an artifact card name");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
if (controller.choose(Outcome.Detriment, cardChoice, game)) {
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ", chosen name: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
|
|
||||||
if (sourceObject instanceof Permanent) {
|
|
||||||
((Permanent) sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Chosen name: " + cardName), game);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChooseACardNameEffect copy() {
|
public ChooseACardNameEffect copy() {
|
||||||
return new ChooseACardNameEffect(this);
|
return new ChooseACardNameEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String setText() {
|
|
||||||
StringBuilder sb = new StringBuilder("choose a ");
|
|
||||||
switch (typeOfName) {
|
|
||||||
case ALL:
|
|
||||||
sb.append("card");
|
|
||||||
break;
|
|
||||||
case NOT_BASIC_LAND_NAME:
|
|
||||||
sb.append("card name other than a basic land card");
|
|
||||||
break;
|
|
||||||
case NONBASIC_LAND_NAME:
|
|
||||||
sb.append("nonbasic land card name");
|
|
||||||
break;
|
|
||||||
case NON_ARTIFACT_AND_NON_LAND_NAME:
|
|
||||||
sb.append("nonartifact, nonland card");
|
|
||||||
break;
|
|
||||||
case NON_LAND_AND_NON_CREATURE_NAME:
|
|
||||||
sb.append("noncreature, nonland card");
|
|
||||||
break;
|
|
||||||
case NON_LAND_NAME:
|
|
||||||
sb.append("nonland card");
|
|
||||||
break;
|
|
||||||
case CREATURE_NAME:
|
|
||||||
sb.append("creature card");
|
|
||||||
break;
|
|
||||||
case ARTIFACT_NAME:
|
|
||||||
sb.append("artifact card");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sb.append(" name");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,21 +141,6 @@ public enum CardRepository {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getNames() {
|
|
||||||
Set<String> names = new TreeSet<>();
|
|
||||||
try {
|
|
||||||
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
|
|
||||||
qb.distinct().selectColumns("name", "modalDoubleFacesSecondSideName", "secondSideName", "flipCardName");
|
|
||||||
List<CardInfo> results = cardDao.query(qb.prepare());
|
|
||||||
for (CardInfo card : results) {
|
|
||||||
addNewNames(card, names);
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
Logger.getLogger(CardRepository.class).error("Error getting names from DB : " + ex);
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addNewNames(CardInfo card, Set<String> namesList) {
|
private void addNewNames(CardInfo card, Set<String> namesList) {
|
||||||
// require before call: qb.distinct().selectColumns("name", "modalDoubleFacesSecondSideName"...);
|
// require before call: qb.distinct().selectColumns("name", "modalDoubleFacesSecondSideName"...);
|
||||||
|
|
||||||
|
@ -180,6 +165,25 @@ public enum CardRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean haveSnowLands(String setCode) {
|
||||||
|
return snowLandSetCodes.contains(setCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getNames() {
|
||||||
|
Set<String> names = new TreeSet<>();
|
||||||
|
try {
|
||||||
|
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
|
||||||
|
qb.distinct().selectColumns("name", "modalDoubleFacesSecondSideName", "secondSideName", "flipCardName");
|
||||||
|
List<CardInfo> results = cardDao.query(qb.prepare());
|
||||||
|
for (CardInfo card : results) {
|
||||||
|
addNewNames(card, names);
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
Logger.getLogger(CardRepository.class).error("Error getting names from DB : " + ex);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> getNonLandNames() {
|
public Set<String> getNonLandNames() {
|
||||||
Set<String> names = new TreeSet<>();
|
Set<String> names = new TreeSet<>();
|
||||||
try {
|
try {
|
||||||
|
@ -197,10 +201,6 @@ public enum CardRepository {
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean haveSnowLands(String setCode) {
|
|
||||||
return snowLandSetCodes.contains(setCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getNonbasicLandNames() {
|
public Set<String> getNonbasicLandNames() {
|
||||||
Set<String> names = new TreeSet<>();
|
Set<String> names = new TreeSet<>();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue