예제 #1
0
 public void setStat(String code, String val) {
   int num = 0;
   int numDex = code.length();
   while ((numDex > 0) && (Character.isDigit(code.charAt(numDex - 1)))) numDex--;
   if (numDex < code.length()) {
     num = CMath.s_int(code.substring(numDex));
     code = code.substring(0, numDex);
   }
   final GOVT_STAT_CODES stat = getStatIndex(code);
   if (stat == null) {
     return;
   }
   switch (stat) {
     case NAME:
       name = val;
       break;
     case AUTOROLE:
       {
         ClanPosition P = getPosition(val);
         if (P != null) autoRole = P.getRoleID();
         break;
       }
     case ACCEPTPOS:
       {
         ClanPosition P = getPosition(val);
         if (P != null) acceptPos = P.getRoleID();
         break;
       }
     case SHORTDESC:
       shortDesc = val;
       break;
     case LONGDESC:
       longDesc = val;
       break;
     case XPLEVELFORMULA:
       setXpCalculationFormulaStr(val);
       break;
     case REQUIREDMASK:
       requiredMaskStr = val;
       break;
     case ISPUBLIC:
       isPublic = CMath.s_bool(val);
       break;
     case ISFAMILYONLY:
       isFamilyOnly = CMath.s_bool(val);
       break;
     case OVERRIDEMINMEMBERS:
       {
         if (val.length() == 0) overrideMinMembers = null;
         else overrideMinMembers = Integer.valueOf(CMath.s_int(val));
         break;
       }
     case CONQUESTENABLED:
       conquestEnabled = CMath.s_bool(val);
       break;
     case CONQUESTITEMLOYALTY:
       conquestItemLoyalty = CMath.s_bool(val);
       break;
     case CONQUESTDEITYBASIS:
       conquestByWorship = CMath.s_bool(val);
       break;
     case MAXVOTEDAYS:
       maxVoteDays = CMath.s_int(val);
       break;
     case VOTEQUORUMPCT:
       voteQuorumPct = CMath.s_int(val);
       break;
     case AUTOPROMOTEBY:
       {
         Clan.AutoPromoteFlag flag =
             (Clan.AutoPromoteFlag) CMath.s_valueOf(Clan.AutoPromoteFlag.values(), val);
         if (flag != null) autoPromoteBy = flag;
         break;
       }
     case VOTEFUNCS:
       {
         final Vector<String> funcs = CMParms.parseCommas(val.toUpperCase().trim(), true);
         for (ClanPosition pos : positions) {
           for (int a = 0; a < Function.values().length; a++)
             if (pos.getFunctionChart()[a] == Authority.MUST_VOTE_ON)
               pos.getFunctionChart()[a] = Authority.CAN_NOT_DO;
           for (final String funcName : funcs) {
             Authority auth = (Authority) CMath.s_valueOf(Function.values(), funcName);
             if (auth != null) pos.getFunctionChart()[auth.ordinal()] = Authority.MUST_VOTE_ON;
           }
         }
         break;
       }
     case NUMRABLE:
       clanAbilityMap = null;
       if (CMath.s_int(val) == 0) {
         clanAbilityNames = null;
         clanAbilityProficiencies = null;
         clanAbilityQuals = null;
         clanAbilityLevels = null;
       } else {
         clanAbilityNames = new String[CMath.s_int(val)];
         clanAbilityProficiencies = new int[CMath.s_int(val)];
         clanAbilityQuals = new boolean[CMath.s_int(val)];
         clanAbilityLevels = new int[CMath.s_int(val)];
       }
       break;
     case GETRABLE:
       {
         if (clanAbilityNames == null) clanAbilityNames = new String[num + 1];
         clanAbilityNames[num] = val;
         break;
       }
     case GETRABLEPROF:
       {
         if (clanAbilityProficiencies == null) clanAbilityProficiencies = new int[num + 1];
         clanAbilityProficiencies[num] = CMath.s_parseIntExpression(val);
         break;
       }
     case GETRABLEQUAL:
       {
         if (clanAbilityQuals == null) clanAbilityQuals = new boolean[num + 1];
         clanAbilityQuals[num] = CMath.s_bool(val);
         break;
       }
     case GETRABLELVL:
       {
         if (clanAbilityLevels == null) clanAbilityLevels = new int[num + 1];
         clanAbilityLevels[num] = CMath.s_parseIntExpression(val);
         break;
       }
     case NUMREFF:
       clanEffectMap = null;
       if (CMath.s_int(val) == 0) {
         clanEffectNames = null;
         clanEffectParms = null;
         clanEffectLevels = null;
       } else {
         clanEffectNames = new String[CMath.s_int(val)];
         clanEffectParms = new String[CMath.s_int(val)];
         clanEffectLevels = new int[CMath.s_int(val)];
       }
       break;
     case GETREFF:
       {
         if (clanEffectNames == null) clanEffectNames = new String[num + 1];
         clanEffectNames[num] = val;
         break;
       }
     case GETREFFPARM:
       {
         if (clanEffectParms == null) clanEffectParms = new String[num + 1];
         clanEffectParms[num] = val;
         break;
       }
     case GETREFFLVL:
       {
         if (clanEffectLevels == null) clanEffectLevels = new int[num + 1];
         clanEffectLevels[num] = CMath.s_int(val);
         break;
       }
     default:
       Log.errOut("Clan", "setStat:Unhandled:" + stat.toString());
       break;
   }
 }
