use of mage.abilities.costs.Cost in project mage by magefree.
the class DemilichPlayEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (source.getSourceId().equals(objectId) && source.isControlledBy(affectedControllerId) && game.getState().getZone(objectId) == Zone.GRAVEYARD) {
Player controller = game.getPlayer(affectedControllerId);
if (controller != null) {
Costs<Cost> costs = new CostsImpl<>();
costs.add(new ExileFromGraveCost(new TargetCardInYourGraveyard(4, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY_FROM_YOUR_GRAVEYARD)));
controller.setCastSourceIdWithAlternateMana(objectId, new ManaCostsImpl<>("{U}{U}{U}{U}"), costs);
return true;
}
}
return false;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class DiscipleOfDeceitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (player != null && mageObject != null) {
Cost cost = new DiscardTargetCost(new TargetCardInHand(new FilterNonlandCard()));
String message = "Discard a nonland card to search your library?";
if (cost.canPay(source, source, source.getControllerId(), game) && player.chooseUse(Outcome.Detriment, message, source, game)) {
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
Card card = game.getCard(cost.getTargets().getFirstTarget());
if (card == null) {
return false;
}
String targetName = "card with mana value of " + card.getManaValue();
FilterCard filter = new FilterCard(targetName);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, card.getManaValue()));
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class EmberwildeDjinnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
if (cost.pay(source, game, source, player.getId(), false)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
game.addEffect(effect, source);
player.resetStoredBookmark(game);
}
}
return true;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class FrightfulDelusionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
Cost cost = ManaUtil.createManaCost(1, false);
if (spell != null) {
Player player = game.getPlayer(spell.getControllerId());
if (player != null) {
cost.clearPaid();
game.getPlayer(spell.getControllerId()).discard(1, false, false, source, game);
if (!cost.pay(source, game, source, spell.getControllerId(), false, null)) {
return game.getStack().counter(source.getFirstTarget(), source, game);
}
}
}
return false;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class LorcanWarlockCollectorReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (player == null || card == null) {
return false;
}
Cost cost = new PayLifeCost(card.getManaValue());
if (!cost.canPay(source, source, source.getControllerId(), game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
game.addEffect(new AddCardSubTypeTargetEffect(SubType.WARLOCK, Duration.Custom).setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1)), source);
player.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
}
Aggregations