use of mage.ApprovingObject in project mage by magefree.
the class SpellshiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player spellController = game.getPlayer(((Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK)).getControllerId());
if (spellController != null) {
Cards cardsToReveal = new CardsImpl();
Card toCast = null;
for (Card card : spellController.getLibrary().getCards(game)) {
cardsToReveal.add(card);
if (card.isSorcery(game) || card.isInstant(game)) {
toCast = card;
break;
}
}
spellController.revealCards(source, cardsToReveal, game);
if (toCast != null && spellController.chooseUse(outcome, "Cast " + toCast.getLogName() + " without paying its mana cost?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + toCast.getId(), Boolean.TRUE);
spellController.cast(spellController.chooseAbilityForCast(toCast, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + toCast.getId(), null);
}
spellController.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class SpelltwineEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card cardOne = game.getCard(source.getTargets().get(0).getFirstTarget());
Card cardTwo = game.getCard(source.getTargets().get(1).getFirstTarget());
if (controller != null) {
if (cardOne != null) {
controller.moveCards(cardOne, Zone.EXILED, source, game);
}
if (cardTwo != null) {
controller.moveCards(cardTwo, Zone.EXILED, source, game);
}
boolean castCardOne = true;
ApprovingObject approvingObject = new ApprovingObject(source, game);
if (cardOne != null && controller.chooseUse(Outcome.Neutral, "Cast the copy of " + cardOne.getName() + " first?", source, game)) {
Card copyOne = game.copyCard(cardOne, source, controller.getId());
game.getState().setValue("PlayFromNotOwnHandZone" + copyOne.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(copyOne, game, true), game, true, approvingObject);
game.getState().setValue("PlayFromNotOwnHandZone" + copyOne.getId(), null);
castCardOne = false;
}
if (cardTwo != null) {
Card copyTwo = game.copyCard(cardTwo, source, controller.getId());
game.getState().setValue("PlayFromNotOwnHandZone" + copyTwo.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(copyTwo, game, true), game, true, approvingObject);
game.getState().setValue("PlayFromNotOwnHandZone" + copyTwo.getId(), null);
}
if (cardOne != null && castCardOne) {
Card copyOne = game.copyCard(cardOne, source, controller.getId());
game.getState().setValue("PlayFromNotOwnHandZone" + copyOne.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(copyOne, game, true), game, true, approvingObject);
game.getState().setValue("PlayFromNotOwnHandZone" + copyOne.getId(), null);
}
return true;
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class ThunderbladeChargeCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (controller != null && sourceCard != null && Zone.GRAVEYARD == game.getState().getZone(sourceCard.getId())) {
game.getState().setValue("PlayFromNotOwnHandZone" + sourceCard.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(sourceCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + sourceCard.getId(), null);
return cardWasCast;
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class VelomachusLoreholdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (controller == null || permanent == null) {
return false;
}
Set<Card> cardsSet = controller.getLibrary().getTopCards(game, 7);
Cards cards = new CardsImpl(cardsSet);
FilterCard filter = new FilterInstantOrSorceryCard("instant or sorcery card with mana value " + permanent.getPower().getValue() + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getPower().getValue() + 1));
TargetCard target = new TargetCardInLibrary(0, 1, filter);
controller.choose(Outcome.PlayForFree, cards, target, game);
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
if (cardWasCast) {
cards.remove(card);
}
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.ApprovingObject in project mage by magefree.
the class DjinnOfWishesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
if (!controller.chooseUse(Outcome.PlayForFree, "Play " + card.getName() + " without paying its mana cost?", source, game) || !controller.playCard(card, game, true, new ApprovingObject(source, game))) {
controller.moveCards(card, Zone.EXILED, source, game);
}
return true;
}
return false;
}
Aggregations