Esempio n. 1
0
 protected void addAbilityNode(SimulationNode parent, Ability ability, Game game) {
   Game sim = game.copy();
   sim.getStack().push(new StackAbility(ability, playerId));
   ability.activate(sim, false);
   sim.applyEffects();
   SimulationNode newNode = new SimulationNode(parent, sim, playerId);
   logger.debug(
       indent(newNode.getDepth())
           + "simulating -- node #:"
           + SimulationNode.getCount()
           + " triggered ability option");
   for (Target target : ability.getTargets()) {
     for (UUID targetId : target.getTargets()) {
       newNode.getTargets().add(targetId);
     }
   }
   for (Choice choice : ability.getChoices()) {
     newNode.getChoices().add(choice.getChoice());
   }
   parent.children.add(newNode);
 }
Esempio n. 2
0
 @Override
 public boolean triggerAbility(TriggeredAbility source, Game game) {
   Ability ability = source.copy();
   List<Ability> options = getPlayableOptions(ability, game);
   if (options.isEmpty()) {
     if (logger.isDebugEnabled()) logger.debug("simulating -- triggered ability:" + ability);
     game.getStack().push(new StackAbility(ability, playerId));
     ability.activate(game, false);
     game.applyEffects();
     game.getPlayers().resetPassed();
   } else {
     SimulationNode parent = (SimulationNode) game.getCustomData();
     if (parent.getDepth() == maxDepth) return true;
     logger.debug(
         indent(parent.getDepth())
             + "simulating -- triggered ability - adding children:"
             + options.size());
     for (Ability option : options) {
       addAbilityNode(parent, option, game);
     }
   }
   return true;
 }