use of mage.target.targetpointer.FixedTarget 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.target.targetpointer.FixedTarget in project mage by magefree.
the class PrimordialMistCastFromExileEffect method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
if (target.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
Card targetCard = game.getCard(target.getFirstTarget());
if (targetPermanent != null && targetCard != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled>";
controller.moveCardsToExile(targetPermanent, source, game, true, source.getSourceId(), exileName);
targetPermanent.setFaceDown(false, game);
PrimordialMistCastFromExileEffect effect = new PrimordialMistCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(targetCard.getId()));
game.addEffect(effect, ability);
this.setPaid();
}
}
}
this.setPaid();
return true;
}
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class RakdossReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
if (player == null) {
return false;
}
Effect effect = new DiscardTargetEffect(ManacostVariableValue.REGULAR);
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class RakishHeirTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent permanent = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && permanent != null && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) {
this.getEffects().clear();
AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
this.addEffect(effect);
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget 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;
}
Aggregations