use of mage.target.targetpointer.FixedTarget 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.target.targetpointer.FixedTarget in project mage by magefree.
the class RhysTheRedeemedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
if (permanent.isControlledBy(source.getControllerId())) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
}
}
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class ShowOfDominanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int highestPower = Integer.MIN_VALUE;
Permanent selectedCreature = null;
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
if (highestPower < permanent.getPower().getValue()) {
highestPower = permanent.getPower().getValue();
selectedCreature = permanent;
} else if (highestPower == permanent.getPower().getValue()) {
highestPower = permanent.getPower().getValue();
selectedCreature = null;
}
}
if (highestPower != Integer.MIN_VALUE) {
if (selectedCreature == null) {
FilterPermanent filter = new FilterCreaturePermanent("creature with power " + highestPower);
filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, highestPower));
Target target = new TargetPermanent(1, 1, filter, true);
if (controller.chooseTarget(outcome, target, source, game)) {
selectedCreature = game.getPermanent(target.getFirstTarget());
}
}
if (selectedCreature != null) {
FixedTarget target = new FixedTarget(selectedCreature.getId(), game);
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(4));
effect.setTargetPointer(target);
effect.apply(game, source);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
continuousEffect.setTargetPointer(target);
game.addEffect(continuousEffect, source);
return true;
}
}
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class ShowdownOfTheSkaldsDelayedTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> cards = controller.getLibrary().getTopCards(game, 4);
Card sourceCard = game.getCard(source.getSourceId());
controller.moveCardsToExile(cards, source, game, true, CardUtil.getCardExileZoneId(game, source), sourceCard != null ? sourceCard.getIdName() : "");
for (Card card : cards) {
ContinuousEffect effect = new ShowdownOfTheSkaldsMayPlayEffect();
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 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