use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class ParoxysmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanent(source.getSourceId());
if (aura != null) {
Permanent creatureAttachedTo = game.getPermanent(aura.getAttachedTo());
if (creatureAttachedTo != null) {
Player controllerOfCreature = game.getPlayer(creatureAttachedTo.getControllerId());
if (controllerOfCreature != null) {
Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game);
if (revealCardFromTop != null) {
Cards cards = new CardsImpl(revealCardFromTop);
controllerOfCreature.revealCards(source, cards, game);
if (revealCardFromTop.isLand(game)) {
creatureAttachedTo.destroy(source, game, false);
} else {
ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId(), game));
game.addEffect(effect, source);
}
return true;
}
}
}
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class PredatorsHourLookEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (opponent == null) {
return false;
}
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject == null) {
return false;
}
Card topCard = opponent.getLibrary().getFromTop(game);
if (topCard == null) {
return false;
}
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
topCard.setFaceDown(true, game);
// Move card to exile
if (controller.moveCardsToExile(topCard, source, game, false, exileZoneId, sourceObject.getIdName())) {
topCard.setFaceDown(true, game);
Set<UUID> exileZones = (Set<UUID>) game.getState().getValue(VALUE_PREFIX + source.getSourceId().toString());
if (exileZones == null) {
exileZones = new HashSet<>();
game.getState().setValue(VALUE_PREFIX + source.getSourceId().toString(), exileZones);
}
exileZones.add(exileZoneId);
// You may play the card
ContinuousEffect effect = new PredatorsHourPlayFromExileEffect();
effect.setTargetPointer(new FixedTarget(topCard.getId(), game));
game.addEffect(effect, source);
// And you may spend mana as though it were mana of any color to cast it
effect = new PredatorsHourSpendAnyManaEffect();
effect.setTargetPointer(new FixedTarget(topCard.getId(), game));
game.addEffect(effect, source);
// For as long as that card remains exiled, you may look at it
effect = new PredatorsHourLookEffect(controller.getId());
effect.setTargetPointer(new FixedTarget(topCard.getId(), game));
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class RhythmOfTheWildEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player player = game.getPlayer(source.getControllerId());
if (creature == null || player == null) {
return false;
}
if (player.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
game.informPlayers(player.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
} else {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
game.addEffect(effect, source);
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class RideDownEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent blockingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (blockingCreature != null) {
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (combatGroup.getBlockers().contains(blockingCreature.getId())) {
for (UUID attackerId : combatGroup.getAttackers()) {
ContinuousEffect effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(attackerId, game));
game.addEffect(effect, source);
}
break;
}
}
blockingCreature.destroy(source, game, false);
}
return true;
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DoUnlessAnyOpponentPaysEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
String message;
if (chooseUseText == null) {
String effectText = executingEffects.getText(source.getModes().getMode());
message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?";
} else {
message = chooseUseText;
}
message = CardUtil.replaceSourceName(message, sourceObject.getName());
boolean result = true;
boolean doEffect = true;
// check if any opponent is willing to pay
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && player.canRespond() && !player.equals(controller) && cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Benefit, message, source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, player.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
}
doEffect = false;
break;
}
}
}
// do the effects if nobody paid
if (doEffect) {
for (Effect effect : executingEffects) {
effect.setTargetPointer(this.targetPointer);
if (effect instanceof OneShotEffect) {
result &= effect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) effect, source);
}
}
}
return result;
}
return false;
}
Aggregations