示例#1
0
 public DVector parseLootPolicyFor(MOB mob) {
   if (mob == null) return new DVector(3);
   Vector lootPolicy =
       (!mob.isMonster())
           ? new Vector()
           : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true);
   DVector policies = new DVector(3);
   for (int p = 0; p < lootPolicy.size(); p++) {
     String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim();
     if (s.length() == 0) continue;
     Vector compiledMask = null;
     int maskDex = s.indexOf("MASK=");
     if (maskDex >= 0) {
       s = s.substring(0, maskDex).trim();
       compiledMask =
           CMLib.masking()
               .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim());
     } else compiledMask = new Vector();
     Vector parsed = CMParms.parse(s);
     int pct = 100;
     for (int x = 0; x < parsed.size(); x++)
       if (CMath.isInteger((String) parsed.elementAt(x)))
         pct = CMath.s_int((String) parsed.elementAt(x));
       else if (CMath.isPct((String) parsed.elementAt(x)))
         pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0);
     int flags = 0;
     if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN;
     else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN;
     else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN;
     policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask);
   }
   return policies;
 }