Search in sources :

Example 1 with CantAttackYouAllEffect

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;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ArrayList(java.util.ArrayList) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) UUID(java.util.UUID) CantAttackYouAllEffect(mage.abilities.effects.common.combat.CantAttackYouAllEffect) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 2 with CantAttackYouAllEffect

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;
}
Also used : Player(mage.players.Player) CantAttackYouAllEffect(mage.abilities.effects.common.combat.CantAttackYouAllEffect)

Aggregations

CantAttackYouAllEffect (mage.abilities.effects.common.combat.CantAttackYouAllEffect)2 Player (mage.players.Player)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 Permanent (mage.game.permanent.Permanent)1 Target (mage.target.Target)1 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)1