use of mage.MageObject in project mage by magefree.
the class HedronAlignmentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Cards cardsToReveal = new CardsImpl();
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
// Check battlefield
if (!game.getBattlefield().contains(filterPermanent, source, game, 1)) {
return true;
}
if (controller.getHand().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
return true;
}
if (controller.getGraveyard().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
return true;
}
Cards cardsToCheck = new CardsImpl();
cardsToCheck.addAll(game.getExile().getAllCards(game));
if (cardsToCheck.count(filterCard, source.getSourceId(), controller.getId(), game) == 0) {
return true;
}
controller.won(game);
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class JestersScepterCounterEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
if (card != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject == null) {
return false;
}
UUID exileId = CardUtil.getCardExileZoneId(game, source);
ExileZone exile = game.getExile().getExileZone(exileId);
return exile != null && exile.contains(objectId);
}
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class JestersScepterCounterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetedPlayer = game.getPlayer(source.getFirstTarget());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && targetedPlayer != null && sourceObject != null) {
if (targetedPlayer.getLibrary().hasCards()) {
Set<Card> cardsToExile = targetedPlayer.getLibrary().getTopCards(game, 5);
for (Card card : cardsToExile) {
if (card.moveToExile(CardUtil.getCardExileZoneId(game, source), sourceObject.getName(), source, game)) {
card.setFaceDown(true, game);
}
}
}
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class JourneyForTheElixirGraveyardTarget method possibleTargets.
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Cards alreadyTargeted = new CardsImpl(this.getTargets());
alreadyTargeted.addAll(cards);
boolean hasBasic = alreadyTargeted.getCards(game).stream().filter(Objects::nonNull).filter(card1 -> card1.isLand(game)).anyMatch(MageObject::isBasic);
possibleTargets.removeIf(uuid -> {
Card card = game.getCard(uuid);
return card != null && hasBasic && card.isLand(game) && card.isBasic();
});
boolean hasYanggu = alreadyTargeted.getCards(game).stream().filter(Objects::nonNull).map(MageObject::getName).anyMatch(name::equals);
possibleTargets.removeIf(uuid -> {
Card card = game.getCard(uuid);
return card != null && hasYanggu && name.equals(card.getName());
});
return possibleTargets;
}
use of mage.MageObject in project mage by magefree.
the class KyrenArchiveReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
card.setFaceDown(true, game);
controller.moveCardsToExile(card, source, game, false, exileZoneId, sourceObject.getIdName());
card.setFaceDown(true, game);
return true;
}
}
return false;
}
Aggregations