Ejemplo n.º 1
0
 @Override
 public void setParms(String newParm) {
   super.setParms(newParm);
   rates.clear();
   cut = 0.05;
   spaceMaxCut = 0.0;
   spaceMaxDistance = SpaceObject.Distance.GalaxyRadius.dm;
   newParm = newParm.toUpperCase();
   int x = newParm.indexOf('=');
   while (x > 0) {
     int lastSp = newParm.lastIndexOf(' ', x);
     if (lastSp < 0) lastSp = 0;
     if ((lastSp >= 0) && (lastSp < x - 1) && (Character.isLetter(newParm.charAt(x - 1)))) {
       String parm = newParm.substring(lastSp, x).trim().toUpperCase();
       while ((x < newParm.length()) && (newParm.charAt(x) != '=')) x++;
       if (x < newParm.length()) {
         while ((x < newParm.length())
             && (!Character.isDigit(newParm.charAt(x)))
             && (newParm.charAt(x) != '.')) x++;
         if (x < newParm.length()) {
           newParm = newParm.substring(x);
           x = 0;
           while ((x < newParm.length())
               && ((Character.isDigit(newParm.charAt(x))) || (newParm.charAt(x) == '.'))) x++;
           double val = CMath.s_double(newParm.substring(0, x));
           if (newParm.substring(0, x).indexOf('.') < 0)
             val = CMath.s_long(newParm.substring(0, x));
           if (x < newParm.length()) newParm = newParm.substring(x + 1);
           else newParm = "";
           if (parm.equalsIgnoreCase("default")) parm = "";
           if (parm.equalsIgnoreCase("spacemaxcut")) spaceMaxCut = val / 100.0;
           else if (parm.equalsIgnoreCase("spacemaxdistance"))
             spaceMaxDistance =
                 Math.round(CMath.mul(SpaceObject.Distance.GalaxyRadius.dm, val / 100.0));
           else if (parm.equalsIgnoreCase("cut")) cut = val / 100.0;
           else rates.put(parm, Double.valueOf(val / 100.0));
         }
       }
     }
     x = newParm.indexOf('=');
   }
 }
Ejemplo n.º 2
0
 @Override
 public Tattoo parse(final String tattooCode) {
   if ((tattooCode == null) || (tattooCode.length() == 0)) return this;
   tattooName = tattooCode;
   if (Character.isDigit(tattooName.charAt(0))) {
     final int x = tattooName.indexOf(' ');
     if ((x > 0) && (CMath.isNumber(tattooName.substring(0, x).trim()))) {
       tickDown = CMath.s_int(tattooName.substring(0, x));
       tattooName = tattooName.substring(x + 1).trim();
     }
   }
   return this;
 }
Ejemplo n.º 3
0
  @Override
  public int getPrice() {
    if (text().length() == 0) return 100000;
    final String s = text();
    int index = s.length();
    while ((--index) >= 0) {
      if ((!Character.isDigit(s.charAt(index))) && (!Character.isWhitespace(s.charAt(index))))
        break;
    }
    int price = CMath.s_int(s.substring(index + 1).trim());

    if (price <= 0) price = 100000;
    return price;
  }
Ejemplo n.º 4
0
 public boolean didHappen() {
   if (chanceToHappen < 0) {
     final String parmString = getParmString(text());
     int x = parmString.indexOf('%');
     if (x < 0) {
       chanceToHappen = 100;
       return true;
     }
     int mul = 1;
     int tot = 0;
     while ((--x) >= 0) {
       if (Character.isDigit(parmString.charAt(x)))
         tot += CMath.s_int("" + parmString.charAt(x)) * mul;
       else x = -1;
       mul = mul * 10;
     }
     chanceToHappen = (short) tot;
   }
   if (CMLib.dice().rollPercentage() <= chanceToHappen) return true;
   return false;
 }