use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect 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;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect 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.abilities.effects.common.continuous.GainAbilityTargetEffect 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.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class TreacherousUrgeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId());
if (opponent != null && sourceObject != null) {
opponent.revealCards(sourceObject.getName(), opponent.getHand(), game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int cardsHand = opponent.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game);
Card card = null;
if (cardsHand > 0) {
TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_CREATURE);
if (controller.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
card = opponent.getHand().get(target.getFirstTarget(), game);
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
}
}
return false;
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class BesmirchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (game.getPermanent(source.getFirstTarget()) != null) {
TargetPointer target = new FixedTarget(source.getFirstTarget(), game);
// gain control
game.addEffect(new GainControlTargetEffect(Duration.EndOfTurn).setTargetPointer(target), source);
// haste
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(target), source);
// goad
game.addEffect(new GoadTargetEffect().setTargetPointer(target), source);
// untap
new UntapTargetEffect().setTargetPointer(target).apply(game, source);
return true;
}
return false;
}
Aggregations