Ejemplo n.º 1
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();
  }
Ejemplo n.º 2
0
  private void updateScope(VariableDescriptor vd) {
    if (!(vd.getScope() instanceof GameModelScope)) {
      EntityManager em = this.getEntityManager();

      Collection<VariableInstance> values = vd.getScope().getVariableInstancesByKeyId().values();
      for (VariableInstance vi : values) {
        em.remove(vi);
      }
      GameModelScope scope = new GameModelScope();
      scope.setBroadcastScope("GameScope");
      scope.setVariableDescscriptor(vd);
      vd.setScope(scope);
      em.persist(vd);
      vd.propagateDefaultInstance(null, true);
    }
  }