use of mage.abilities.effects.common.combat.CantAttackYouAllEffect 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.abilities.effects.common.combat.CantAttackYouAllEffect in project mage by magefree.
the class IslandSanctuaryEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(event.getPlayerId());
if (controller != null && controller.chooseUse(outcome, "Skip draw card? (If you do, until your next turn, you can't be attacked except by creatures with flying and/or islandwalk)", source, game)) {
game.informPlayers(controller.getLogName() + " skips their draw card action. Until their next turn, they can't be attacked except by creatures with flying and/or islandwalk");
game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, notFlyingorIslandwalkCreatures), source);
return true;
}
return false;
}
Aggregations