use of com.lilithsthrone.game.character.attributes.Attribute in project liliths-throne-public by Innoxia.
the class MainController method manageRightListeners.
private void manageRightListeners() {
documentRight = (Document) webEngineRight.executeScript("document");
EventListenerDataMap.put(documentRight, new ArrayList<>());
List<InventorySlot> concealedSlots = new ArrayList<>();
if (RenderingEngine.getCharacterToRender() != null) {
concealedSlots = RenderingEngine.getCharacterToRender().getInventorySlotsConcealed();
}
// Inventory:
String id;
for (InventorySlot invSlot : InventorySlot.values()) {
id = invSlot.toString() + "Slot";
if (invSlot != InventorySlot.WEAPON_MAIN && invSlot != InventorySlot.WEAPON_OFFHAND) {
if (((EventTarget) documentRight.getElementById(id)) != null) {
if (concealedSlots.contains(invSlot)) {
addEventListener(documentRight, id, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, id, "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el2 = new TooltipInformationEventListener().setInformation(Util.capitaliseSentence(invSlot.getName()) + " - [style.boldBad(Concealed!)]", "");
addEventListener(documentRight, id, "mouseenter", el2, false);
} else {
InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setClothingEquipped(RenderingEngine.getCharacterToRender(), invSlot);
addEventListener(documentRight, id, "click", el, false);
addEventListener(documentRight, id, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, id, "mouseleave", hideTooltipListener, false);
InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setInventorySlot(invSlot, RenderingEngine.getCharacterToRender());
addEventListener(documentRight, id, "mouseenter", el2, false);
}
}
} else {
if (((EventTarget) documentRight.getElementById(id)) != null) {
InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setWeaponEquipped(RenderingEngine.getCharacterToRender(), invSlot);
addEventListener(documentRight, id, "click", el, false);
addEventListener(documentRight, id, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, id, "mouseleave", hideTooltipListener, false);
InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setInventorySlot(invSlot, RenderingEngine.getCharacterToRender());
addEventListener(documentRight, id, "mouseenter", el2, false);
}
}
}
for (NPC character : Main.game.getCharactersPresent()) {
id = "CHARACTERS_PRESENT_" + character.getId();
if (((EventTarget) documentRight.getElementById(id)) != null) {
((EventTarget) documentRight.getElementById(id)).addEventListener("click", e -> {
openCharactersPresent(Main.game.getNPCById(character.getId()));
}, false);
}
}
if (Main.game.getPlayer() != null) {
// Weapons on floor:
for (Entry<AbstractWeapon, Integer> entry : Main.game.getPlayerCell().getInventory().getMapOfDuplicateWeapons().entrySet()) {
id = "WEAPON_FLOOR_" + entry.getKey().hashCode();
if (((EventTarget) documentRight.getElementById(id)) != null) {
if (!Main.game.getCurrentDialogueNode().isInventoryDisabled()) {
InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setWeaponInventory(entry.getKey(), null);
addEventListener(documentRight, id, "click", el, false);
}
addEventListener(documentRight, id, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, id, "mouseleave", hideTooltipListener, false);
InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setWeapon(entry.getKey(), null);
addEventListener(documentRight, id, "mouseenter", el2, false);
}
}
// Clothing on floor:
for (Entry<AbstractClothing, Integer> entry : Main.game.getPlayerCell().getInventory().getMapOfDuplicateClothing().entrySet()) {
id = "CLOTHING_FLOOR_" + entry.getKey().hashCode();
if (((EventTarget) documentRight.getElementById(id)) != null) {
if (!Main.game.getCurrentDialogueNode().isInventoryDisabled()) {
InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setClothingInventory(entry.getKey(), null);
addEventListener(documentRight, id, "click", el, false);
}
addEventListener(documentRight, id, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, id, "mouseleave", hideTooltipListener, false);
InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setClothing(entry.getKey(), null, null);
addEventListener(documentRight, id, "mouseenter", el2, false);
}
}
// Items on floor:
for (Entry<AbstractItem, Integer> entry : Main.game.getPlayerCell().getInventory().getMapOfDuplicateItems().entrySet()) {
id = "ITEM_FLOOR_" + entry.getKey().hashCode();
if (((EventTarget) documentRight.getElementById(id)) != null) {
if (!Main.game.getCurrentDialogueNode().isInventoryDisabled()) {
InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setItemInventory(entry.getKey(), null);
addEventListener(documentRight, id, "click", el, false);
}
addEventListener(documentRight, id, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, id, "mouseleave", hideTooltipListener, false);
InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setItem(entry.getKey(), null, null);
addEventListener(documentRight, id, "mouseenter", el2, false);
}
}
}
if (RenderingEngine.getCharacterToRender() != null) {
Attribute[] attributes = { Attribute.HEALTH_MAXIMUM, Attribute.MANA_MAXIMUM, Attribute.EXPERIENCE, Attribute.MAJOR_PHYSIQUE, Attribute.MAJOR_ARCANE, Attribute.MAJOR_CORRUPTION, Attribute.AROUSAL, Attribute.LUST };
List<GameCharacter> charactersBeingRendered = new ArrayList<>();
if (Main.game.isInSex()) {
charactersBeingRendered.addAll(Sex.getDominantParticipants().keySet());
charactersBeingRendered.addAll(Sex.getSubmissiveParticipants().keySet());
} else if (Main.game.isInCombat()) {
charactersBeingRendered.addAll(Combat.getEnemies());
} else {
charactersBeingRendered.add(RenderingEngine.getCharacterToRender());
}
charactersBeingRendered.remove(Main.game.getPlayer());
for (GameCharacter character : charactersBeingRendered) {
String idModifier = character.getId() + "_";
for (Attribute a : attributes) {
if (((EventTarget) documentRight.getElementById("NPC_" + idModifier + a.getName())) != null) {
if (a == Attribute.EXPERIENCE) {
((EventTarget) documentRight.getElementById("NPC_" + idModifier + a.getName())).addEventListener("click", e -> {
openCharactersPresent(character);
}, false);
}
addEventListener(documentRight, "NPC_" + idModifier + a.getName(), "mousemove", moveTooltipListener, false);
addEventListener(documentRight, "NPC_" + idModifier + a.getName(), "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setAttribute(a, character);
addEventListener(documentRight, "NPC_" + idModifier + a.getName(), "mouseenter", el, false);
}
}
// Extra attribute info:
if (((EventTarget) documentRight.getElementById("NPC_" + idModifier + "ATTRIBUTES")) != null) {
// ((EventTarget) documentRight.getElementById("NPC_"+idModifier+"ATTRIBUTES")).addEventListener("click", e -> {
// openCharactersPresent(Main.game.getNPCById(Main.game.getActiveNPC().getId()));
// }, false);
addEventListener(documentRight, "NPC_" + idModifier + "ATTRIBUTES", "mousemove", moveTooltipListener, false);
addEventListener(documentRight, "NPC_" + idModifier + "ATTRIBUTES", "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setExtraAttributes(character);
addEventListener(documentRight, "NPC_" + idModifier + "ATTRIBUTES", "mouseenter", el, false);
}
// For status effect slots:
for (StatusEffect se : character.getStatusEffects()) {
if (((EventTarget) documentRight.getElementById("SE_NPC_" + idModifier + se)) != null) {
addEventListener(documentRight, "SE_NPC_" + idModifier + se, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, "SE_NPC_" + idModifier + se, "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setStatusEffect(se, character);
addEventListener(documentRight, "SE_NPC_" + idModifier + se, "mouseenter", el, false);
}
}
// For perk slots:
for (Perk p : character.getMajorPerks()) {
if (((EventTarget) documentRight.getElementById("PERK_NPC_" + idModifier + p)) != null) {
addEventListener(documentRight, "PERK_NPC_" + idModifier + p, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, "PERK_NPC_" + idModifier + p, "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setPerk(p, character);
addEventListener(documentRight, "PERK_NPC_" + idModifier + p, "mouseenter", el, false);
}
}
for (Fetish f : character.getFetishes()) {
if (((EventTarget) documentRight.getElementById("FETISH_NPC_" + idModifier + f)) != null) {
addEventListener(documentRight, "FETISH_NPC_" + idModifier + f, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, "FETISH_NPC_" + idModifier + f, "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setFetish(f, character);
addEventListener(documentRight, "FETISH_NPC_" + idModifier + f, "mouseenter", el, false);
}
}
for (SpecialAttack sa : character.getSpecialAttacks()) {
if (((EventTarget) documentRight.getElementById("SA_NPC_" + idModifier + sa)) != null) {
addEventListener(documentRight, "SA_NPC_" + idModifier + sa, "mousemove", moveTooltipListener, false);
addEventListener(documentRight, "SA_NPC_" + idModifier + sa, "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setSpecialAttack(sa, character);
addEventListener(documentRight, "SA_NPC_" + idModifier + sa, "mouseenter", el, false);
}
}
for (Spell s : character.getAllSpells()) {
if (((EventTarget) documentAttributes.getElementById("SPELL_" + idModifier + s)) != null) {
addEventListener(documentAttributes, "SPELL_" + idModifier + s, "mousemove", moveTooltipListener, false);
addEventListener(documentAttributes, "SPELL_" + idModifier + s, "mouseleave", hideTooltipListener, false);
TooltipInformationEventListener el = new TooltipInformationEventListener().setSpell(s, character.getLevel(), character);
addEventListener(documentAttributes, "SPELL_" + idModifier + s, "mouseenter", el, false);
}
}
}
}
}
use of com.lilithsthrone.game.character.attributes.Attribute in project liliths-throne-public by Innoxia.
the class InventoryTooltipEventListener method clothingTooltip.
private void clothingTooltip(AbstractClothing absClothing) {
int yIncrease = 0;
int listIncrease = absClothing.getAttributeModifiers().size();
yIncrease += absClothing.getExtraDescriptions(equippedToCharacter).size();
for (ItemEffect ie : absClothing.getEffects()) {
if (ie.getPrimaryModifier() == TFModifier.CLOTHING_ENSLAVEMENT || ie.getPrimaryModifier() == TFModifier.CLOTHING_SEALING) {
listIncrease += 1;
} else if (ie.getPrimaryModifier() != TFModifier.CLOTHING_ATTRIBUTE) {
listIncrease += 2;
}
}
yIncrease += Math.max(0, listIncrease - 4);
// Title:
tooltipSB.setLength(0);
tooltipSB.append("<body>" + "<div class='container-full-width center'><h5>" + Util.capitaliseSentence(absClothing.getDisplayName(true)) + "</h5></div>");
// Core info:
tooltipSB.append("<div class='container-half-width titular'>" + Util.capitaliseSentence(absClothing.getClothingType().getSlot().getName()) + "</div>");
tooltipSB.append("<div class='container-half-width titular'>" + (absClothing.getClothingType().getClothingSet() == null ? "<span style='color:" + Colour.TEXT_GREY.toWebHexString() + ";'>Not part of a set</span>" : absClothing.getClothingType().getClothingSet().getName() + " set") + "</div>");
// Attribute modifiers:
tooltipSB.append("<div class='container-full-width'>" + "<div class='container-half-width titular' style='width:calc(66.6% - 16px);'>");
int res = absClothing.getClothingType().getPhysicalResistance();
tooltipSB.append((res > 0 ? "[style.boldGood(+" + absClothing.getClothingType().getPhysicalResistance() + ")]" : "[style.boldDisabled(0)]") + " [style.boldResPhysical(" + Util.capitaliseSentence(Attribute.RESISTANCE_PHYSICAL.getName()) + ")]");
if (!absClothing.getEffects().isEmpty()) {
if (!absClothing.isEnchantmentKnown()) {
tooltipSB.append("</br>[style.colourDisabled(Unidentified effects!)]");
} else {
for (ItemEffect e : absClothing.getEffects()) {
if (e.getPrimaryModifier() != TFModifier.CLOTHING_ATTRIBUTE) {
for (String s : e.getEffectsDescription(owner, owner)) {
tooltipSB.append("</br>" + s);
}
}
}
for (Entry<Attribute, Integer> entry : absClothing.getAttributeModifiers().entrySet()) {
tooltipSB.append("</br>" + (entry.getValue() < 0 ? "[style.boldBad(" + entry.getValue() + ")] " : "[style.boldGood(+" + entry.getValue() + ")] ") + "<b style='color:" + entry.getKey().getColour().toWebHexString() + ";'>" + Util.capitaliseSentence(entry.getKey().getName()) + "</b>");
}
}
} else {
tooltipSB.append("</br>[style.colourDisabled(No bonuses)]");
}
tooltipSB.append("</div>");
// Picture:
tooltipSB.append("<div class='container-half-width' style='width:calc(33.3% - 16px);'>" + (owner != null && owner.getClothingCurrentlyEquipped().contains(absClothing) ? absClothing.getSVGEquippedString(owner) : absClothing.getSVGString()) + "</div>");
tooltipSB.append("</div>");
tooltipSB.append("<div class='container-full-width' style='padding:8px; height:106px;'>" + absClothing.getTypeDescription() + "</div>");
tooltipSB.append("<div class='container-full-width titular'>");
if (absClothing.getExtraDescriptions(equippedToCharacter).isEmpty()) {
tooltipSB.append("<span style='color:" + Colour.TEXT_GREY.toWebHexString() + ";'>No Status</span>");
} else {
tooltipSB.append("<b>Status</b>");
for (String s : absClothing.getExtraDescriptions(equippedToCharacter)) {
tooltipSB.append("</br>" + s);
}
}
tooltipSB.append("</div>");
if (InventoryDialogue.getInventoryNPC() != null && InventoryDialogue.getNPCInventoryInteraction() == InventoryInteraction.TRADING) {
if (owner.isPlayer()) {
if (InventoryDialogue.getInventoryNPC().willBuy(absClothing)) {
tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + (absClothing.isEnchantmentKnown() ? UtilText.formatAsMoney(absClothing.getValue()) : UtilText.formatAsMoney("?", "b")) + " | " + InventoryDialogue.getInventoryNPC().getName("The") + " offers " + UtilText.formatAsMoney(absClothing.getPrice(InventoryDialogue.getInventoryNPC().getBuyModifier())) + "</div>");
} else {
tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + (absClothing.isEnchantmentKnown() ? UtilText.formatAsMoney(absClothing.getValue()) : UtilText.formatAsMoney("?", "b")) + " | " + "<span style='color:" + Colour.TEXT_GREY.toWebHexString() + ";'>" + InventoryDialogue.getInventoryNPC().getName("The") + " will not buy this</span>" + "</div>");
}
} else {
if (InventoryDialogue.isBuyback()) {
tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + (absClothing.isEnchantmentKnown() ? UtilText.formatAsMoney(absClothing.getValue()) : UtilText.formatAsMoney("?", "b")) + " | " + InventoryDialogue.getInventoryNPC().getName("The") + " wants " + UtilText.formatAsMoney(+getBuybackPriceFor(absClothing)) + "</div>");
} else {
tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + (absClothing.isEnchantmentKnown() ? UtilText.formatAsMoney(absClothing.getValue()) : UtilText.formatAsMoney("?", "b")) + " | " + InventoryDialogue.getInventoryNPC().getName("The") + " wants " + UtilText.formatAsMoney(absClothing.getPrice(InventoryDialogue.getInventoryNPC().getSellModifier())) + "</div>");
}
}
} else {
tooltipSB.append("<div class='container-full-width titular'>Value: " + (absClothing.isEnchantmentKnown() ? UtilText.formatAsMoney(absClothing.getValue()) : UtilText.formatAsMoney("?", "b")) + "</div>");
}
tooltipSB.append("</body>");
int specialIncrease = 0;
if (absClothing.getDisplayName(false).length() > 40) {
specialIncrease = 26;
}
Main.mainController.setTooltipSize(360, 392 + (yIncrease * LINE_HEIGHT_TITULAR) + specialIncrease);
Main.mainController.setTooltipContent(UtilText.parse(tooltipSB.toString()));
}
use of com.lilithsthrone.game.character.attributes.Attribute in project liliths-throne-public by Innoxia.
the class GameCharacter method applyEquipClothingEffects.
private void applyEquipClothingEffects(AbstractClothing newClothing) {
incrementBonusAttribute(Attribute.RESISTANCE_PHYSICAL, newClothing.getClothingType().getPhysicalResistance());
for (Entry<Attribute, Integer> e : newClothing.getAttributeModifiers().entrySet()) {
incrementBonusAttribute(e.getKey(), e.getValue());
}
for (ItemEffect ie : newClothing.getEffects()) {
if (ie.getSecondaryModifier() != null && ie.getSecondaryModifier().getFetish() != null) {
Fetish associatedFetish = ie.getSecondaryModifier().getFetish();
switch(ie.getPotency()) {
case MINOR_BOOST:
clothingFetishDesireModifiersMap.putIfAbsent(ie.getSecondaryModifier().getFetish(), 0);
clothingFetishDesireModifiersMap.put(associatedFetish, clothingFetishDesireModifiersMap.get(associatedFetish) + 1);
break;
case BOOST:
clothingFetishDesireModifiersMap.putIfAbsent(associatedFetish, 0);
clothingFetishDesireModifiersMap.put(associatedFetish, clothingFetishDesireModifiersMap.get(associatedFetish) + 2);
break;
case MAJOR_BOOST:
fetishesFromClothing.add(associatedFetish);
applyFetishGainEffects(associatedFetish);
break;
case MINOR_DRAIN:
clothingFetishDesireModifiersMap.putIfAbsent(associatedFetish, 0);
clothingFetishDesireModifiersMap.put(associatedFetish, clothingFetishDesireModifiersMap.get(associatedFetish) - 1);
break;
case DRAIN:
clothingFetishDesireModifiersMap.putIfAbsent(associatedFetish, 0);
clothingFetishDesireModifiersMap.put(associatedFetish, clothingFetishDesireModifiersMap.get(associatedFetish) - 2);
break;
case MAJOR_DRAIN:
clothingFetishDesireModifiersMap.putIfAbsent(associatedFetish, 0);
clothingFetishDesireModifiersMap.put(associatedFetish, clothingFetishDesireModifiersMap.get(associatedFetish) - 999);
break;
}
}
}
}
use of com.lilithsthrone.game.character.attributes.Attribute in project liliths-throne-public by Innoxia.
the class GameCharacter method setHistory.
/**
* Only player character gets job attribute bonuses.
*/
public void setHistory(History history) {
// Revert attributes from old History:
if (this.history.getAssociatedPerk() != null && this.isPlayer()) {
for (Attribute att : this.history.getAssociatedPerk().getAttributeModifiers().keySet()) {
incrementBonusAttribute(att, -this.history.getAssociatedPerk().getAttributeModifiers().get(att));
}
}
this.history.revertExtraEffects(this);
// Implement attributes from new History:
if (history.getAssociatedPerk() != null && this.isPlayer()) {
for (Attribute att : history.getAssociatedPerk().getAttributeModifiers().keySet()) {
incrementBonusAttribute(att, history.getAssociatedPerk().getAttributeModifiers().get(att));
}
}
history.applyExtraEffects(this);
this.history = history;
updateAttributeListeners();
}
use of com.lilithsthrone.game.character.attributes.Attribute in project liliths-throne-public by Innoxia.
the class AbstractClothing method getCoreEnchantment.
public Attribute getCoreEnchantment() {
Attribute att = Attribute.MAJOR_PHYSIQUE;
int max = 0;
for (Entry<Attribute, Integer> entry : getAttributeModifiers().entrySet()) {
if (entry.getValue() > max) {
att = entry.getKey();
max = entry.getValue();
}
}
return att;
}
Aggregations