示例#1
0
 private String getPropertiesAsString() {
   StringBuilder sb = new StringBuilder();
   for (Key key : Key.values()) {
     sb.append(key.key).append("=").append(properties.getProperty(key.key)).append("\n");
   }
   return sb.toString();
 }
 public static Key fromString(String string) {
   for (Key key : Key.values()) {
     if (key.name().equals(string.toUpperCase())) {
       return key;
     }
   }
   return null;
 }
示例#3
0
 private void validate() {
   // make sure there are default values set for every parameter
   for (Key key : Key.values()) {
     if (defaultProperties.get(key.key) == null)
       throw new InvalidProfileConfigurationException("No default property set for key " + key);
   }
   // make sure the default resource allocation values add up to 100
   int totalDefaultAllocation =
       getDefaultAllocation_AttackHills()
           + getDefaultAllocation_DefendHills()
           + getDefaultAllocation_Explore()
           + getDefaultAllocation_GatherFood();
   if (totalDefaultAllocation != 100)
     throw new InvalidProfileConfigurationException(
         "Default resource allocations do not add up to 100");
   // values that need to be between 0 and 100
   checkValidPercentRange(Key.EXPLORE_FORCE_THRESHOLD_PERCENT, getExplore_ForceThresholdPercent());
   checkValidPercentRange(Key.ATTACK_HILLS_HALFTIME_BOOST, getAttackHills_HalfTimeBoost());
   checkValidPercentRange(Key.EXPLORE_DOMINANT_POSITION_BOOST, getExplore_DominantPositionBoost());
   checkValidPercentRange(
       Key.ATTACK_HILLS_DOMINANT_POSITION_BOOST, getAttackHills_DominantPositionBoost());
   // values that need to be between 0 and 1
   checkValidFraction(Key.EXPLORE_FORCE_GAIN, getExplore_ForceGain());
 }
示例#4
0
 static {
   EntityContext.registerPropertySet(FilterNode.class, PropertyView.All, Key.values());
 }
示例#5
0
 static {
   EntityContext.registerPropertySet(Template.class, PropertyView.All, Key.values());
 }
 /**
  * @param awtKey
  * @return
  */
 public static Key getKey(int awtKey) {
   for (Key k : Key.values()) if (k.awtKey == awtKey) return k;
   return Key_Undefined;
 }