示例#1
0
  /**
   * Write the header of the easyNPC script to the target. This contains the name, the gender, the
   * race, the position and the direction NPC. Every single NPC requires to have this values.
   *
   * @param source the easyNPC that is the data source for this function
   * @param target the target writer that takes the data extracted from the source
   * @throws IOException thrown in case a writing operation failed
   */
  @SuppressWarnings("nls")
  private void writeHeader(final ParsedNpc source, final Writer target) throws IOException {
    target.write("name = \"");
    target.write(source.getNpcName());
    target.write("\"");
    target.write(NL);

    target.write("race = ");
    target.write(source.getNpcRace().name());
    target.write(NL);

    target.write("sex = ");
    target.write(source.getNpcSex().name());
    target.write(NL);

    target.write("position = ");
    target.write(Integer.toString(source.getNpcPos().getScX(), 0));
    target.write(", ");
    target.write(Integer.toString(source.getNpcPos().getScY(), 0));
    target.write(", ");
    target.write(Integer.toString(source.getNpcPos().getScZ(), 0));
    target.write(NL);

    target.write("direction = ");
    target.write(source.getNpcDir().name());
    target.write(NL);

    target.write("affiliation = \"");
    target.write(source.getAffiliation().name());
    target.write("\"");
    target.write(NL);

    target.write("job = \"");
    target.write(source.getJob());
    target.write("\"");
    target.write(NL);

    target.write(NL);
    final CharacterLanguage[] languages = source.getLanguages();
    for (final CharacterLanguage lang : languages) {
      target.write("language = ");
      target.write(lang.name());
      target.write(NL);
    }
    target.write("defaultLanguage = ");
    target.write(source.getDefaultLanguage().name());
    target.write(NL);
    target.write("autointroduce = ");
    target.write(source.getAutoIntroduce().getEasyNpc());
    target.write(NL);

    target.write(NL);
    final String[] authors = source.getAuthors();
    if (authors.length == 0) {
      target.write("author = \"not set\"");
      target.write(NL);
    } else {
      for (final String author : authors) {
        target.write("author = \"");
        target.write(author);
        target.write("\"");
        target.write(NL);
      }
    }
    target.write(NL);

    target.write("lookatDE = \"");
    target.write(source.getGermanLookat());
    target.write("\"");
    target.write(NL);

    target.write("lookatUS = \"");
    target.write(source.getEnglishLookat());
    target.write("\"");
    target.write(NL);

    target.write("useMsgDE = \"");
    target.write(source.getGermanUse());
    target.write("\"");
    target.write(NL);

    target.write("useMsgUS = \"");
    target.write(source.getEnglishUse());
    target.write("\"");
    target.write(NL);

    target.write("wrongLangDE = \"");
    target.write(source.getGermanWrongLang());
    target.write("\"");
    target.write(NL);

    target.write("wrongLangUS = \"");
    target.write(source.getEnglishWrongLang());
    target.write("\"");
    target.write(NL);
  }