예제 #2
0
 public String getStat(String code) {
   int num = 0;
   int numDex = code.length();
   while ((numDex > 0) && (Character.isDigit(code.charAt(numDex - 1)))) numDex--;
   if (numDex < code.length()) {
     num = CMath.s_int(code.substring(numDex));
     code = code.substring(0, numDex);
   }
   final GOVT_STAT_CODES stat = getStatIndex(code);
   if (stat == null) {
     return "";
   }
   switch (stat) {
     case NAME:
       return name;
     case AUTOROLE:
       return (autoRole < 0 || autoRole > positions.length) ? "" : positions[autoRole].getID();
     case ACCEPTPOS:
       return (acceptPos < 0 || acceptPos > positions.length) ? "" : positions[acceptPos].getID();
     case SHORTDESC:
       return shortDesc;
     case LONGDESC:
       return longDesc;
     case XPLEVELFORMULA:
       return xpCalculationFormulaStr == null ? "" : xpCalculationFormulaStr;
     case REQUIREDMASK:
       return requiredMaskStr;
     case ISPUBLIC:
       return Boolean.toString(isPublic);
     case ISFAMILYONLY:
       return Boolean.toString(isFamilyOnly);
     case OVERRIDEMINMEMBERS:
       return overrideMinMembers == null ? "" : overrideMinMembers.toString();
     case CONQUESTENABLED:
       return Boolean.toString(conquestEnabled);
     case CONQUESTITEMLOYALTY:
       return Boolean.toString(conquestItemLoyalty);
     case CONQUESTDEITYBASIS:
       return Boolean.toString(conquestByWorship);
     case MAXVOTEDAYS:
       return Integer.toString(maxVoteDays);
     case VOTEQUORUMPCT:
       return Integer.toString(voteQuorumPct);
     case AUTOPROMOTEBY:
       return autoPromoteBy.toString();
     case VOTEFUNCS:
       {
         final StringBuilder str = new StringBuilder("");
         for (ClanPosition pos : positions) {
           for (int a = 0; a < Function.values().length; a++)
             if (pos.getFunctionChart()[a] == Authority.MUST_VOTE_ON) {
               if (str.length() > 0) str.append(",");
               str.append(Function.values()[a]);
             }
           break;
         }
         return str.toString();
       }
     case NUMRABLE:
       return (clanAbilityNames == null) ? "0" : ("" + clanAbilityNames.length);
     case GETRABLE:
       return (clanAbilityNames == null) ? "" : ("" + clanAbilityNames[num]);
     case GETRABLEPROF:
       return (clanAbilityProficiencies == null) ? "0" : ("" + clanAbilityProficiencies[num]);
     case GETRABLEQUAL:
       return (clanAbilityQuals == null) ? "false" : ("" + clanAbilityQuals[num]);
     case GETRABLELVL:
       return (clanAbilityLevels == null) ? "0" : ("" + clanAbilityLevels[num]);
     case NUMREFF:
       return (clanEffectNames == null) ? "0" : ("" + clanEffectNames.length);
     case GETREFF:
       return (clanEffectNames == null) ? "" : ("" + clanEffectNames[num]);
     case GETREFFPARM:
       return (clanEffectParms == null) ? "0" : ("" + clanEffectParms[num]);
     case GETREFFLVL:
       return (clanEffectLevels == null) ? "0" : ("" + clanEffectLevels[num]);
     default:
       Log.errOut("Clan", "getStat:Unhandled:" + stat.toString());
       break;
   }
   return "";
 }
예제 #3
0
 public int getSaveStatIndex() {
   return GOVT_STAT_CODES.values().length;
 }
예제 #4
0
 private GOVT_STAT_CODES getStatIndex(String code) {
   return (GOVT_STAT_CODES) CMath.s_valueOf(GOVT_STAT_CODES.values(), code);
 }
예제 #5
0
 public String[] getStatCodes() {
   return CMParms.toStringArray(GOVT_STAT_CODES.values());
 }