use of mage.players.Player in project mage by magefree.
the class DireFleetDaredevilReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
if (targetCard != null) {
if (controller.moveCards(targetCard, Zone.EXILED, source, game)) {
targetCard = game.getCard(targetCard.getId());
if (targetCard != null) {
// you may play and spend any mana
CardUtil.makeCardPlayable(game, source, targetCard, Duration.EndOfTurn, true);
// exile from graveyard
ContinuousEffect effect = new DireFleetDaredevilReplacementEffect();
effect.setTargetPointer(new FixedTarget(targetCard, game));
game.addEffect(effect, source);
return true;
}
}
}
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class DireFleetDaredevilReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
return controller.moveCards(card, Zone.EXILED, source, game);
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class DireTacticsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (permanent == null || player == null) {
return false;
}
int toughness = permanent.getToughness().getValue();
player.moveCards(permanent, Zone.EXILED, source, game);
if (game.getBattlefield().countAll(filter, player.getId(), game) < 1) {
player.loseLife(toughness, game, source, false);
}
return true;
}
use of mage.players.Player 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.players.Player in project mage by magefree.
the class DispersalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Set<PermanentIdPredicate> permsToReturn = new HashSet<>();
for (UUID opponentId : game.getOpponents(player.getId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent == null) {
continue;
}
int highestCMC = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponentId)) {
if (permanent != null) {
highestCMC = Math.max(highestCMC, permanent.getManaValue());
}
}
FilterPermanent filter = new FilterNonlandPermanent("permanent you control with mana value " + highestCMC);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, highestCMC));
filter.add(new ControllerIdPredicate(opponentId));
Target target = new TargetPermanent(1, 1, filter, true);
if (opponent.choose(outcome, target, source.getSourceId(), game)) {
if (target.getFirstTarget() == null) {
continue;
}
permsToReturn.add(new PermanentIdPredicate(target.getFirstTarget()));
}
}
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.or(permsToReturn));
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
new DiscardEachPlayerEffect(StaticValue.get(1), false, TargetController.OPPONENT).apply(game, source);
return true;
}
Aggregations