use of com.lilithsthrone.game.inventory.clothing.ClothingAccess in project liliths-throne-public by Innoxia.
the class CharacterInventory method isAbleToUnequip.
private boolean isAbleToUnequip(AbstractClothing clothing, boolean unequipIfAble, boolean automaticClothingManagement, GameCharacter characterClothingOwner, GameCharacter characterRemovingClothing, boolean continuingIsAbleToEquip) {
if (!continuingIsAbleToEquip) {
clothingToRemove.clear();
equipTextSB.setLength(0);
}
if (clothing.isSealed()) {
equipTextSB.append("Your " + clothing.getName() + " can't be removed because " + (clothing.getClothingType().isPlural() ? "they are" : "it is") + " <b style='color:" + Colour.SEALED.toWebHexString() + ";'>sealed</b>!");
blockingClothing = clothing;
return false;
} else if (!continuingIsAbleToEquip) {
clothingToRemove.put(clothing, DisplacementType.REMOVE_OR_EQUIP);
}
// Check for access needed: TODO check this works
for (BlockedParts bp : clothing.getClothingType().getBlockedPartsList()) {
// Keep iterating through until until we find the BlockedParts that corresponds to equipping (if not found, carry on, as this clothing doesn't need any access in order to be equipped):
if (bp.displacementType == DisplacementType.REMOVE_OR_EQUIP)
if (bp.clothingAccessRequired == null) {
// This clothing doesn't need any access in order to be equipped, so just carry on.
break;
} else {
// This clothing has access requirements in order to be equipped. Check each piece of equipped clothing to see if it's blocking the access required:
for (AbstractClothing equippedClothing : clothingCurrentlyEquipped) {
if (equippedClothing != clothing)
for (BlockedParts bpEquipped : equippedClothing.getClothingType().getBlockedPartsList()) {
for (ClothingAccess caBlocked : bpEquipped.clothingAccessBlocked) {
if (bp.clothingAccessRequired.contains(caBlocked) && !equippedClothing.getDisplacedList().contains(bpEquipped.displacementType) && !isDisplacementAvailableFromElsewhere(equippedClothing, caBlocked)) {
if (bpEquipped.displacementType != DisplacementType.REMOVE_OR_EQUIP) {
// If clothingToRemove already contains this clothing, it's just going to be easier to remove the clothing fully than perform multiple displacements:
if (!clothingToRemove.containsKey(equippedClothing))
if (!equippedClothing.getDisplacedList().contains(bpEquipped.displacementType)) {
// Not already displaced:
if (automaticClothingManagement)
clothingToRemove.put(equippedClothing, bpEquipped.displacementType);
else {
equipTextSB.append("Your <b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + equippedClothing.getName() + "</b> " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " preventing you from being able to unequip your " + clothing.getName() + "!");
blockingClothing = equippedClothing;
return false;
}
}
} else {
if (isAbleToUnequip(equippedClothing, false, automaticClothingManagement, characterClothingOwner, characterRemovingClothing, true)) {
// Can be removed:
clothingToRemove.put(equippedClothing, DisplacementType.REMOVE_OR_EQUIP);
} else {
equipTextSB.append("</br>Your " + clothing.getName() + " can't be unequipped because your " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
blockingClothing = equippedClothing;
return false;
}
}
}
}
}
}
}
}
if (continuingIsAbleToEquip)
return true;
if (!automaticClothingManagement && clothingToRemove.size() != 1) {
equipTextSB.append("Before your " + clothing.getName() + " " + (clothing.getClothingType().isPlural() ? "are" : "is") + " able to be removed, " + Util.clothesToStringList(clothingToRemove.keySet()) + " need" + (clothingToRemove.size() > 1 ? "" : "s") + " to be removed.");
for (AbstractClothing c : clothingToRemove.keySet()) if (c != clothing) {
blockingClothing = c;
break;
}
return false;
}
// If you want to unequip this clothing now:
if (unequipIfAble) {
// Sort clothing to remove in zLayer order(so you take off your
// shirt before removing bra etc.):
List<AbstractClothing> tempClothingList = new ArrayList<>();
tempClothingList.addAll(clothingToRemove.keySet());
tempClothingList.sort(new ClothingZLayerComparator());
// Description of each clothing item that is removed/displaced:
for (AbstractClothing c : tempClothingList) {
equipTextSB.append((equipTextSB.length() == 0 ? "" : "</br>") + (clothingToRemove.get(c) == DisplacementType.REMOVE_OR_EQUIP ? (// (Main.game.isInSex()?Sex.isSubResisting():false))
c == clothing ? // (Main.game.isInSex()?Sex.isSubResisting():false))
c.onUnequipApplyEffects(characterClothingOwner, characterRemovingClothing, false) : // (Main.game.isInSex()?Sex.isSubResisting():false)))
c.onUnequipText(characterClothingOwner, characterRemovingClothing, false)) : // (Main.game.isInSex()?Sex.isSubResisting():false))));
c.getClothingType().displaceText(characterClothingOwner, characterRemovingClothing, clothingToRemove.get(c), false)));
// if(c==clothing)
// unequipTextSB.append("</br>"+(isInventoryFull()?characterClothingOwner.droppedItemText(clothing):characterClothingOwner.addedItemToInventoryText(clothing)));
}
// Actually unequip the clothing:
clothingCurrentlyEquipped.remove(clothing);
// If it was displaced, clear it's displacements:
clothing.getDisplacedList().clear();
List<AbstractClothing> clothingToBeReplaced = new ArrayList<>();
clothingToBeReplaced.addAll(clothingToRemove.keySet());
clothingToBeReplaced.remove(clothing);
clothingToBeReplaced.sort(new ReverseClothingZLayerComparator());
if (!clothingToBeReplaced.isEmpty() && !continuingIsAbleToEquip) {
equipTextSB.append("</br>You replace " + (characterClothingOwner.isPlayer() ? "your" : characterClothingOwner.getName() + "'s") + " " + Util.clothesToStringList(clothingToBeReplaced) + ".");
}
// Check for clothing sets:
if (clothing.getClothingType().getClothingSet() != null) {
clothingSetCount.put(clothing.getClothingType().getClothingSet(), clothingSetCount.get(clothing.getClothingType().getClothingSet()) - 1);
}
clothingCurrentlyEquipped.sort(new AbstractClothingRarityComparator());
}
return true;
}
use of com.lilithsthrone.game.inventory.clothing.ClothingAccess in project liliths-throne-public by Innoxia.
the class CharacterInventory method getNextClothingToRemoveForCoverableAreaAccess.
public SimpleEntry<AbstractClothing, DisplacementType> getNextClothingToRemoveForCoverableAreaAccess(CoverableArea coverableArea) {
// TODO
AbstractClothing clothingToRemove = null;
DisplacementType displacement = null;
List<AbstractClothing> zLayerSortedList = new ArrayList<>(clothingCurrentlyEquipped);
zLayerSortedList.sort(new ClothingZLayerComparator().reversed());
outerloop: for (AbstractClothing clothing : zLayerSortedList) {
for (BlockedParts bp : clothing.getClothingType().getBlockedPartsList()) if (bp.blockedBodyParts.contains(coverableArea) && !clothing.getDisplacedList().contains(bp.displacementType)) {
if (!isCoverableAreaExposedFromElsewhere(clothing, coverableArea)) {
// this clothing is blocking the part we want access to, so make that our starting point:
clothingToRemove = clothing;
displacement = bp.displacementType;
break outerloop;
}
}
}
if (clothingToRemove == null) {
throw new IllegalArgumentException("There is no clothing covering this part!");
}
boolean finished = false;
while (!finished) {
finished = true;
outerloop2: for (BlockedParts bp : clothingToRemove.getClothingType().getBlockedPartsList()) {
if (bp.displacementType == displacement) {
for (ClothingAccess ca : bp.clothingAccessRequired) {
for (AbstractClothing clothing : zLayerSortedList) {
if (clothing != clothingToRemove) {
for (BlockedParts bpIterated : clothing.getClothingType().getBlockedPartsList()) {
if (bpIterated.clothingAccessBlocked.contains(ca) && !clothing.getDisplacedList().contains(bpIterated.displacementType)) {
if (!isCoverableAreaExposedFromElsewhere(clothing, coverableArea)) {
// this clothing is blocking the clothing we wanted to displace, so now we re-start by wanting to displace this new clothing:
clothingToRemove = clothing;
displacement = bpIterated.displacementType;
finished = false;
break outerloop2;
}
}
}
}
}
}
}
}
}
return new SimpleEntry<AbstractClothing, DisplacementType>(clothingToRemove, displacement);
}
use of com.lilithsthrone.game.inventory.clothing.ClothingAccess in project liliths-throne-public by Innoxia.
the class CharacterInventory method isAbleToBeReplaced.
public boolean isAbleToBeReplaced(AbstractClothing clothing, DisplacementType dt, boolean replaceIfAble, boolean automaticClothingManagement, GameCharacter characterClothingOwner, GameCharacter characterRemovingClothing) {
if (dt == DisplacementType.REMOVE_OR_EQUIP)
throw new IllegalArgumentException("Can't replace DisplacementType.REMOVE_OR_EQUIP!");
if (automaticClothingManagement)
clothingToRemove.clear();
boolean displacementTypeFound = false;
// Check for access needed: TODO check this works
for (BlockedParts bp : clothing.getClothingType().getBlockedPartsList()) {
// Keep iterating through until until we find the displacementType:
if (bp.displacementType == dt) {
displacementTypeFound = true;
if (bp.clothingAccessRequired == null) {
// This clothing doesn't need any access in order to
break;
// be displaced in this manner, so just carry on.
} else {
// This clothing has access requirements in order to be displaced. Check each piece of equipped clothing to see if it's blocking the access required:
for (AbstractClothing equippedClothing : clothingCurrentlyEquipped) {
for (BlockedParts bpEquipped : equippedClothing.getClothingType().getBlockedPartsList()) {
for (ClothingAccess caBlocked : bpEquipped.clothingAccessBlocked) {
if (bp.clothingAccessRequired.contains(caBlocked) && !equippedClothing.getDisplacedList().contains(bpEquipped.displacementType) && !isDisplacementAvailableFromElsewhere(equippedClothing, caBlocked)) {
if (bpEquipped.displacementType != DisplacementType.REMOVE_OR_EQUIP && !clothingToRemove.containsKey(equippedClothing)) {
// Can be displaced:
if (!equippedClothing.getDisplacedList().contains(bpEquipped.displacementType)) {
// Not already displaced:
if (automaticClothingManagement)
clothingToRemove.put(equippedClothing, bpEquipped.displacementType);
else {
unableToReplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " can't be replaced because " + equippedClothing.getClothingType().getDeterminer() + " " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
blockingClothing = equippedClothing;
return false;
}
}
} else {
if (// Can be removed:
isAbleToUnequip(equippedClothing, false, automaticClothingManagement, characterClothingOwner, characterRemovingClothing, true))
clothingToRemove.put(equippedClothing, DisplacementType.REMOVE_OR_EQUIP);
else {
unableToReplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " can't be replaced because " + equippedClothing.getClothingType().getDeterminer() + " " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
blockingClothing = equippedClothing;
return false;
}
}
}
}
}
}
}
}
}
// The supplied clothing cannot be displaced in this manner!
if (!displacementTypeFound) {
throw new IllegalArgumentException("The supplied clothing cannot be replaced in this manner!");
}
if (replaceIfAble) {
if (!clothing.getDisplacedList().contains(dt)) {
unableToReplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " is already replaced!");
return false;
}
clothing.getDisplacedList().remove(dt);
List<AbstractClothing> tempClothingList = new ArrayList<>();
tempClothingList.addAll(clothingToRemove.keySet());
tempClothingList.sort(new ClothingZLayerComparator());
unableToReplaceText = new StringBuilder();
// Description of each clothing item that is removed/displaced:
for (AbstractClothing c : tempClothingList) unableToReplaceText.append((unableToReplaceText.length() == 0 ? "" : "</br>") + (clothingToRemove.get(c) == DisplacementType.REMOVE_OR_EQUIP ? (// (Main.game.isInSex()?Sex.isSubResisting():false))
c == clothing ? // (Main.game.isInSex()?Sex.isSubResisting():false))
c.onUnequipApplyEffects(characterClothingOwner, characterRemovingClothing, false) : // (Main.game.isInSex()?Sex.isSubResisting():false)))
c.onUnequipText(characterClothingOwner, characterRemovingClothing, false)) : // (Main.game.isInSex()?Sex.isSubResisting():false))));
c.getClothingType().displaceText(characterClothingOwner, characterRemovingClothing, clothingToRemove.get(c), false)));
unableToReplaceText.append(// (Main.game.isInSex()?Sex.isSubResisting():false))
(unableToReplaceText.length() == 0 ? "" : "</br><span style='color:" + Colour.GENERIC_GOOD.toWebHexString() + ";'>") + clothing.getClothingType().replaceText(characterClothingOwner, characterRemovingClothing, dt, false) + "</span>");
List<AbstractClothing> replaceClothingList = new ArrayList<>();
replaceClothingList.addAll(clothingToRemove.keySet());
replaceClothingList.sort(new ReverseClothingZLayerComparator());
if (!replaceClothingList.isEmpty()) {
unableToReplaceText.append("</br>You replace " + (characterClothingOwner.isPlayer() ? "your" : characterClothingOwner.getName() + "'s") + " " + Util.clothesToStringList(replaceClothingList) + ".");
}
return true;
}
unableToReplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " is able to be replaced.");
return true;
}
use of com.lilithsthrone.game.inventory.clothing.ClothingAccess in project liliths-throne-public by Innoxia.
the class CharacterInventory method isAbleToBeDisplaced.
/**
* If pass in DisplacementType.REMOVE_OR_EQUIP, returns isAbleToUnequip().
*/
public boolean isAbleToBeDisplaced(AbstractClothing clothing, DisplacementType dt, boolean displaceIfAble, boolean automaticClothingManagement, GameCharacter characterClothingOwner, GameCharacter characterRemovingClothing, boolean continuingIsAbleToEquip) {
if (dt == DisplacementType.REMOVE_OR_EQUIP) {
return isAbleToUnequip(clothing, displaceIfAble, automaticClothingManagement, characterClothingOwner, characterRemovingClothing, continuingIsAbleToEquip);
}
if (!continuingIsAbleToEquip) {
clothingToRemove.clear();
equipTextSB.setLength(0);
}
boolean displacementTypeFound = false;
// Check for access needed: TODO check this works
for (BlockedParts bp : clothing.getClothingType().getBlockedPartsList()) {
// Keep iterating through until until we find the displacementType:
if (bp.displacementType == dt) {
displacementTypeFound = true;
if (bp.clothingAccessRequired == null) {
// This clothing doesn't need any access in order to be displaced in this manner, so just carry on.
break;
} else {
// This clothing has access requirements in order to be displaced. Check each piece of equipped clothing to see if it's blocking the access required:
for (AbstractClothing equippedClothing : clothingCurrentlyEquipped) {
if (equippedClothing != clothing)
for (BlockedParts bpEquipped : equippedClothing.getClothingType().getBlockedPartsList()) {
for (ClothingAccess caBlocked : bpEquipped.clothingAccessBlocked) {
if (bp.clothingAccessRequired.contains(caBlocked) && !equippedClothing.getDisplacedList().contains(bpEquipped.displacementType) && !isDisplacementAvailableFromElsewhere(equippedClothing, caBlocked)) {
if (bpEquipped.displacementType != DisplacementType.REMOVE_OR_EQUIP && !clothingToRemove.containsKey(equippedClothing)) {
// Can be displaced:
if (!equippedClothing.getDisplacedList().contains(bpEquipped.displacementType)) {
// Not already displaced:
if (automaticClothingManagement)
clothingToRemove.put(equippedClothing, bpEquipped.displacementType);
else {
unableToDisplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " can't be displaced because " + equippedClothing.getClothingType().getDeterminer() + " " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
blockingClothing = equippedClothing;
return false;
}
}
} else {
if (// Can be removed:
isAbleToUnequip(equippedClothing, false, automaticClothingManagement, characterClothingOwner, characterRemovingClothing, true))
clothingToRemove.put(equippedClothing, DisplacementType.REMOVE_OR_EQUIP);
else {
unableToDisplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " can't be displaced because " + equippedClothing.getClothingType().getDeterminer() + " " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
blockingClothing = equippedClothing;
return false;
}
}
}
}
}
}
}
}
}
// The supplied clothing cannot be displaced in this manner!
if (!displacementTypeFound) {
throw new IllegalArgumentException("The supplied clothing cannot be displaced in this manner!");
}
if (displaceIfAble) {
if (clothing.getDisplacedList().contains(dt)) {
unableToDisplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " is already displaced!");
return false;
}
clothing.getDisplacedList().add(dt);
List<AbstractClothing> tempClothingList = new ArrayList<>();
tempClothingList.addAll(clothingToRemove.keySet());
tempClothingList.sort(new ClothingZLayerComparator());
unableToDisplaceText = new StringBuilder();
// Description of each clothing item that is removed/displaced:
for (AbstractClothing c : tempClothingList) {
unableToDisplaceText.append((unableToDisplaceText.length() == 0 ? "" : "</br>") + (// (Main.game.isInSex()?Sex.isSubResisting():false))
clothingToRemove.get(c) == DisplacementType.REMOVE_OR_EQUIP ? // (Main.game.isInSex()?Sex.isSubResisting():false))
c.onUnequipText(characterClothingOwner, characterRemovingClothing, false) : // (Main.game.isInSex()?Sex.isSubResisting():false))));
c.getClothingType().displaceText(characterClothingOwner, characterRemovingClothing, clothingToRemove.get(c), false)));
}
unableToDisplaceText.append(// (Main.game.isInSex()?Sex.isSubResisting():false))
(unableToDisplaceText.length() == 0 ? "" : "</br><span style='color:" + Colour.GENERIC_ARCANE.toWebHexString() + ";'>") + clothing.getClothingType().displaceText(characterClothingOwner, characterRemovingClothing, dt, false) + "</span>");
List<AbstractClothing> replaceClothingList = new ArrayList<>();
replaceClothingList.addAll(clothingToRemove.keySet());
replaceClothingList.remove(clothing);
replaceClothingList.sort(new ReverseClothingZLayerComparator());
if (!replaceClothingList.isEmpty()) {
unableToDisplaceText.append("</br>You replace " + (characterClothingOwner.isPlayer() ? "your" : characterClothingOwner.getName() + "'s") + " " + Util.clothesToStringList(replaceClothingList) + ".");
}
return true;
}
unableToDisplaceText = new StringBuilder(Util.capitaliseSentence(clothing.getClothingType().getDeterminer()) + " " + clothing.getName() + " is able to be displaced.");
return true;
}
use of com.lilithsthrone.game.inventory.clothing.ClothingAccess in project liliths-throne-public by Innoxia.
the class CharacterInventory method isAbleToEquip.
/**
* Calculates if the character is able to remove or displace all blocking clothing in order to equip the supplied clothing.
*/
public boolean isAbleToEquip(AbstractClothing newClothing, boolean equipIfAble, boolean automaticClothingManagement, GameCharacter characterClothingOwner, GameCharacter characterClothingEquipper) {
clothingToRemove.clear();
equipTextSB.setLength(0);
// Check to see if any of the character's body parts are blocking equipping this item:
if (newClothing.getClothingType().getSlot().slotBlockedByRace(characterClothingOwner) != null) {
equipTextSB.append("<span style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + newClothing.getClothingType().getSlot().getCannotBeWornDescription(characterClothingOwner) + "</span>");
return false;
}
if (!newClothing.getClothingType().isCanBeEquipped(characterClothingOwner)) {
equipTextSB.append("<span style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + newClothing.getClothingType().getCannotBeEquippedText(characterClothingOwner) + "</span>");
return false;
}
// Can't equip if InventorySlot is taken by a sealed piece of clothing:
if (getClothingInSlot(newClothing.getClothingType().getSlot()) != null) {
if (getClothingInSlot(newClothing.getClothingType().getSlot()).isSealed()) {
if (characterClothingOwner.isPlayer()) {
equipTextSB.append("You can't equip the " + newClothing.getName() + ", as your <b style='color:" + Colour.SEALED.toWebHexString() + ";'>sealed</b> " + getClothingInSlot(newClothing.getClothingType().getSlot()).getName() + " can't be removed!");
} else {
equipTextSB.append(UtilText.parse(characterClothingOwner, "[npc.Name] can't equip the " + newClothing.getName() + ", as [npc.her] <b style='color:" + Colour.SEALED.toWebHexString() + ";'>sealed</b> " + getClothingInSlot(newClothing.getClothingType().getSlot()).getName() + " can't be removed!"));
}
return false;
}
}
// Can't equip piercings if that body part isn't pierced:
if (!characterClothingOwner.isPiercedEar() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_EAR) {
equipTextSB.append("Your ears need to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedNose() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_NOSE) {
equipTextSB.append("Your nose needs to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedLip() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_LIP) {
equipTextSB.append("Your lip needs to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedTongue() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_TONGUE) {
equipTextSB.append("Your tongue needs to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedNavel() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_STOMACH) {
equipTextSB.append("Your navel needs to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedNipple() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_NIPPLE) {
equipTextSB.append("Your nipples need to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedVagina() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_VAGINA) {
equipTextSB.append("Your clit needs to be pierced before you can wear this!");
return false;
}
if (!characterClothingOwner.isPiercedPenis() && newClothing.getClothingType().getSlot() == InventorySlot.PIERCING_PENIS) {
equipTextSB.append("Your cock needs to be pierced before you can wear this!");
return false;
}
// Check to see if any equipped clothing is incompatible with newClothing:
incompatibleUnequippableClothing.clear();
incompatibleRemovableClothing.clear();
for (InventorySlot slot : newClothing.getClothingType().getIncompatibleSlots()) {
if (getClothingInSlot(slot) != null) {
if (!isAbleToUnequip(getClothingInSlot(slot), false, automaticClothingManagement, characterClothingOwner, characterClothingEquipper, true))
incompatibleUnequippableClothing.add(getClothingInSlot(slot));
else {
clothingToRemove.put(getClothingInSlot(slot), DisplacementType.REMOVE_OR_EQUIP);
incompatibleRemovableClothing.add(getClothingInSlot(slot));
}
}
}
// Check to see if newClothing is incompatible with any equipped clothing:
for (AbstractClothing clothing : clothingCurrentlyEquipped) {
if (clothing.getClothingType().getIncompatibleSlots().contains(newClothing.getClothingType().getSlot())) {
if (!isAbleToUnequip(clothing, false, automaticClothingManagement, characterClothingOwner, characterClothingEquipper, true)) {
incompatibleUnequippableClothing.add(clothing);
} else {
clothingToRemove.put(clothing, DisplacementType.REMOVE_OR_EQUIP);
incompatibleRemovableClothing.add(clothing);
}
}
}
// There is at least one piece of clothing that is incompatible with newClothing, and that clothing cannot be removed.
if (!incompatibleUnequippableClothing.isEmpty()) {
for (AbstractClothing c : incompatibleUnequippableClothing) {
if (c.isSealed())
equipTextSB.append("You can't equip the " + newClothing.getName() + " because your <b style='color:" + Colour.SEALED.toWebHexString() + ";'>sealed</b> " + c.getName() + " " + (c.getClothingType().isPlural() ? "are" : "is") + " in the way.");
}
return false;
}
// Check for access needed:
for (BlockedParts bp : newClothing.getClothingType().getBlockedPartsList()) {
if (bp.displacementType == DisplacementType.REMOVE_OR_EQUIP) {
// Check for all blocking types that affect REMOVE_OR_EQUIP. (As we are trying to equip this item of clothing.)
if (bp.clothingAccessRequired == null) {
// This clothing doesn't need any access in order to be equipped, so just carry on.
break;
} else {
// This clothing has access requirements in order to be equipped. Check each piece of equipped clothing to see if it's blocking the access required:
for (AbstractClothing equippedClothing : clothingCurrentlyEquipped) {
for (BlockedParts bpEquipped : equippedClothing.getClothingType().getBlockedPartsList()) {
for (ClothingAccess caBlocked : bpEquipped.clothingAccessBlocked) {
if (bp.clothingAccessRequired.contains(caBlocked) && !equippedClothing.getDisplacedList().contains(bpEquipped.displacementType) && !isDisplacementAvailableFromElsewhere(equippedClothing, caBlocked)) {
if (!clothingToRemove.containsKey(equippedClothing)) {
// This clothing has not already been marked for removal:
if (automaticClothingManagement && isAbleToBeDisplaced(equippedClothing, bpEquipped.displacementType, false, automaticClothingManagement, characterClothingOwner, characterClothingEquipper, true)) {
clothingToRemove.put(equippedClothing, bpEquipped.displacementType);
} else {
equipTextSB.append("Your <b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + equippedClothing.getName() + "</b> " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " preventing you from being able to equip the " + newClothing.getName() + "!");
blockingClothing = equippedClothing;
return false;
}
} else {
if (isAbleToUnequip(equippedClothing, false, automaticClothingManagement, characterClothingOwner, characterClothingEquipper, true)) {
// Can be removed:
clothingToRemove.put(equippedClothing, DisplacementType.REMOVE_OR_EQUIP);
} else {
if (equippedClothing.isSealed()) {
equipTextSB.append("You can't equip the " + newClothing.getName() + " because your <b style='color:" + Colour.SEALED.toWebHexString() + ";'>sealed</b> " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
} else {
equipTextSB.append("You can't equip the " + newClothing.getName() + " because your " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
}
blockingClothing = equippedClothing;
return false;
}
}
}
}
}
}
}
}
}
// If you want to equip this clothing now:
if (equipIfAble) {
equipTextSB = new StringBuilder();
if (automaticClothingManagement || (clothingToRemove.size() == incompatibleRemovableClothing.size() + 1)) {
if (getClothingInSlot(newClothing.getClothingType().getSlot()) != null) {
AbstractClothing equippedClothing = getClothingInSlot(newClothing.getClothingType().getSlot());
if (isAbleToUnequip(equippedClothing, false, automaticClothingManagement, characterClothingOwner, characterClothingEquipper, true)) {
// Can be removed:
clothingToRemove.put(equippedClothing, DisplacementType.REMOVE_OR_EQUIP);
} else {
if (equippedClothing.isSealed()) {
equipTextSB.append("You can't equip the " + newClothing.getName() + " because your <b style='color:" + Colour.SEALED.toWebHexString() + ";'>sealed</b> " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
} else {
equipTextSB.append("You can't equip the " + newClothing.getName() + " because your " + equippedClothing.getName() + " " + (equippedClothing.getClothingType().isPlural() ? "are" : "is") + " in the way.");
}
blockingClothing = equippedClothing;
return false;
}
}
// Sort clothing to remove in zLayer order(so you take off your
// shirt before removing bra etc.):
List<AbstractClothing> tempClothingList = new ArrayList<>();
for (AbstractClothing cl : clothingToRemove.keySet()) if (!tempClothingList.contains(cl))
tempClothingList.add(cl);
for (AbstractClothing cl : incompatibleRemovableClothing) if (!tempClothingList.contains(cl))
tempClothingList.add(cl);
// tempClothingList.addAll(clothingToRemove.keySet());
// tempClothingList.addAll(incompatibleRemovableClothing);
// if (getClothingInSlot(newClothing.getClothingType().getSlot()) != null && !tempClothingList.contains(getClothingInSlot(newClothing.getClothingType().getSlot())))
// tempClothingList.add(getClothingInSlot(newClothing.getClothingType().getSlot()));
tempClothingList.sort(new ClothingZLayerComparator());
List<AbstractClothing> clothingToBeReplaced = new ArrayList<>();
// Description of each clothing item that is removed/displaced:
for (AbstractClothing c : tempClothingList) {
if (!incompatibleRemovableClothing.contains(c) && c != getClothingInSlot(newClothing.getClothingType().getSlot())) {
clothingToBeReplaced.add(c);
}
equipTextSB.append((equipTextSB.length() == 0 ? "" : "</br>") + (clothingToRemove.get(c) == DisplacementType.REMOVE_OR_EQUIP ? // (Main.game.isInSex()?Sex.isSubResisting():false))
c.onUnequipText(characterClothingOwner, characterClothingEquipper, false) : "You " + clothingToRemove.get(c).getDescription() + " your " + c.getName() + "."));
}
// Remove all clothing that is incompatible with newClothing using the owner's accessor method.
for (AbstractClothing c : incompatibleRemovableClothing) {
if (!characterClothingOwner.isInventoryFull() || characterClothingOwner.hasClothing(c))
equipTextSB.append("</br>" + characterClothingOwner.addedItemToInventoryText(c));
else
equipTextSB.append("</br>" + characterClothingOwner.droppedItemText(c));
// this is a hack to fix the string builder being overwritten
String oldEquipText = equipTextSB.toString();
if (Main.game.isInNewWorld()) {
characterClothingOwner.unequipClothingIntoInventory(c, true, characterClothingEquipper);
} else {
characterClothingOwner.unequipClothingOntoFloor(c, true, characterClothingEquipper);
}
equipTextSB.setLength(0);
equipTextSB.append(oldEquipText);
}
// Clear the new clothing's displacement list as a precaution:
newClothing.getDisplacedList().clear();
// Remove the old clothing in this slot using the owner's accessor method:
if (getClothingInSlot(newClothing.getClothingType().getSlot()) != null) {
if (getClothingInSlot(newClothing.getClothingType().getSlot()).getClothingType().isDiscardedOnUnequip()) {
// this is a hack to fix the string builder being overwritten
String oldEquipText = equipTextSB.toString();
characterClothingOwner.unequipClothingIntoVoid(getClothingInSlot(newClothing.getClothingType().getSlot()), true, characterClothingEquipper);
equipTextSB.setLength(0);
equipTextSB.append(oldEquipText);
} else {
if ((!characterClothingOwner.isInventoryFull() || characterClothingOwner.hasClothing(getClothingInSlot(newClothing.getClothingType().getSlot()))) && Main.game.isInNewWorld()) {
equipTextSB.append("</br>" + characterClothingOwner.addedItemToInventoryText(getClothingInSlot(newClothing.getClothingType().getSlot())));
} else {
equipTextSB.append("</br>" + characterClothingOwner.droppedItemText(getClothingInSlot(newClothing.getClothingType().getSlot())));
}
// this is a hack to fix the string builder being overwritten
String oldEquipText = equipTextSB.toString();
if (Main.game.isInNewWorld()) {
characterClothingOwner.unequipClothingIntoInventory(getClothingInSlot(newClothing.getClothingType().getSlot()), true, characterClothingEquipper);
} else {
characterClothingOwner.unequipClothingOntoFloor(getClothingInSlot(newClothing.getClothingType().getSlot()), true, characterClothingEquipper);
}
equipTextSB.setLength(0);
equipTextSB.append(oldEquipText);
}
}
// Actually equip the newClothing:
clothingCurrentlyEquipped.add(newClothing);
// newClothing.getClothingType().setColourShade(newClothing.getColourShade());
// (Main.game.isInSex()?Sex.isSubResisting():false)));
equipTextSB.append((equipTextSB.length() == 0 ? "" : "</br>") + newClothing.onEquipApplyEffects(characterClothingOwner, characterClothingEquipper, false));
clothingToBeReplaced.sort(new ReverseClothingZLayerComparator());
if (!clothingToBeReplaced.isEmpty()) {
// clothingCountToBeReplaced-incompatibleUnequippableClothing.size()>0)
equipTextSB.append("</br>You replace " + (characterClothingOwner.isPlayer() ? "your" : characterClothingOwner.getName("the") + "'s") + " " + Util.clothesToStringList(clothingToBeReplaced) + ".");
}
// Check for clothing sets:
if (newClothing.getClothingType().getClothingSet() != null) {
if (clothingSetCount.get(newClothing.getClothingType().getClothingSet()) == null) {
clothingSetCount.put(newClothing.getClothingType().getClothingSet(), 1);
} else {
clothingSetCount.put(newClothing.getClothingType().getClothingSet(), clothingSetCount.get(newClothing.getClothingType().getClothingSet()) + 1);
}
}
}
clothingCurrentlyEquipped.sort(new AbstractClothingRarityComparator());
} else {
if (clothingToRemove.isEmpty()) {
equipTextSB.append(Util.capitaliseSentence(newClothing.getName(true)) + " " + (newClothing.getClothingType().isPlural() ? "are" : "is") + " able to be equipped.");
} else {
equipTextSB.append(Util.capitaliseSentence("Before" + newClothing.getClothingType().getDeterminer()) + " " + newClothing.getName() + " is able to be equipped, " + Util.clothesToStringList(clothingToRemove.keySet()) + " need" + (clothingToRemove.size() > 1 ? "" : "s") + " to be removed.");
}
}
return true;
}
Aggregations