use of mage.ApprovingObject in project mage by magefree.
the class RashmiEternitiesCrafterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Boolean cardWasCast = false;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.revealCards("Rashmi, Eternities Crafter", new CardsImpl(card), game);
if (card.isLand(game)) {
controller.moveCards(card, Zone.HAND, source, game);
return true;
}
Object cmcObject = this.getValue("RashmiEternitiesCrafterCMC");
if (cmcObject != null && card.getManaValue() < (int) cmcObject && controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying its mana cost?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
if (!cardWasCast) {
controller.moveCards(card, Zone.HAND, source, game);
}
return true;
}
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class ToshiroUmezawaReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null && controller.getGraveyard().contains(card.getId())) {
// must be in graveyard
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, false), game, false, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
game.addEffect(new ToshiroUmezawaReplacementEffect(card.getId()), source);
}
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class GarthOneEyeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
initMap();
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Set<String> alreadyChosen = getAlreadyChosen(game, source);
Set<String> choices = new HashSet<>(names);
choices.removeAll(alreadyChosen);
String chosen;
switch(choices.size()) {
case 0:
return false;
case 1:
chosen = choices.stream().findAny().orElse(null);
break;
default:
Choice choice = new ChoiceImpl(true, ChoiceHintType.CARD);
choice.setChoices(choices);
player.choose(outcome, choice, game);
chosen = choice.getChoice();
}
alreadyChosen.add(chosen);
Card card = cardMap.get(chosen);
if (card == null || !player.chooseUse(outcome, "Cast " + card.getName() + '?', source, game)) {
return false;
}
Card copiedCard = game.copyCard(card, source, source.getControllerId());
copiedCard.setZone(Zone.OUTSIDE, game);
game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE);
player.cast(player.chooseAbilityForCast(copiedCard, game, false), game, false, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null);
return true;
}
use of mage.ApprovingObject in project mage by magefree.
the class HarnessTheStormEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getGraveyard().get(getTargetPointer().getFirst(game, source), game);
if (card != null) {
if (controller.chooseUse(outcome.Benefit, "Cast " + card.getIdName() + " from your graveyard?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, false), game, false, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
return true;
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class MindleechMassEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (opponent != null && controller != null) {
Cards cardsInHand = new CardsImpl();
cardsInHand.addAll(opponent.getHand());
opponent.revealCards("Opponents hand", cardsInHand, game);
if (!cardsInHand.isEmpty() && !cardsInHand.getCards(new FilterNonlandCard(), game).isEmpty()) {
TargetCard target = new TargetCard(1, Zone.HAND, new FilterNonlandCard());
if (controller.chooseTarget(Outcome.PlayForFree, cardsInHand, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
}
return true;
}
return false;
}
Aggregations