use of mage.game.ExileZone in project mage by magefree.
the class HaukensInsightWatcher method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId()) && game.isActivePlayer(source.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId());
HaukensInsightWatcher watcher = game.getState().getWatcher(HaukensInsightWatcher.class);
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (controller != null && watcher != null && sourceObject != null && !watcher.isAbilityUsed(new MageObjectReference(sourceObject, game))) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(CardUtil.getMainCardId(game, objectId))) {
allowCardToPlayWithoutMana(objectId, source, affectedControllerId, game);
return true;
}
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class HazoretsUndyingFuryEffect 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) {
controller.shuffleLibrary(source, game);
// move cards from library to exile
controller.moveCardsToExile(controller.getLibrary().getTopCards(game, 4), source, game, true, source.getSourceId(), sourceObject.getIdName());
// cast the possible cards without paying the mana
ExileZone hazoretsUndyingFuryExileZone = game.getExile().getExileZone(source.getSourceId());
Cards cardsToCast = new CardsImpl();
if (hazoretsUndyingFuryExileZone == null) {
return true;
}
cardsToCast.addAll(hazoretsUndyingFuryExileZone.getCards(filter, source.getSourceId(), source.getControllerId(), game));
while (controller.canRespond() && !cardsToCast.isEmpty()) {
if (!controller.chooseUse(Outcome.PlayForFree, "Cast (another) a card exiled with " + sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
break;
}
TargetCard targetCard = new TargetCard(1, Zone.EXILED, new FilterCard("nonland card to cast for free"));
if (controller.choose(Outcome.PlayForFree, cardsToCast, targetCard, game)) {
Card card = game.getCard(targetCard.getFirstTarget());
if (card != null) {
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);
cardsToCast.remove(card);
if (!cardWasCast) {
game.informPlayer(controller, "You're not able to cast " + card.getIdName() + " or you canceled the casting.");
}
}
}
}
return true;
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class TargetCardInMuseVesselExile method possibleTargets.
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
Card sourceCard = game.getCard(sourceId);
if (sourceCard != null) {
UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null && !exile.isEmpty()) {
possibleTargets.addAll(exile);
}
}
return possibleTargets;
}
use of mage.game.ExileZone in project mage by magefree.
the class TargetCardInMuseVesselExile method canChoose.
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
Card sourceCard = game.getCard(sourceId);
if (sourceCard != null) {
UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null && !exile.isEmpty()) {
return true;
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class ValakutExplorationDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
if (exileZone == null) {
return false;
}
int count = exileZone.size();
if (count < 1) {
return false;
}
player.moveCards(exileZone, Zone.GRAVEYARD, source, game);
for (UUID playerId : game.getOpponents(source.getControllerId())) {
player = game.getPlayer(playerId);
if (playerId == null) {
continue;
}
player.damage(count, source.getSourceId(), source, game);
}
return true;
}
Aggregations