protected Vector loadRecipes() { String filename = parametersFile(); Vector recipes = (Vector) Resources.getResource("PARSED: " + filename); if (recipes == null) { StringBuffer str = new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text(); recipes = loadList(str); if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!"); else { Vector pleaseAdd1 = new Vector(); Vector pleaseAdd2 = new Vector(); for (int r = 0; r < recipes.size(); r++) { Vector V = (Vector) recipes.elementAt(r); if (V.size() > 0) { Vector V1 = (Vector) V.clone(); Vector V2 = (Vector) V.clone(); String name = (String) V.elementAt(RCP_FINALNAME); V1.setElementAt("Hard " + name, RCP_FINALNAME); V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL); V2.setElementAt("Studded " + name, RCP_FINALNAME); V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL); pleaseAdd1.addElement(V1); pleaseAdd2.addElement(V2); } } for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i)); for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i)); } Resources.submitResource("PARSED: " + filename, recipes); } return recipes; }
@Override protected List<List<String>> loadRecipes() { final String filename = parametersFile(); @SuppressWarnings("unchecked") List<List<String>> recipes = (List<List<String>>) Resources.getResource("PARSED_RECIPE: " + filename); if (recipes == null) { final StringBuffer str = new CMFile(Resources.buildResourcePath("skills") + filename, null, CMFile.FLAG_LOGERRORS) .text(); recipes = loadList(str); if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!"); else { final List<List<String>> newRecipes = new Vector<List<String>>(); for (int r = 0; r < recipes.size(); r++) { final List<String> V = recipes.get(r); if (V.size() > 0) { final String name = V.get(RCP_FINALNAME); final int baseLevel = CMath.s_int(V.get(RCP_LEVEL)) + 2; for (final Stage s : Stage.values()) { final List<String> V1 = new XVector<String>(V); V1.set(RCP_FINALNAME, s.name() + " " + name); final int level = baseLevel + s.recipeLevel; V1.set(RCP_LEVEL, "" + level); for (int i = 0; i <= newRecipes.size(); i++) { if (newRecipes.size() == i) { newRecipes.add(V1); break; } else if (CMath.s_int(newRecipes.get(i).get(RCP_LEVEL)) > level) { newRecipes.add(i, V1); break; } } } } } recipes.clear(); recipes = newRecipes; } Resources.submitResource("PARSED_RECIPE: " + filename, recipes); } return recipes; }
@Override public void setRacialStat(final int abilityCode, final int racialMax) { if ((!CharStats.CODES.isBASE(abilityCode)) || (getStat(abilityCode) == VALUE_ALLSTATS_DEFAULT)) setPermanentStat(abilityCode, racialMax); else { final int baseMax = CMProps.getIntVar(CMProps.Int.BASEMAXSTAT); int currMax = getStat(CharStats.CODES.toMAXBASE(abilityCode)) + baseMax; if (currMax <= 0) currMax = 1; int curStat = getStat(abilityCode); if (curStat > currMax * 7) { final String errorMsg = "Detected mob with " + curStat + "/" + currMax + " " + CharStats.CODES.ABBR(abilityCode); @SuppressWarnings({"unchecked", "rawtypes"}) Set<String> errs = (Set) Resources.getResource("SYSTEM_DEFCHARSTATS_ERRORS"); if (errs == null) { errs = new TreeSet<String>(); Resources.submitResource("SYSTEM_DEFCHARSTATS_ERRORS", errs); } if (!errs.contains(errorMsg)) { errs.add(errorMsg); final StringBuilder str = new StringBuilder(errorMsg); // ByteArrayOutputStream stream=new ByteArrayOutputStream(); // new Exception().printStackTrace(new PrintStream(stream)); // str.append("\n\r"+new String(stream.toByteArray())); Log.errOut("DefCharStats", str.toString()); } curStat = currMax * 7; } final int pctOfMax = Math.round(((float) curStat / (float) currMax) * racialMax); final int stdMaxAdj = Math.round((((float) (currMax - VALUE_ALLSTATS_DEFAULT)) / (float) currMax) * racialMax); final int racialStat = pctOfMax + stdMaxAdj; setStat(abilityCode, ((racialStat < 1) && (racialMax > 0)) ? 1 : racialStat); setStat(CharStats.CODES.toMAXBASE(abilityCode), racialMax - baseMax); } }
public static boolean doRentalProperty(Area A, String ID, String owner, int rent) { if (!CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) return false; final int month = A.getTimeObj().getMonth(); final int day = A.getTimeObj().getDayOfMonth(); final int year = A.getTimeObj().getYear(); final Object O = Resources.getResource("RENTAL INFO/" + owner); List<PlayerData> pDataV = null; if (O instanceof List) pDataV = (List<PlayerData>) O; else pDataV = CMLib.database().DBReadData(owner, "RENTAL INFO"); if (pDataV == null) pDataV = new Vector(); DatabaseEngine.PlayerData pData = null; if (pDataV.size() == 0) { pData = new DatabaseEngine.PlayerData(); pData.who = owner; pData.section = "RENTAL INFO"; pData.key = "RENTAL INFO/" + owner; pData.xml = ID + "|~>|" + day + " " + month + " " + year + "|~;|"; CMLib.database().DBCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, pData.xml); pDataV.add(pData); Resources.submitResource("RENTAL INFO/" + owner, pDataV); return false; } else if (pDataV.get(0) != null) { pData = pDataV.get(0); String parse = pData.xml; int x = parse.indexOf("|~;|"); final StringBuffer reparse = new StringBuffer(""); boolean changesMade = false; boolean needsToPay = false; while (x >= 0) { String thisOne = parse.substring(0, x); if (thisOne.startsWith(ID + "|~>|")) { thisOne = thisOne.substring((ID + "|~>|").length()); final Vector dateV = CMParms.parse(thisOne); if (dateV.size() == 3) { int lastYear = CMath.s_int((String) dateV.lastElement()); int lastMonth = CMath.s_int((String) dateV.elementAt(1)); final int lastDay = CMath.s_int((String) dateV.firstElement()); while (!needsToPay) { if (lastYear < year) needsToPay = true; else if ((lastYear == year) && (lastMonth < month) && (day >= lastDay)) needsToPay = true; if (needsToPay) { if (CMLib.beanCounter() .modifyLocalBankGold( A, owner, CMLib.utensils().getFormattedDate(A) + ":Withdrawal of " + rent + ": Rent for " + ID, CMLib.beanCounter().getCurrency(A), (-rent))) { lastMonth++; if (lastMonth > A.getTimeObj().getMonthsInYear()) { lastMonth = 1; lastYear++; } changesMade = true; needsToPay = false; } } else break; } if (changesMade) reparse.append(ID + "|~>|" + lastDay + " " + lastMonth + " " + lastYear + "|~;|"); if (needsToPay && (!changesMade)) return true; } } else reparse.append(thisOne + "|~;|"); parse = parse.substring(x + 4); x = parse.indexOf("|~;|"); } if (changesMade) { CMLib.database() .DBReCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, reparse.toString()); pData = new DatabaseEngine.PlayerData(); pData.who = owner; pData.section = "RENTAL INFO"; pData.key = "RENTAL INFO/" + owner; pData.xml = reparse.toString(); pDataV.set(0, pData); Resources.removeResource("RENTAL INFO/" + owner); Resources.submitResource("RENTAL INFO/" + owner, pDataV); } return needsToPay; } return false; }