예제 #1
0
 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);
   }
 }
예제 #2
0
 ///// 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);
   }
 }
예제 #3
0
 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);
 }
예제 #4
0
 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;
 }
예제 #5
0
 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())));
 }