use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class CurfewEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
game.informPlayers("Each player returns a creature they control to its owner's hand");
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game) > 0) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_CREATURE, true);
player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
player.moveCards(permanent, Zone.HAND, source, game);
}
}
}
return true;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class DeathsPresenceTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
if (zoneChangeEvent.isDiesEvent()) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (permanent != null && permanent.isControlledBy(this.getControllerId()) && permanent.isCreature(game)) {
this.getTargets().clear();
this.addTarget(new TargetControlledCreaturePermanent());
this.getEffects().clear();
this.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(permanent.getPower().getValue())));
return true;
}
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class BronzehideLionContinuousEffect method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
if (game.getState().getZoneChangeCounter(source.getSourceId()) > zoneChangeCounter) {
discard();
}
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (sourceObject == null) {
sourceObject = game.getPermanentEntering(source.getSourceId());
}
if (sourceObject == null) {
return false;
}
Permanent lion = sourceObject;
switch(layer) {
case TypeChangingEffects_4:
lion.removeAllCardTypes(game);
lion.addCardType(game, CardType.ENCHANTMENT);
lion.removeAllSubTypes(game);
lion.addSubType(game, SubType.AURA);
break;
case AbilityAddingRemovingEffects_6:
List<Ability> toRemove = new ArrayList<>();
for (Ability ability : lion.getAbilities(game)) {
if (!lion.getSpellAbility().equals(ability)) {
toRemove.add(ability);
}
}
lion.removeAbilities(toRemove, source.getSourceId(), game);
lion.getSpellAbility().getTargets().clear();
lion.getSpellAbility().getEffects().clear();
TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
lion.getSpellAbility().addTarget(auraTarget);
lion.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
lion.addAbility(new EnchantAbility(auraTarget.getTargetName()), source.getSourceId(), game);
// add the activated ability
activatedAbility.setControllerId(source.getControllerId());
lion.addAbility(activatedAbility, source.getSourceId(), game);
break;
}
return true;
}
Aggregations