Exemple #1
0
  private String rtsUpdateScope(GameModel gameModel) {
    List<VariableDescriptor> variableDescriptors = gameModel.getVariableDescriptors();
    StringBuilder sb = new StringBuilder();
    sb.append("[");

    for (VariableDescriptor vd : variableDescriptors) {

      if ("question".equals(vd.getLabel().toLowerCase())) {
        this.updateScope(vd);
      } else if ("toolbar".equals(vd.getLabel().toLowerCase())
          || "moves".equals(vd.getLabel().toLowerCase())
          || "dialogues".equals(vd.getLabel().toLowerCase())) {
        if (vd instanceof ListDescriptor) {
          ListDescriptor list = (ListDescriptor) vd;
          for (VariableDescriptor child : list.getItems()) {
            if (child instanceof StringDescriptor) {
              this.updateScope(child);
            }
          }
        }
      }
    }
    sb.append("]");

    return sb.toString();
  }
Exemple #2
0
  private String rtsNewScope(GameModel gameModel) {
    List<VariableDescriptor> variableDescriptors = gameModel.getVariableDescriptors();
    StringBuilder sb = new StringBuilder();
    sb.append("[");

    for (Iterator<VariableDescriptor> it = variableDescriptors.iterator(); it.hasNext(); ) {
      VariableDescriptor vd = it.next();
      if ("question".equals(vd.getLabel().toLowerCase())) {
        if (!(vd.getScope() instanceof GameModelScope)) {
          sb.append(this.newScope(gameModel, vd));
        }
      } else if ("toolbar".equals(vd.getLabel().toLowerCase())
          || "moves".equals(vd.getLabel().toLowerCase())
          || "dialogues".equals(vd.getLabel().toLowerCase())) {
        if (vd instanceof ListDescriptor) {
          ListDescriptor list = (ListDescriptor) vd;
          for (VariableDescriptor child : list.getItems()) {
            if (child instanceof StringDescriptor) {
              sb.append(this.newScope(gameModel, child));
            }
          }
        }
      }
    }
    sb.append("]");

    return sb.toString();
  }
Exemple #3
0
 /**
  * Retrieve
  *
  * @param gameModelId
  * @return static "Finished" string...
  */
 @GET
 @Path("Encode/{gameModelId : ([1-9][0-9]*)}")
 public String encode(@PathParam("gameModelId") Long gameModelId) {
   List<VariableDescriptor> findAll = descriptorFacade.findByGameModelId(gameModelId);
   for (VariableDescriptor vd : findAll) {
     List<String> findDistinctNames = descriptorFacade.findDistinctNames(vd.getGameModel());
     List<String> findDistinctLabels = descriptorFacade.findDistinctLabels(vd.getGameModel());
     findDistinctNames.remove(vd.getName());
     findDistinctLabels.remove(vd.getLabel());
     Helper.setUniqueName(vd, findDistinctNames);
     Helper.setUniqueLabel(vd, findDistinctLabels);
     descriptorFacade.flush();
   }
   return "Finished";
 }