Package mage.game.combat

Examples of mage.game.combat.CombatGroup


  }

  @Override
  public void declareBlocker(UUID blockerId, UUID attackerId, Game game) {
    Permanent blocker = game.getPermanent(blockerId);
    CombatGroup group = game.getCombat().findGroup(attackerId);
    if (blocker != null && group != null && group.canBlock(blocker, game)) {
      group.addBlocker(blockerId, playerId, game);
    }
  }
View Full Code Here


    super(effect);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    CombatGroup group = game.getCombat().findGroup(source.getSourceId());
    if (group != null) {
      Player defender = null;
      if (group.isDefenderIsPlaneswalker()) {
        Permanent planeswalker = game.getPermanent(group.getDefenderId());
        if (planeswalker != null) {
          defender = game.getPlayer(planeswalker.getControllerId());
        }
      }
      else {
        defender = game.getPlayer(group.getDefenderId());
      }
      if (defender != null) {
        for (Permanent creature: game.getBattlefield().getAllActivePermanents(FilterCreaturePermanent.getDefault(), defender.getId())) {
          if (group.canBlock(creature, game)) {
            group.addBlocker(creature.getId(), creature.getControllerId(), game);
          }
        }
        return true;
      }
    }
View Full Code Here

        if (input.isAttacking()) {
            if ((game.getPhase().getStep().getType() == PhaseStep.DECLARE_BLOCKERS
                    && game.getStep().getStepPart() == Step.StepPart.PRIORITY)
                    || game.getPhase().getStep().getType() == PhaseStep.FIRST_COMBAT_DAMAGE
                    || game.getPhase().getStep().getType() == PhaseStep.COMBAT_DAMAGE) {
                CombatGroup combatGroup = game.getCombat().findGroup(input.getId());
                if (combatGroup != null) {
                    return combatGroup.getBlockers().isEmpty();
                }
            }
        }
        return false;
    }
View Full Code Here

        List<Permanent> blockers = getAvailableBlockers(game);
        for (Permanent blocker: blockers) {
            int check = rnd.nextInt(numGroups + 1);
            if (check < numGroups) {
                CombatGroup group = game.getCombat().getGroups().get(check);
                if (group.getAttackers().size() > 0)
                    this.declareBlocker(this.getId(), blocker.getId(), group.getAttackers().get(0), game);
            }
        }
        actionCount++;
    }
View Full Code Here

    }

    @Override
    public void declareBlocker(UUID defenderId, UUID blockerId, UUID attackerId, Game game) {
        Permanent blocker = game.getPermanent(blockerId);
        CombatGroup group = game.getCombat().findGroup(attackerId);
        if (blocker != null && group != null && group.canBlock(blocker, game)) {
            group.addBlocker(blockerId, playerId, game);
            game.getCombat().addBlockingGroup(blockerId, attackerId, playerId, game);
        } else {
            if (this.isHuman()) {
                game.informPlayer(this, "You can't block this creature.");
            }
View Full Code Here

        List<Permanent> blockers = getAvailableBlockers(game);
        for (Permanent blocker: blockers) {
            int check = rnd.nextInt(numGroups + 1);
            if (check < numGroups) {
                CombatGroup group = game.getCombat().getGroups().get(check);
                if (group.getAttackers().size() > 0) {
                    this.declareBlocker(this.getId(), blocker.getId(), group.getAttackers().get(0), game);
                }
            }
        }
        actionCount++;
    }
View Full Code Here

        game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), false, null);
        waitForResponse(game);
        if (response.getBoolean() != null) {
            // do nothing
        } else if (response.getUUID() != null) {
            CombatGroup group = game.getCombat().findGroup(response.getUUID());
            if (group != null) {
                // check if already blocked, if not add
                if (!group.getBlockers().contains(blockerId)) {                   
                    declareBlocker(defenderId, blockerId, response.getUUID(), game);
                } else { // else remove from block
                    game.getCombat().removeBlockerGromGroup(blockerId, group, game);
                }
            }
View Full Code Here

                // Possible ruling (see Ætherplasm)
                // The token you put onto the battlefield is blocking the attacking creature,
                // even if the block couldn't legally be declared (for example, if that creature
                // enters the battlefield tapped, or it can't block, or the attacking creature
                // has protection from it)
                CombatGroup combatGroup = game.getState().getCombat().findGroup(attackingCreature.getId());
                if (combatGroup != null) {
                    combatGroup.addBlocker(catToken.getId(), source.getControllerId(), game);
                    game.getCombat().addBlockingGroup(catToken.getId(),attackingCreature.getId() , source.getControllerId(), game);   
                }
            }
            return true;
        }   
View Full Code Here

TOP

Related Classes of mage.game.combat.CombatGroup

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.