protected static boolean tryMerge( MOB mob, Room room, Environmental E, List things, List<String> changes, List<String> onfields, List<String> ignore, boolean noisy) { boolean didAnything = false; final List<String> efields = new Vector(); List<String> allMyFields = new Vector(); final String[] EFIELDS = E.getStatCodes(); for (int i = 0; i < EFIELDS.length; i++) if (!efields.contains(EFIELDS[i])) efields.add(EFIELDS[i]); efields.add("REJUV"); allMyFields = new XVector<String>(efields); for (int v = 0; v < ignore.size(); v++) if (efields.contains(ignore.get(v))) efields.remove(ignore.get(v)); for (int v = 0; v < changes.size(); v++) if (efields.contains(changes.get(v))) efields.remove(changes.get(v)); if (noisy) mergedebugtell(mob, "AllMy-" + CMParms.toStringList(allMyFields)); if (noisy) mergedebugtell(mob, "efields-" + CMParms.toStringList(efields)); for (int t = 0; t < things.size(); t++) { final Environmental E2 = (Environmental) things.get(t); if (noisy) mergedebugtell( mob, E.name() + "/" + E2.name() + "/" + CMClass.classID(E) + "/" + CMClass.classID(E2)); if (CMClass.classID(E).equals(CMClass.classID(E2))) { Vector fieldsToCheck = null; if (onfields.size() > 0) { fieldsToCheck = new Vector(); for (int v = 0; v < onfields.size(); v++) if (efields.contains(onfields.get(v))) fieldsToCheck.add(onfields.get(v)); } else fieldsToCheck = new XVector<String>(efields); boolean checkedOut = fieldsToCheck.size() > 0; if (noisy) mergedebugtell(mob, "fieldsToCheck-" + CMParms.toStringList(fieldsToCheck)); if (checkedOut) for (int i = 0; i < fieldsToCheck.size(); i++) { final String field = (String) fieldsToCheck.get(i); if (noisy) mergedebugtell( mob, field + "/" + getStat(E, field) + "/" + getStat(E2, field) + "/" + getStat(E, field).equals(getStat(E2, field))); if (!getStat(E, field).equals(getStat(E2, field))) { checkedOut = false; break; } } if (checkedOut) { List<String> fieldsToChange = null; if (changes.size() == 0) fieldsToChange = new XVector<String>(allMyFields); else { fieldsToChange = new Vector(); for (int v = 0; v < changes.size(); v++) if (allMyFields.contains(changes.get(v))) fieldsToChange.add(changes.get(v)); } if (noisy) mergedebugtell(mob, "fieldsToChange-" + CMParms.toStringList(fieldsToChange)); for (int i = 0; i < fieldsToChange.size(); i++) { final String field = fieldsToChange.get(i); if (noisy) mergedebugtell( mob, E.name() + " wants to change " + field + " value " + getStat(E, field) + " to " + getStat(E2, field) + "/" + (!getStat(E, field).equals(getStat(E2, field)))); if (!getStat(E, field).equals(getStat(E2, field))) { setStat(E, field, getStat(E2, field)); Log.sysOut( "Merge", "The " + CMStrings.capitalizeAndLower(field) + " field on " + E.Name() + " in " + room.roomID() + " was changed to " + getStat(E2, field) + "."); didAnything = true; } } } } } if (didAnything) { if (E instanceof Physical) ((Physical) E).recoverPhyStats(); if (E instanceof MOB) { ((MOB) E).recoverCharStats(); ((MOB) E).recoverMaxState(); } E.text(); } return didAnything; }
@Override public int compareTo(CMObject o) { return CMClass.classID(this).compareToIgnoreCase(CMClass.classID(o)); }