use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class ScourgeOfNelTothPlayEffect method applies.
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
// can sometimes be cast with base mana cost from grave????
Costs<Cost> costs = new CostsImpl<>();
costs.add(new SacrificeTargetCost(new TargetControlledCreaturePermanent(2)));
player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{B}{B}"), costs);
return true;
}
}
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class VictimizeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
// To end effects of the sacrificed creature
game.getState().processAction(game);
controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return true;
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class CrushUnderfootEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// Choose a Giant creature you control (not targeted, happens during effect resolving )
Target target = new TargetControlledCreaturePermanent(1, 1, filter, false);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Permanent giant = game.getPermanent(target.getFirstTarget());
if (giant != null) {
game.informPlayers("Crush Underfoot: Chosen Giant is " + giant.getName());
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
targetCreature.damage(giant.getPower().getValue(), source.getSourceId(), source, game, false, true);
return true;
}
}
}
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class GaleaKindlerOfHopeEffect method makeAbility.
private static Ability makeAbility() {
Ability ability = new EntersBattlefieldTriggeredAbility(new AttachEffect(Outcome.BoostCreature, "attach it to target creature you control"), false).setTriggerPhrase("When this Equipment enters the battlefield, ");
ability.addTarget(new TargetControlledCreaturePermanent());
return ability;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class LiegeOfThePitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (player == null || sourcePermanent == null) {
return false;
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature other than " + sourcePermanent.getName());
filter.add(AnotherPredicate.instance);
Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
return true;
}
} else {
player.damage(7, source.getSourceId(), source, game);
return true;
}
return false;
}
Aggregations