use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class AureliasFuryDamagedByWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
AureliasFuryDamagedByWatcher watcher = game.getState().getWatcher(AureliasFuryDamagedByWatcher.class, source.getSourceId());
if (watcher != null) {
for (UUID creatureId : watcher.getDamagedCreatures()) {
Permanent permanent = game.getPermanent(creatureId);
if (permanent != null) {
permanent.tap(source, game);
}
}
for (UUID playerId : watcher.getDamagedPlayers()) {
ContinuousEffect effect = new AureliasFuryCantCastEffect();
effect.setTargetPointer(new FixedTarget(playerId));
game.addEffect(effect, source);
}
watcher.reset();
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class ProtectionChosenColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (!controller.choose(Outcome.Benefit, colorChoice, game)) {
return false;
}
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
if (protectColor != null) {
ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
game.addEffect(effect, source);
ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) {
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
return true;
}
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class BorosBattleshaperEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature1 = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (creature1 != null) {
if (game.getOpponents(creature1.getControllerId()).contains(game.getActivePlayerId())) {
// Blocks
ContinuousEffectImpl effect = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(BlocksThisTurnMarkerAbility.getInstance(), Duration.EndOfTurn, "");
effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
game.addEffect(effect, source);
} else {
// Attacks
ContinuousEffectImpl effect = new AttacksIfAbleTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(AttacksThisTurnMarkerAbility.getInstance(), Duration.EndOfTurn, "");
effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
game.addEffect(effect, source);
}
}
Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (creature2 != null) {
if (game.getOpponents(creature2.getControllerId()).contains(game.getActivePlayerId())) {
// Blocks
ContinuousEffectImpl effect = new CantBlockTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature2.getId(), game));
game.addEffect(effect, source);
} else {
// Attacks
ContinuousEffectImpl effect = new CantAttackTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature2.getId(), game));
game.addEffect(effect, source);
}
}
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class BondOfPassionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
permanent.untap(game);
effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
Permanent permanent2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent2 != null) {
permanent2.damage(2, source.getSourceId(), source, game);
} else {
Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (player != null) {
player.damage(2, source.getSourceId(), source, game);
}
}
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class BondOfRevivalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (player == null || card == null) {
return false;
}
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
game.addEffect(effect, source);
}
return true;
}
Aggregations