use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.
the class SabaccGameEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (targetPermanent != null) {
Player opponent = game.getPlayer(targetPermanent.getControllerId());
if (opponent != null) {
FilterPermanent filter = new FilterPermanent("permanent controlled by " + controller.getName());
filter.add(new ControllerIdPredicate(controller.getId()));
TargetPermanent target = new TargetPermanent(1, 1, filter, true);
Permanent chosenPermanent = null;
if (target.chooseTarget(outcome, opponent.getId(), source, game)) {
chosenPermanent = game.getPermanent(target.getFirstTarget());
}
boolean flipWin = controller.flipCoin(source, game, true);
if (flipWin) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, controller.getId());
effect.setTargetPointer(new FixedTarget(targetPermanent, game));
game.addEffect(effect, source);
} else if (chosenPermanent != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, opponent.getId());
effect.setTargetPointer(new FixedTarget(chosenPermanent, game));
game.addEffect(effect, source);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.
the class SkyfireKirinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = null;
for (Target target : source.getTargets()) {
if (target instanceof TargetPermanent) {
targetCreature = game.getPermanent(target.getFirstTarget());
}
}
if (targetCreature != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.
the class DonateEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetPlayer != null && permanent != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, targetPlayer.getId());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.
the class GiltLeafArchdruidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && targetPlayer != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LANDS, targetPlayer.getId(), game)) {
if (permanent != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.
the class ShurikenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Object object = getValue("attachedPermanent");
Player player = game.getPlayer(source.getControllerId());
Permanent targetedPermanent = game.getPermanent(source.getFirstTarget());
if (!(object instanceof Permanent) || player == null || targetedPermanent == null) {
return false;
}
Permanent equipment = (Permanent) object;
targetedPermanent.damage(2, equipment.getId(), source, game);
Permanent attached = source.getSourcePermanentOrLKI(game);
if (attached != null && attached.hasSubtype(SubType.NINJA, game)) {
return true;
}
game.addEffect(new GainControlTargetEffect(Duration.Custom, true, attached.getControllerId()).setTargetPointer(new FixedTarget(equipment, game)), source);
return true;
}
Aggregations