Example #1
0
  private static final int getTurnsUsed(GenericRequest request) {
    if (!(request instanceof RelayRequest)) {
      return request.getAdventuresUsed();
    }

    String urlString = request.getURLString();

    if (urlString.startsWith("adventure.php")) {
      // Assume unknown adventure locations take 1 turn each
      // This is likely not true under the Sea, for example,
      // but it's as good a guess as any we can make.

      return 1;
    }

    if (urlString.startsWith("inv_use.php") || urlString.startsWith("inv_eat.php")) {
      return UseItemRequest.getAdventuresUsed(urlString);
    }

    if (urlString.startsWith("runskillz.php")) {
      return UseSkillRequest.getAdventuresUsed(urlString);
    }

    if (urlString.startsWith("craft.php") || urlString.startsWith("guild.php")) {
      return CreateItemRequest.getAdventuresUsed(request);
    }

    if (urlString.startsWith("place.php?whichplace=chateau")
        && urlString.contains("action=chateau_painting")) {
      return Preferences.getBoolean("_chateauMonsterFought") ? 0 : 1;
    }

    if (urlString.startsWith("crimbo09.php")) {
      return Crimbo09Request.getTurnsUsed(request);
    }

    return 0;
  }