use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class RakdosRiteknifeEffect method makeAbility.
private static Ability makeAbility(Permanent permanent, Game game) {
Ability ability = new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.BLOOD.createInstance()).setText("put a blood counter on " + permanent.getName()).setTargetPointer(new FixedTarget(permanent, game)), new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)));
return ability;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class RampageOfTheValkyriesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null || player.getId().equals(source.getControllerId())) {
continue;
}
TargetPermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), playerId, game)) {
continue;
}
player.choose(outcome, target, source.getSourceId(), game);
perms.add(target.getFirstTarget());
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class ReignOfThePitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int totalPowerSacrificed = 0;
List<UUID> perms = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
while (!target.isChosen() && player.canRespond()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
perms.addAll(target.getTargets());
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
int power = permanent.getPower().getValue();
if (permanent.sacrifice(source, game)) {
totalPowerSacrificed += power;
}
}
}
new CreateTokenEffect(new DemonFlyingToken(totalPowerSacrificed)).apply(game, source);
return true;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class FinalityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Target target = new TargetControlledCreaturePermanent(0, 1);
target.setNotTarget(true);
if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
}
game.addEffect(new BoostAllEffect(-4, -4, Duration.EndOfTurn), source);
return true;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class FrayingOmnipotenceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// Each player loses half of their life,
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int lifeToLose = (int) Math.ceil(player.getLife() / 2.0);
player.loseLife(lifeToLose, game, source, false);
}
// then discards half of the cards in their hand,
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 2.0);
if (cardsToDiscard > 0) {
player.discard(cardsToDiscard, false, false, source, game);
}
}
// then sacrifices half of the creatures they control,
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 2.0);
if (creaturesToSacrifice == 0) {
continue;
}
Target target = new TargetControlledCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true);
target.chooseTarget(Outcome.Sacrifice, playerId, source, game);
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
}
return true;
}
Aggregations