returns true if you can put Equipment into a location in EquipSet @param eSet @param locName @param eqI @param eqTarget @return true if equipment can be added
(EquipSet eSet, String locName, Equipment eqI, Equipment eqTarget)
| 7022 | * @return true if equipment can be added |
| 7023 | */ |
| 7024 | private boolean canEquipItem(EquipSet eSet, String locName, Equipment eqI, Equipment eqTarget) |
| 7025 | { |
| 7026 | final String idPath = eSet.getIdPath(); |
| 7027 | // If target is a container, allow it |
| 7028 | if ((eqTarget != null) && eqTarget.isContainer()) |
| 7029 | { |
| 7030 | return true; // TODO - Should make sure eqI can be contained by eqTarget |
| 7031 | } |
| 7032 | |
| 7033 | // If Carried/Equipped/Not Carried slot |
| 7034 | // allow as many as they would like |
| 7035 | if (locName.startsWith(Constants.EQUIP_LOCATION_CARRIED) |
| 7036 | || locName.startsWith(Constants.EQUIP_LOCATION_EQUIPPED) |
| 7037 | || locName.startsWith(Constants.EQUIP_LOCATION_NOTCARRIED)) |
| 7038 | { |
| 7039 | return true; |
| 7040 | } |
| 7041 | |
| 7042 | // allow as many unarmed items as you'd like |
| 7043 | if (eqI.isUnarmed()) |
| 7044 | { |
| 7045 | return true; |
| 7046 | } |
| 7047 | |
| 7048 | // allow many Secondary Natural weapons |
| 7049 | if (locName.equals(Constants.EQUIP_LOCATION_NATURAL_SECONDARY)) |
| 7050 | { |
| 7051 | return true; |
| 7052 | } |
| 7053 | |
| 7054 | // Don't allow weapons that are too large for PC |
| 7055 | if (eqI.isWeapon() && eqI.isWeaponOutsizedForPC(this) && !eqI.isNatural()) |
| 7056 | { |
| 7057 | return false; |
| 7058 | } |
| 7059 | |
| 7060 | // make a HashMap to keep track of the number of each |
| 7061 | // item that is already equipped to a slot |
| 7062 | Map<String, String> slotMap = new HashMap<>(); |
| 7063 | |
| 7064 | for (EquipSet es : getEquipSet()) |
| 7065 | { |
| 7066 | String esID = es.getParentIdPath() + Constants.EQUIP_SET_PATH_SEPARATOR; |
| 7067 | String abID = idPath + Constants.EQUIP_SET_PATH_SEPARATOR; |
| 7068 | if (!esID.startsWith(abID)) |
| 7069 | { |
| 7070 | continue; |
| 7071 | } |
| 7072 | |
| 7073 | // check to see if we already have |
| 7074 | // an item in that particular location |
| 7075 | if (es.getName().equals(locName)) |
| 7076 | { |
| 7077 | final Equipment eItem = es.getItem(); |
| 7078 | final String nString = slotMap.get(locName); |
| 7079 | int existNum = 0; |
| 7080 | if (nString != null) |
| 7081 | { |
no test coverage detected