private String evaluationNormalSnip(EffectMatchNode effectNode, Object[] args) { Effect effect = effectNode.getEffect(); StringBuilder sb = new StringBuilder(); // Prepare a hash map of snippet variables for use by formulas. HashMap<String, String> variables = new HashMap<String, String>(); // First add a variable for each of the effect's arguments. for (int i = 0; i < args.length; i++) { variables.put(effect.getParameter(i).getName(), (String) args[i]); } ISnippetNode[] snippetNodes; if (cachedSnippetNodes.containsKey(effect.getId())) { snippetNodes = cachedSnippetNodes.get(effect.getId()); } else { snippetNodes = SnippetParser.parseSnippetNodes(effect); cachedSnippetNodes.put(effect.getId(), snippetNodes); } // Evaluate the snippet by processing its nodes, and concatenate all the results. for (ISnippetNode snippetNode : snippetNodes) { sb.append(evaluateSnippetNode(snippetNode, variables, effectNode)); } return sb.toString().trim(); }
private void setControllerForEffect( ContinuousEffectsList<?> effects, UUID cardId, UUID controllerId) { for (Effect effect : effects) { HashSet<Ability> abilities = effects.getAbility(effect.getId()); for (Ability ability : abilities) { if (ability.getSourceId() != null) { if (ability.getSourceId().equals(cardId)) { ability.setControllerId(controllerId); } } else { if (!ability.getZone().equals(Zone.COMMAND)) { logger.fatal(new StringBuilder("No sourceId Ability: ").append(ability)); } } } } }