use of mage.abilities.effects.common.FightTargetSourceEffect in project mage by magefree.
the class HansErikssonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
player.revealCards(source, new CardsImpl(card), game);
if (!card.isCreature(game)) {
return player.moveCards(card, Zone.HAND, source, game);
}
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return true;
}
UUID defendingPlayerId = getTargetPointer().getFirst(game, source);
UUID defenderId;
if (game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, source.getSourceId(), defendingPlayerId, game) < 1) {
defenderId = defendingPlayerId;
} else {
FilterPlayerOrPlaneswalker filter = new FilterPlayerOrPlaneswalker("defending player or a planeswalker they control");
filter.getPlayerFilter().add(new PlayerIdPredicate(defendingPlayerId));
filter.getPermanentFilter().add(new ControllerIdPredicate(defendingPlayerId));
TargetPlayerOrPlaneswalker target = new TargetPlayerOrPlaneswalker(filter);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
defenderId = target.getFirstTarget();
}
if (defenderId != null) {
game.getCombat().addAttackerToCombat(permanent.getId(), defenderId, game);
}
Effect fightEffect = new FightTargetSourceEffect();
fightEffect.setTargetPointer(new FixedTarget(permanent, game));
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(fightEffect, false, "When you put a creature card onto the battlefield this way, it fights {this}");
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.common.FightTargetSourceEffect in project mage by magefree.
the class MythosOfIllunaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId());
if (condition.apply(game, source)) {
Ability ability = new ConditionalInterveningIfTriggeredAbility(new EntersBattlefieldTriggeredAbility(new FightTargetSourceEffect()), MythosOfIllunaCondition.instance, "When this permanent enters the battlefield, " + "if it's a creature, it fights up to one target creature you don't control.");
ability.addTarget(new TargetPermanent(0, 1, StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, false));
effect.addAdditionalAbilities(ability);
}
return effect.apply(game, source);
}
use of mage.abilities.effects.common.FightTargetSourceEffect in project mage by magefree.
the class SkophosMazeWardenTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject == null) {
return false;
}
Permanent permanent = game.getPermanent(stackObject.getSourceId());
if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.isLand(game) || !permanent.getName().equals("Labyrinth of Skophos")) {
return false;
}
Permanent creature = game.getPermanent(event.getTargetId());
if (creature == null || !creature.isCreature(game) || creature.getId().equals(getSourceId())) {
return false;
}
this.getEffects().clear();
this.addEffect(new FightTargetSourceEffect().setTargetPointer(new FixedTarget(creature, game)));
return true;
}
use of mage.abilities.effects.common.FightTargetSourceEffect in project mage by magefree.
the class CherishedHatchlingTriggeredAbility method getEffectToAdd.
private static Effect getEffectToAdd() {
Ability abilityToAdd = new EntersBattlefieldTriggeredAbility(new FightTargetSourceEffect().setText("you may have it fight another target creature"), true);
abilityToAdd.addTarget(new TargetCreaturePermanent(filter));
Effect effect = new GainAbilityTargetEffect(abilityToAdd, Duration.EndOfTurn, "it gains \"When this creature enters the battlefield, you may have it fight another target creature.\"", true);
return effect;
}
Aggregations