use of mage.target.TargetSource in project mage by magefree.
the class ShamanEnKorRedirectFromTargetEffect method init.
@Override
public void init(Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
TargetSource target = new TargetSource();
target.choose(Outcome.PreventDamage, player.getId(), source.getSourceId(), game);
this.sourceObject = new MageObjectReference(target.getFirstTarget(), game);
} else {
discard();
}
}
use of mage.target.TargetSource in project mage by magefree.
the class InterventionPactPreventDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetSource();
target.setRequired(true);
target.setNotTarget(true);
if (controller.chooseTarget(outcome, target, source, game)) {
ContinuousEffect continuousEffect = new InterventionPactPreventDamageEffect();
continuousEffect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
game.addEffect(continuousEffect, source);
}
return true;
}
return false;
}
use of mage.target.TargetSource in project mage by magefree.
the class MournersShieldEffect method init.
@Override
public void init(Ability source, Game game) {
ObjectColor colorsAmongImprinted = new ObjectColor();
Permanent sourceObject = game.getPermanent(source.getSourceId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
if (sourceObject == null || sourceObject.getImprinted() == null) {
noneExiled = true;
return;
}
for (UUID imprinted : sourceObject.getImprinted()) {
if (imprinted != null && exileZone.contains(imprinted)) {
Card card = game.getCard(imprinted);
if (card != null) {
colorsAmongImprinted = colorsAmongImprinted.union(card.getColor(game));
}
}
}
FilterObject filterObject = new FilterObject("a source of your choice that shares a color with the exiled card");
filterObject.add(new SharesColorPredicate(colorsAmongImprinted));
this.target = new TargetSource(filterObject);
this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game);
if (target.getFirstTarget() != null) {
mageObjectReference = new MageObjectReference(target.getFirstTarget(), game);
} else {
mageObjectReference = null;
}
}
Aggregations