use of mage.game.ExileZone in project mage by magefree.
the class CemeteryProwlerCostReductionEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
if (abilityToModify instanceof SpellAbility) {
// sourceObjectZoneChangeCounter is not working here. Getting it from GameState works.
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
ExileZone exileZone = game.getExile().getExileZone(exileId);
Card castCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
if (exileZone != null && castCard != null) {
HashSet<CardType> cardTypes = new HashSet<>();
for (UUID cardId : exileZone) {
Card card = game.getCard(cardId);
if (card != null) {
cardTypes.addAll(card.getCardType(game));
}
}
int sharedTypes = 0;
for (CardType type : castCard.getCardType(game)) {
if (cardTypes.contains(type)) {
sharedTypes++;
}
}
if (sharedTypes > 0) {
CardUtil.reduceCost(abilityToModify, sharedTypes);
return true;
}
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class AzorsGatewayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
UUID exileId = CardUtil.getCardExileZoneId(game, source);
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && exileId != null && sourceObject != null) {
controller.drawCards(1, source, game);
TargetCardInHand target = new TargetCardInHand();
controller.choose(outcome, target, source.getSourceId(), game);
Card cardToExile = game.getCard(target.getFirstTarget());
if (cardToExile != null) {
controller.moveCardsToExile(cardToExile, source, game, true, exileId, sourceObject.getIdName());
}
Set<Integer> usedCMC = new HashSet<>();
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null) {
for (Card card : exileZone.getCards(game)) {
usedCMC.add(card.getManaValue());
}
if (usedCMC.size() > 4) {
controller.gainLife(4, game, source);
new UntapSourceEffect().apply(game, source);
new TransformSourceEffect().apply(game, source);
}
}
return true;
}
return false;
}
Aggregations