示例#1
0
  @Override
  public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    preventDamageAction(event, source, game);

    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
      boolean removeCounter = true;
      // check if in the same combat damage step already a counter was removed
      if (game.getTurn().getPhase().getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)) {
        if (game.getTurnNum() == turn && game.getTurn().getStep().equals(combatPhaseStep)) {
          removeCounter = false;
        } else {
          turn = game.getTurnNum();
          combatPhaseStep = game.getTurn().getStep();
        }
      }

      if (removeCounter && permanent.getCounters().getCount(CounterType.P1P1) > 0) {
        StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
        permanent.removeCounters(CounterType.P1P1.createInstance(), game);
        sb.append("Removed a +1/+1 counter ");
        game.informPlayers(sb.toString());
      }
    }

    return false;
  }
示例#2
0
 @Override
 public boolean replaceEvent(GameEvent event, Ability source, Game game) {
   boolean retValue = false;
   GameEvent preventEvent =
       new GameEvent(
           GameEvent.EventType.PREVENT_DAMAGE,
           source.getFirstTarget(),
           source.getId(),
           source.getControllerId(),
           event.getAmount(),
           false);
   int damage = event.getAmount();
   if (!game.replaceEvent(preventEvent)) {
     event.setAmount(0);
     game.fireEvent(
         GameEvent.getEvent(
             GameEvent.EventType.PREVENTED_DAMAGE,
             source.getFirstTarget(),
             source.getId(),
             source.getControllerId(),
             damage));
     retValue = true;
   }
   Permanent permanent = game.getPermanent(source.getSourceId());
   if (permanent != null) {
     permanent.removeCounters(CounterType.P1P1.createInstance(damage), game);
   }
   return retValue;
 }
 @Override
 public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
   Permanent permanent = game.getPermanent(sourceId);
   if (permanent != null && permanent.getCounters().getCount(name) >= amount) {
     permanent.removeCounters(name, amount, game);
     this.paid = true;
   }
   return paid;
 }
示例#4
0
 @Override
 public boolean replaceEvent(GameEvent event, Ability source, Game game) {
   int damage = event.getAmount();
   preventDamageAction(event, source, game);
   Permanent permanent = game.getPermanent(source.getSourceId());
   if (permanent != null) {
     permanent.removeCounters(CounterType.P1P1.createInstance(damage), game);
   }
   new CreateTokenEffect(new SpiritToken(), damage).apply(game, source);
   return true;
 }
示例#5
0
文件: Hankyu.java 项目: Nick456/mage
 @Override
 public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
   Permanent equipment = game.getPermanent(this.effectGivingEquipmentId);
   if (equipment != null) {
     this.removedCounters = equipment.getCounters().getCount(CounterType.AIM);
     if (this.removedCounters > 0) {
       equipment.removeCounters("aim", this.removedCounters, game);
     }
   }
   this.paid = true;
   return true;
 }
示例#6
0
  @Override
  public boolean apply(Game game, Ability source) {
    TargetPermanent target = (TargetPermanent) source.getTargets().get(0);

    Permanent permanent = game.getPermanent(target.getFirstTarget());

    if (permanent != null) {
      for (Counter counter : permanent.getCounters().values()) {
        permanent.removeCounters(counter, game);
      }

      return true;
    }

    return false;
  }
示例#7
0
  @Override
  public boolean apply(Game game, Ability source) {
    Permanent creatureToMoveCountersFrom =
        game.getPermanent(source.getTargets().get(0).getFirstTarget());
    Permanent creatureToMoveCountersTo =
        game.getPermanent(source.getTargets().get(1).getFirstTarget());

    if (creatureToMoveCountersFrom != null && creatureToMoveCountersTo != null) {
      Permanent copyCreature = creatureToMoveCountersFrom.copy();
      for (Counter counter : copyCreature.getCounters(game).values()) {
        creatureToMoveCountersFrom.removeCounters(counter, game);
        creatureToMoveCountersTo.addCounters(counter, game);
      }
      return true;
    }
    return false;
  }
示例#8
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     for (Permanent permanent :
         game.getBattlefield()
             .getActivePermanents(
                 new FilterPermanent(), controller.getId(), source.getSourceId(), game)) {
       if (permanent instanceof PermanentToken) {
         controller.moveCardToExileWithInfo(
             permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
       } else if (!permanent.getCounters(game).isEmpty()) {
         Counters counters = permanent.getCounters(game).copy();
         for (Counter counter : counters.values()) {
           permanent.removeCounters(counter, game);
         }
       }
     }
     return true;
   }
   return false;
 }
 @Override
 public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
   Permanent permanent = game.getPermanent(sourceId);
   Player player = game.getPlayer(permanent.getControllerId());
   this.amountPaid =
       player.getAmount(
           minimalCountersToPay,
           permanent.getCounters().getCount(name),
           "Choose X counters to remove",
           game);
   if (this.amountPaid >= minimalCountersToPay) {
     permanent.removeCounters(name, amountPaid, game);
     this.paid = true;
   }
   game.informPlayers(
       player.getName()
           + " removes "
           + this.amountPaid
           + " "
           + name
           + " counter from "
           + permanent.getName());
   return paid;
 }