示例#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
 public void addActivation(Game game) {
   if (game.getTurnNum() != turnNum) {
     activationCounter = 1;
     turnNum = game.getTurnNum();
   } else {
     activationCounter++;
   }
   game.getState().setValue(key, activationCounter);
   game.getState().setValue(key + "T", turnNum);
 }
示例#3
0
 @Override
 public boolean apply(Game game, Ability source) {
   DelayedTriggeredAbility delayedAbility =
       new JaceArchitectOfThoughtDelayedTriggeredAbility(game.getTurnNum());
   game.addDelayedTriggeredAbility(delayedAbility, source);
   return true;
 }
示例#4
0
 public static ActivationInfo getInstance(Game game, UUID sourceId, int zoneChangeCounter) {
   String key = "ActivationInfo" + sourceId.toString() + zoneChangeCounter;
   Integer activations = (Integer) game.getState().getValue(key);
   ActivationInfo activationInfo;
   if (activations != null) {
     Integer turnNum = (Integer) game.getState().getValue(key + "T");
     activationInfo = new ActivationInfo(game, turnNum, activations);
   } else {
     activationInfo = new ActivationInfo(game, game.getTurnNum(), 0);
   }
   activationInfo.setKey(key);
   return activationInfo;
 }
示例#5
0
 private boolean priorityPlay(Game game) {
   if (lastLoggedTurn != game.getTurnNum()) {
     lastLoggedTurn = game.getTurnNum();
     logger.info(
         "======================= Turn: "
             + game.getTurnNum()
             + " ["
             + game.getPlayer(game.getActivePlayerId()).getName()
             + "] =========================================");
   }
   logState(game);
   logger.debug(
       "Priority -- Step: "
           + (game.getTurn().getStepType() + "                       ").substring(0, 25)
           + " ActivePlayer-"
           + game.getPlayer(game.getActivePlayerId()).getName()
           + " PriorityPlayer-"
           + name);
   game.getState().setPriorityPlayerId(playerId);
   game.firePriorityEvent(playerId);
   switch (game.getTurn().getStepType()) {
     case UPKEEP:
     case DRAW:
       pass(game);
       return false;
     case PRECOMBAT_MAIN:
       if (game.getActivePlayerId().equals(playerId)) {
         printOutState(game);
         if (actions.size() == 0) {
           logger.info(
               "Sim Calculate pre combat actions ----------------------------------------------------- ");
           calculatePreCombatActions(game);
         }
         act(game);
         return true;
       } else {
         pass(game);
       }
       return false;
     case BEGIN_COMBAT:
       pass(game);
       return false;
     case DECLARE_ATTACKERS:
       if (!game.getActivePlayerId().equals(playerId)) {
         printOutState(game);
         if (actions.size() == 0) {
           logger.info(
               "Sim Calculate declare attackers actions ----------------------------------------------------- ");
           calculatePreCombatActions(game);
         }
         act(game);
         return true;
       } else {
         pass(game);
       }
       return false;
     case DECLARE_BLOCKERS:
     case FIRST_COMBAT_DAMAGE:
     case COMBAT_DAMAGE:
     case END_COMBAT:
       pass(game);
       return false;
     case POSTCOMBAT_MAIN:
       //                if (game.getActivePlayerId().equals(playerId)) {
       printOutState(game);
       if (actions.size() == 0) {
         calculatePostCombatActions(game);
       }
       act(game);
       return true;
       //                }
       //                else {
       //                    pass(game);
       //                }
       //                return false;
     case END_TURN:
     case CLEANUP:
       actionCache.clear();
       pass(game);
       return false;
   }
   return false;
 }
示例#6
0
 @Override
 public boolean isInactive(Game game) {
   return game.getActivePlayerId().equals(getControllerId()) && game.getTurnNum() != startingTurn;
 }