Package mage.target.common

Examples of mage.target.common.TargetDefender


  @Override
  public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature != null) {
      if (creature.canAttack(game)) {
        TargetDefender target = new TargetDefender(game.getCombat().getDefenders(), creature.getControllerId());
        target.setRequired(true);
        Player controller = game.getPlayer(creature.getControllerId());
        while (!target.isChosen())
          controller.chooseTarget(Outcome.Damage, target, source, game);
        game.getCombat().declareAttacker(creature.getId(), target.getFirstTarget(), game);
        return true;
      }
    }
    return false;
  }
View Full Code Here


  @Override
  public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getSourceId());
    if (creature != null) {
      if (creature.canAttack(game)) {
        TargetDefender target = new TargetDefender(game.getCombat().getDefenders(), creature.getControllerId());
        target.setRequired(true);
        Player controller = game.getPlayer(creature.getControllerId());
        while (!target.isChosen())
          controller.chooseTarget(Outcome.Damage, target, source, game);
        game.getCombat().declareAttacker(creature.getId(), target.getFirstTarget(), game);
        return true;
      }
    }
    return false;
  }
View Full Code Here

    if (defenders.size() == 1) {
      declareAttacker(attackerId, defenders.iterator().next(), game);
      return true;
    }
    else {
      TargetDefender target = new TargetDefender(defenders, attackerId);
      if (chooseTarget(Outcome.Damage, target, null, game)) {
        declareAttacker(attackerId, response.getUUID(), game);
        return true;
      }
    }
View Full Code Here

        Player player = game.getPlayer(attackerId);
        if (defenders.size() == 1) {
            declareAttacker(creatureId, defenders.iterator().next(), game);
            return true;
        } else {
            TargetDefender target = new TargetDefender(defenders, creatureId);
            target.setRequired(true);
            player.chooseTarget(Outcome.Damage, target, null, game);
            if (target.getFirstTarget() != null) {
                declareAttacker(creatureId, target.getFirstTarget(), game);
                return true;
            }
        }
        return false;
    }
View Full Code Here

                creaturesForcedToAttack.put(creature.getId(), defendersForcedToAttack);
                if (defendersForcedToAttack.isEmpty()) {
                    if (defenders.size() == 1) {
                        player.declareAttacker(creature.getId(), defenders.iterator().next(), game, false);
                    } else {
                        TargetDefender target = new TargetDefender(defenders, creature.getId());
                        target.setRequired(true);
                        if (player.chooseTarget(Outcome.Damage, target, null, game)) {
                            player.declareAttacker(creature.getId(), target.getFirstTarget(), game, false);
                        }
                    }
                } else {
                    player.declareAttacker(creature.getId(), defendersForcedToAttack.iterator().next(), game, false);
                }
View Full Code Here

        if (possibleDefender.size() == 1) {
            declareAttacker(attackerId, defenders.iterator().next(), game, true);
            return true;
        }
        else {
            TargetDefender target = new TargetDefender(possibleDefender, attackerId);
            target.setNotTarget(true); // player or planswalker hexproof does not prevent attacking a player
            if (forcedToAttack) {
                StringBuilder sb = new StringBuilder(target.getTargetName());
                Permanent attacker = game.getPermanent(attackerId);
                if (attacker != null) {
                    sb.append(" (").append(attacker.getName()).append(")");
                    target.setTargetName(sb.toString());
                }
            }
            if (chooseTarget(Outcome.Damage, target, null, game)) {
                declareAttacker(attackerId, response.getUUID(), game, true);
                return true;
View Full Code Here

TOP

Related Classes of mage.target.common.TargetDefender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.