use of mage.game.ExileZone in project mage by magefree.
the class SkyshipWeatherlightEffect2 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
if (exZone != null) {
controller.moveCards(exZone.getRandom(game), Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class SynodSanctumEffect2 method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone == null) {
return true;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return controller.moveCards(exileZone, Zone.BATTLEFIELD, source, game);
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class WatcherForTomorrowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Permanent permanentLeftBattlefield = (Permanent) getValue("permanentLeftBattlefield");
if (permanentLeftBattlefield == null) {
return false;
}
ExileZone zone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanentLeftBattlefield.getZoneChangeCounter(game)));
if (zone == null) {
return false;
}
Cards cards = new CardsImpl(zone.getCards(game));
return player.moveCards(cards, Zone.HAND, source, game);
}
use of mage.game.ExileZone in project mage by magefree.
the class AdventureCastFromExileEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
UUID targetId = getTargetPointer().getFirst(game, source);
ExileZone adventureExileZone = game.getExile().getExileZone(ExileAdventureSpellEffect.adventureExileId(affectedControllerId, game));
if (targetId == null) {
this.discard();
} else if (objectId.equals(targetId) && affectedControllerId.equals(source.getControllerId()) && adventureExileZone.contains(objectId)) {
Card card = game.getCard(objectId);
return card != null;
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class GrimoireThiefCounterspellEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Cards cards = new CardsImpl();
MageObject sourceObject = game.getObject(source.getSourceId());
Set<UUID> exileZones = (Set<UUID>) game.getState().getValue(GrimoireThief.VALUE_PREFIX + source.getSourceId().toString());
if (exileZones != null && sourceObject != null) {
for (ExileZone exileZone : game.getExile().getExileZones()) {
if (!exileZone.isEmpty()) {
cards.addAll(exileZone.getCards(game));
}
}
// set face up first
for (Card card : cards.getCards(game)) {
card.setFaceDown(false, game);
}
// then counter any with the same name as the card exiled with Grimoire Thief
for (Card card : cards.getCards(game)) {
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext(); ) {
StackObject stackObject = iterator.next();
MageObject mageObject = game.getObject(card.getId());
String name1;
String name2;
if (mageObject instanceof SplitCard) {
name1 = ((SplitCard) mageObject).getLeftHalfCard().getName();
name2 = ((SplitCard) mageObject).getRightHalfCard().getName();
} else {
// modal double faces cards, adventure cards -- all have one name in non stack/battlefield zone
name1 = mageObject.getName();
name2 = name1;
}
if (CardUtil.haveSameNames(stackObject, name1, game) || CardUtil.haveSameNames(stackObject, name2, game)) {
Spell spell = (Spell) stackObject;
game.getStack().counter(stackObject.getId(), source, game);
game.informPlayers(sourceObject.getLogName() + ": spell " + spell.getIdName() + " was countered.");
}
}
}
return true;
}
return false;
}
Aggregations