private static TSeeding toSeeding(String... playerNames) {
   List<TPlayer> playersBestFirst = Lists.newArrayList();
   for (String playerName : playerNames) {
     playersBestFirst.add(TPlayer.create(playerName));
   }
   return TSeeding.create(playersBestFirst);
 }
示例#2
0
 @SuppressWarnings("unchecked")
 public static StageSpec parseYaml(
     Object yamlStage, int stageNum, Map<String, Game> games, AtomicInteger playerLimitSoFar) {
   Map<String, Object> stageMap = (Map<String, Object>) yamlStage;
   YamlUtils.validateKeys(stageMap, "stage", ALLOWED_KEYS);
   String formatName = (String) stageMap.get("format");
   List<RoundSpec> rounds = Lists.newArrayList();
   int roundNum = 0;
   for (Object yamlRound : (List<Object>) stageMap.get("rounds")) {
     rounds.add(RoundSpec.parseYaml(yamlRound, roundNum, games));
     roundNum++;
   }
   int playerLimit = playerLimitSoFar.get();
   if (stageMap.containsKey("playerLimit")) {
     playerLimit = Math.min(playerLimit, (int) stageMap.get("playerLimit"));
     playerLimitSoFar.set(playerLimit);
   }
   if (stageMap.containsKey("playerCutoff")) {
     // This affects the player limit for the next round, not the current round.
     playerLimitSoFar.set((int) stageMap.get("playerCutoff"));
   }
   Set<TPlayer> excludedPlayers = Sets.newHashSet();
   if (stageMap.containsKey("excludedPlayers")) {
     for (Object playerName : (List<Object>) stageMap.get("excludedPlayers")) {
       // Note that playerName could actually be e.g. an Integer instead
       // of a String, so we do need toString() instead of a cast.
       excludedPlayers.add(TPlayer.create(playerName.toString()));
     }
   }
   return new StageSpec(
       stageNum,
       StageFormat.parse(formatName),
       ImmutableList.copyOf(rounds),
       playerLimit,
       ImmutableSet.copyOf(excludedPlayers));
 }