use of mage.players.Player in project mage by magefree.
the class CosmicHorrorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent cosmicHorror = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && cosmicHorror != null) {
StringBuilder sb = new StringBuilder(cost.getText()).append('?');
if (!sb.toString().toLowerCase(Locale.ENGLISH).startsWith("exile ") && !sb.toString().toLowerCase(Locale.ENGLISH).startsWith("return ")) {
sb.insert(0, "Pay ");
}
if (controller.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
return true;
}
}
if (cosmicHorror.destroy(source, game, false)) {
controller.damage(7, source.getSourceId(), source, game);
return true;
}
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class CreamOfTheCropEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (controller != null && permanent != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, permanent.getPower().getValue()));
if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on top of your library"));
target.setNotTarget(true);
controller.chooseTarget(Outcome.Benefit, cards, target, source, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.putCardsOnTopOfLibrary(new CardsImpl(card), game, source, true);
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class CranialArchiveEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
for (Card card : targetPlayer.getGraveyard().getCards(game)) {
targetPlayer.moveCardToLibraryWithInfo(card, source, game, Zone.GRAVEYARD, true, true);
}
targetPlayer.shuffleLibrary(source, game);
}
controller.drawCards(1, source, game);
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class CranialExtractionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player == null) {
return true;
}
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;
}
use of mage.players.Player in project mage by magefree.
the class DefilerOfSoulsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("monocolored creature");
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player == null) {
return false;
}
filter.add(MonocoloredPredicate.instance);
int amount;
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
amount = Math.min(1, realCount);
Target target = new TargetControlledPermanent(amount, amount, filter, false);
target.setNotTarget(true);
// had, if thats the case this ability should fizzle.
if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
boolean abilityApplied = false;
while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
if (permanent != null) {
abilityApplied |= permanent.sacrifice(source, game);
}
}
return abilityApplied;
}
return false;
}
Aggregations