@RequestMapping("/hf/{id}")
  public Template hf(VelocityContext context, int id) {
    HistoricalFigure hf = World.getHistoricalFigure(id);
    HistoricalFigure.setContext(hf);

    context.put("hf", hf);
    context.put("family", new Family(hf, false));

    if (hf.isWerebeast()) {
      context.put("curse", new Family(hf, true));
    }

    context.put(
        "events",
        World.getHistoricalEvents()
            .stream()
            .filter(e -> EventHelper.related(hf, e))
            .collect(Collectors.toList()));

    return Templates.get("hf.vm");
  }
  @RequestMapping("/hfs")
  public Template hfs(VelocityContext context) {
    boolean leader = context.containsKey("leader");
    boolean deity = context.containsKey("deity");
    boolean force = context.containsKey("force");
    boolean vampire = context.containsKey("vampire");
    boolean werebeast = context.containsKey("werebeast");
    boolean necromancer = context.containsKey("necromancer");
    boolean alive = context.containsKey("alive");
    boolean ghost = context.containsKey("ghost");
    boolean adventurer = context.containsKey("adventurer");

    Collection<HistoricalFigure> historicalFigures = World.getHistoricalFigures();
    context.put(
        "races",
        new TreeSet<String>(
            historicalFigures
                .stream()
                .map(hf -> hf.getRace() != null ? hf.getRace() : "UNKNOWN")
                .collect(Collectors.toList())));

    String race = (String) context.get("race");

    if (leader
        || deity
        || force
        || vampire
        || werebeast
        || necromancer
        || alive
        || ghost
        || adventurer
        || (race != null && !race.equals(""))) {
      context.put(
          "elements",
          historicalFigures
              .stream()
              .filter(
                  hf -> {
                    if (leader && !hf.isLeader()) return false;
                    if (deity && !hf.isDeity()) return false;
                    if (force && !hf.isForce()) return false;
                    if (vampire && !hf.isVampire()) return false;
                    if (werebeast && !hf.isWerebeast()) return false;
                    if (necromancer && !hf.isNecromancer()) return false;
                    if (alive && hf.getDeathYear() != -1) return false;
                    if (ghost && !hf.isGhost()) return false;
                    if (adventurer && !hf.isAdventurer()) return false;

                    if (race != null && !race.equals("")) {
                      if (hf.getRace() == null) {
                        if (!race.equals("UNKNOWN")) {
                          return false;
                        }
                      } else if (!hf.getRace().equals(race)) {
                        return false;
                      }
                    }
                    return true;
                  })
              .collect(Collectors.toList()));
    } else {
      context.put("elements", historicalFigures);
    }

    return Templates.get("hfs.vm");
  }