use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class IndulgentTormentorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getFirstTarget());
if (opponent != null) {
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
if (cost.canPay(source, source, opponent.getId(), game) && opponent.chooseUse(outcome, "Sacrifice a creature to prevent the card draw?", source, game)) {
if (cost.pay(source, game, source, opponent.getId(), false, null)) {
return true;
}
}
cost = new PayLifeCost(3);
if (cost.canPay(source, source, opponent.getId(), game) && opponent.chooseUse(outcome, "Pay 3 life to prevent the card draw?", source, game)) {
if (cost.pay(source, game, source, opponent.getId(), false, null)) {
return true;
}
}
game.getPlayer(source.getControllerId()).drawCards(1, source, game);
return true;
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class OrzhovAdvokistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<UUID> players = new ArrayList<>();
List<UUID> creatures = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.chooseUse(outcome, "Put two +1/+1 counters on a creature you control?", source, game)) {
Target target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature you control (to add two +1/+1 counters on it)"));
if (player.choose(outcome, target, playerId, game)) {
creatures.add(target.getFirstTarget());
players.add(player.getId());
}
}
}
}
for (UUID creatureId : creatures) {
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(2), creature.getControllerId(), source, game);
}
}
for (UUID playerId : players) {
if (!Objects.equals(playerId, source.getControllerId())) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId));
game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter, true), source);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class DiscipleOfBolasEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
target.setRequired(true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
controller.chooseTarget(outcome, target, source, game);
Permanent sacrificed = game.getPermanent(target.getFirstTarget());
if (sacrificed != null) {
sacrificed.sacrifice(source, game);
int power = sacrificed.getPower().getValue();
controller.gainLife(power, game, source);
controller.drawCards(power, source, game);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class GravePactEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && !playerId.equals(source.getControllerId())) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class GrabTheReinsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID controllerId = source.getControllerId();
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
target.setTargetName("a creature to sacrifice");
if (!target.canChoose(source.getSourceId(), controllerId, game)) {
return false;
}
Player player = game.getPlayer(controllerId);
if (player != null) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
Permanent creatureToSacrifice = game.getPermanent(target.getTargets().get(0));
int amount = creatureToSacrifice.getPower().getValue();
if (!creatureToSacrifice.sacrifice(source, game)) {
return false;
}
if (amount > 0) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(amount, source.getSourceId(), source, game, false, true);
return true;
}
player = game.getPlayer(source.getFirstTarget());
if (player != null) {
player.damage(amount, source.getSourceId(), source, game);
return true;
}
} else {
return true;
}
}
return false;
}
Aggregations