use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class HatefulEidolonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int auraCount = 0;
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (deadCreature.getAttachments().isEmpty()) {
return false;
}
for (UUID auraId : deadCreature.getAttachments()) {
Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
// Shadowspear or any other equipment does not count
auraCount += 1;
}
}
if (auraCount == 0) {
// just equipment not aura's
return false;
}
Player controller = game.getPlayer(controllerId);
if (controller != null && controller.canRespond()) {
this.getEffects().clear();
DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
drawCard.setTargetPointer(new FixedTarget(controllerId));
this.addEffect(drawCard);
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class HaukensInsightWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
MageObject sourceObject = source.getSourceObject(game);
String exileName = sourceObject == null ? null : sourceObject.getIdName();
controller.moveCardsToExile(card, source, game, true, exileId, exileName);
if (game.getState().getZone(card.getId()) == Zone.EXILED) {
card.setFaceDown(true, game);
HaukensInsightLookEffect effect = new HaukensInsightLookEffect(controller.getId());
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
return true;
}
}
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class HauntingWindTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent == null || !permanent.isArtifact(game)) {
return false;
}
StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
if (stackAbility == null) {
return false;
}
String abilityText = stackAbility.getRule(true);
if (abilityText.contains("{T}:") || abilityText.contains("{T},") || abilityText.contains("{T} or")) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent.getControllerId(), game));
}
return true;
}
if (event.getType() == GameEvent.EventType.TAPPED) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null || !permanent.isArtifact(game)) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent.getControllerId(), game));
}
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class HateMirageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
source.getTargets().stream().map(Target::getTargets).flatMap(Collection::stream).forEach(uuid -> {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
effect.setTargetPointer(new FixedTarget(uuid, game));
effect.apply(game, source);
effect.exileTokensCreatedAtNextEndStep(game, source);
});
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class InameAsOneEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
if (controller != null && sourceObject != null && targetCard != null) {
if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit card?", source, game)) {
// In a Commander game, you may send Iname to the Command Zone instead of exiling it during the resolution
// of its ability. If you do, its ability still works. Iname's ability only requires that you attempted to
// exile it, not that it actually gets to the exile zone. This is similar to how destroying a creature
// (with, for example, Rest in Peace) doesn't necessarily ensure that creature will end up in the graveyard;
// it just so happens that the action of exiling something and the exile zone both use the same word: "exile".
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(targetCard.getId(), targetCard.getZoneChangeCounter(game)));
new ExileSourceEffect().apply(game, source);
return effect.apply(game, source);
}
return true;
}
return false;
}
Aggregations