protected HashMap<String, Role> initializeRoles(Properties props) { String rolesProperty = props.getProperty(ROLES_PROPNAME); if (rolesProperty == null || rolesProperty.length() == 0) { return initializeRoles(new String[] {"trader", "manipulator", "judge"}, props); } else { return initializeRoles(rolesProperty.split(COMMA_SPLIT_RE), props); } }
///// INITIALIZATION ///////////////////////////////////////////////////////// static boolean describesJudgingSession(Properties props) { String rolesProperty = props.getProperty(ROLES_PROPNAME); if (rolesProperty != null && rolesProperty.indexOf(JUDGE_PROPERTY_WORD) > -1) { return true; } else { return nonTradersPresent(props); } }
private static boolean requiresJudges(String playerName, Properties props) { String roleName = props.getProperty(PropertyHelper.dottedWords(playerName, ROLE_PROPERTY_WORD)); if (roleName == null) { return false; } else { roleName = roleName.trim(); } return roleName.equals(JUDGE_PROPERTY_WORD) || roleName.equals(MANIPULATOR_PROPERTY_WORD); }
public static boolean nonTradersPresent(Properties props) { String playersProperty = props.getProperty(PLAYERS_PROPNAME); String[] playerNames = playersProperty.split(COMMA_SPLIT_RE); for (int i = 0; i < playerNames.length; i++) { if (requiresJudges(playerNames[i], props)) { return true; } } return false; }
protected Quantity bookFundingRequired(Properties props) { String playersProperty = props.getProperty(PLAYERS_PROPNAME); Quantity playerCount = new Quantity(playersProperty.split(COMMA_SPLIT_RE).length); Quantity maxTickets = initialTraderTickets().min(initialManipulatorTickets()); return maxTickets.times(playerCount.times(new Quantity(rounds()))); }