Search in sources :

Example 6 with Spell

use of com.lilithsthrone.game.combat.Spell in project liliths-throne-public by Innoxia.

the class MainController method manageAttributeListeners.

private void manageAttributeListeners() {
    documentAttributes = (Document) webEngineAttributes.executeScript("document");
    EventListenerDataMap.put(documentAttributes, new ArrayList<>());
    // Map:
    if (((EventTarget) documentAttributes.getElementById("upButton")) != null) {
        addEventListener(documentAttributes, "upButton", "click", moveNorthListener, true);
    }
    if (((EventTarget) documentAttributes.getElementById("downButton")) != null) {
        addEventListener(documentAttributes, "downButton", "click", moveSouthListener, true);
    }
    if (((EventTarget) documentAttributes.getElementById("leftButton")) != null) {
        addEventListener(documentAttributes, "leftButton", "click", moveWestListener, true);
    }
    if (((EventTarget) documentAttributes.getElementById("rightButton")) != null) {
        addEventListener(documentAttributes, "rightButton", "click", moveEastListener, true);
    }
    // Inventory:
    // For all equipped clothing slots:
    String id;
    for (InventorySlot invSlot : InventorySlot.values()) {
        id = invSlot.toString() + "Slot";
        if (invSlot != InventorySlot.WEAPON_MAIN && invSlot != InventorySlot.WEAPON_OFFHAND) {
            if (((EventTarget) documentAttributes.getElementById(id)) != null) {
                InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setClothingEquipped(Main.game.getPlayer(), invSlot);
                addEventListener(documentAttributes, id, "click", el, false);
                addEventListener(documentAttributes, id, "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, id, "mouseleave", hideTooltipListener, false);
                InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setInventorySlot(invSlot, Main.game.getPlayer());
                addEventListener(documentAttributes, id, "mouseenter", el2, false);
            }
        } else {
            if (((EventTarget) documentAttributes.getElementById(id)) != null) {
                InventorySelectedItemEventListener el = new InventorySelectedItemEventListener().setWeaponEquipped(Main.game.getPlayer(), invSlot);
                addEventListener(documentAttributes, id, "click", el, false);
                addEventListener(documentAttributes, id, "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, id, "mouseleave", hideTooltipListener, false);
                InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setInventorySlot(invSlot, Main.game.getPlayer());
                addEventListener(documentAttributes, id, "mouseenter", el2, false);
            }
        }
    }
    id = "DATE_DISPLAY_TOGGLE";
    if (((EventTarget) documentAttributes.getElementById(id)) != null) {
        ((EventTarget) documentAttributes.getElementById(id)).addEventListener("click", e -> {
            Main.getProperties().calendarDisplay = !Main.getProperties().calendarDisplay;
            Main.saveProperties();
            this.updateUI();
        }, false);
        addEventListener(documentAttributes, id, "mousemove", moveTooltipListener, false);
        addEventListener(documentAttributes, id, "mouseleave", hideTooltipListener, false);
        TooltipInformationEventListener el2 = new TooltipInformationEventListener().setInformation("Toggle Calendar Display", "Toggle the date's display between a calendar and day count.");
        addEventListener(documentAttributes, id, "mouseenter", el2, false);
    }
    id = "TWENTY_FOUR_HOUR_TIME_TOGGLE";
    if (((EventTarget) documentAttributes.getElementById(id)) != null) {
        ((EventTarget) documentAttributes.getElementById(id)).addEventListener("click", e -> {
            Main.getProperties().twentyFourHourTime = !Main.getProperties().twentyFourHourTime;
            Main.saveProperties();
            this.updateUI();
        }, false);
        addEventListener(documentAttributes, id, "mousemove", moveTooltipListener, false);
        addEventListener(documentAttributes, id, "mouseleave", hideTooltipListener, false);
        TooltipInformationEventListener el2 = new TooltipInformationEventListener().setInformation("Toggle Time Display", "Toggle the display of time between a 24 and 12-hour clock.");
        addEventListener(documentAttributes, id, "mouseenter", el2, false);
    }
    if (((EventTarget) documentAttributes.getElementById("ESSENCE_" + TFEssence.ARCANE.hashCode())) != null) {
        addEventListener(documentAttributes, "ESSENCE_" + TFEssence.ARCANE.hashCode(), "mousemove", moveTooltipListener, false);
        addEventListener(documentAttributes, "ESSENCE_" + TFEssence.ARCANE.hashCode(), "mouseleave", hideTooltipListener, false);
        InventoryTooltipEventListener el2 = new InventoryTooltipEventListener().setEssence(TFEssence.ARCANE);
        addEventListener(documentAttributes, "ESSENCE_" + TFEssence.ARCANE.hashCode(), "mouseenter", el2, false);
    }
    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.add(Main.game.getPlayer());
        charactersBeingRendered.addAll(Combat.getAllies());
    } else {
        if (Main.game.getPlayer() != null) {
            charactersBeingRendered.add(Main.game.getPlayer());
        }
    }
    for (GameCharacter character : charactersBeingRendered) {
        String idModifier = (character.isPlayer() ? "PLAYER_" : "NPC_" + character.getId() + "_");
        for (Attribute a : attributes) {
            if (((EventTarget) documentAttributes.getElementById(idModifier + a.getName())) != null) {
                if (a == Attribute.EXPERIENCE) {
                    ((EventTarget) documentAttributes.getElementById(idModifier + a.getName())).addEventListener("click", e -> {
                        if (character.isPlayer()) {
                            // block when in character creation
                            if (Main.game.isInNewWorld()) {
                                if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.PHONE) {
                                    if (Main.game.getCurrentDialogueNode() == PhoneDialogue.CHARACTER_APPEARANCE) {
                                        openPhone();
                                    } else {
                                        Main.game.setContent(new Response("", "", PhoneDialogue.CHARACTER_APPEARANCE));
                                    }
                                } else if (!Main.game.getCurrentDialogueNode().isOptionsDisabled()) {
                                    if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.NORMAL) {
                                        Main.game.saveDialogueNode();
                                    }
                                    Main.game.setContent(new Response("", "", PhoneDialogue.CHARACTER_APPEARANCE));
                                }
                            }
                        } else {
                            openCharactersPresent(Main.game.getNPCById(Main.game.getActiveNPC().getId()));
                        }
                    }, false);
                }
                addEventListener(documentAttributes, idModifier + a.getName(), "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, idModifier + a.getName(), "mouseleave", hideTooltipListener, false);
                TooltipInformationEventListener el = new TooltipInformationEventListener().setAttribute(a, character);
                addEventListener(documentAttributes, idModifier + a.getName(), "mouseenter", el, false);
            }
        }
        if (((EventTarget) documentAttributes.getElementById(idModifier + "ATTRIBUTES")) != null) {
            ((EventTarget) documentAttributes.getElementById(idModifier + "ATTRIBUTES")).addEventListener("click", e -> {
                if (character.isPlayer()) {
                    // block when in character creation
                    if (Main.game.isInNewWorld()) {
                        if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.PHONE) {
                            if (Main.game.getCurrentDialogueNode() == PhoneDialogue.CHARACTER_LEVEL_UP) {
                                openPhone();
                            } else {
                                Main.game.setContent(new Response("", "", PhoneDialogue.CHARACTER_LEVEL_UP));
                            }
                        } else if (!Main.game.getCurrentDialogueNode().isOptionsDisabled()) {
                            if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.NORMAL) {
                                Main.game.saveDialogueNode();
                            }
                            Main.game.setContent(new Response("", "", PhoneDialogue.CHARACTER_LEVEL_UP));
                        }
                    }
                } else {
                    // TODO display NPC perk tree
                    openCharactersPresent(Main.game.getNPCById(Main.game.getActiveNPC().getId()));
                }
            }, false);
            addEventListener(documentAttributes, idModifier + "ATTRIBUTES", "mousemove", moveTooltipListener, false);
            addEventListener(documentAttributes, idModifier + "ATTRIBUTES", "mouseleave", hideTooltipListener, false);
            TooltipInformationEventListener el = new TooltipInformationEventListener().setExtraAttributes(character);
            addEventListener(documentAttributes, idModifier + "ATTRIBUTES", "mouseenter", el, false);
        }
        // For status effect slots:
        for (StatusEffect se : character.getStatusEffects()) {
            if (((EventTarget) documentAttributes.getElementById("SE_" + idModifier + se)) != null) {
                addEventListener(documentAttributes, "SE_" + idModifier + se, "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, "SE_" + idModifier + se, "mouseleave", hideTooltipListener, false);
                TooltipInformationEventListener el = new TooltipInformationEventListener().setStatusEffect(se, character);
                addEventListener(documentAttributes, "SE_" + idModifier + se, "mouseenter", el, false);
            }
        }
        for (Perk trait : character.getTraits()) {
            id = "TRAIT_" + idModifier + trait;
            if (((EventTarget) documentAttributes.getElementById(id)) != null) {
                addEventListener(documentAttributes, id, "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, id, "mouseleave", hideTooltipListener, false);
                TooltipInformationEventListener el = new TooltipInformationEventListener().setPerk(trait, character);
                addEventListener(documentAttributes, id, "mouseenter", el, false);
            }
        }
        for (Fetish f : character.getFetishes()) {
            if (((EventTarget) documentAttributes.getElementById("FETISH_" + idModifier + f)) != null) {
                addEventListener(documentAttributes, "FETISH_" + idModifier + f, "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, "FETISH_" + idModifier + f, "mouseleave", hideTooltipListener, false);
                TooltipInformationEventListener el = new TooltipInformationEventListener().setFetish(f, character);
                addEventListener(documentAttributes, "FETISH_" + idModifier + f, "mouseenter", el, false);
            }
        }
        for (SpecialAttack sa : character.getSpecialAttacks()) {
            if (((EventTarget) documentAttributes.getElementById("SA_" + idModifier + sa)) != null) {
                addEventListener(documentAttributes, "SA_" + idModifier + sa, "mousemove", moveTooltipListener, false);
                addEventListener(documentAttributes, "SA_" + idModifier + sa, "mouseleave", hideTooltipListener, false);
                TooltipInformationEventListener el = new TooltipInformationEventListener().setSpecialAttack(sa, character);
                addEventListener(documentAttributes, "SA_" + 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);
            }
        }
    }
}
Also used : TooltipInformationEventListener(com.lilithsthrone.controller.eventListeners.TooltipInformationEventListener) Attribute(com.lilithsthrone.game.character.attributes.Attribute) InventorySlot(com.lilithsthrone.game.inventory.InventorySlot) ArrayList(java.util.ArrayList) Perk(com.lilithsthrone.game.character.effects.Perk) Spell(com.lilithsthrone.game.combat.Spell) InventorySelectedItemEventListener(com.lilithsthrone.controller.eventListeners.InventorySelectedItemEventListener) Response(com.lilithsthrone.game.dialogue.responses.Response) Fetish(com.lilithsthrone.game.character.fetishes.Fetish) StatusEffect(com.lilithsthrone.game.character.effects.StatusEffect) InventoryTooltipEventListener(com.lilithsthrone.controller.eventListeners.InventoryTooltipEventListener) GameCharacter(com.lilithsthrone.game.character.GameCharacter) SpecialAttack(com.lilithsthrone.game.combat.SpecialAttack) EventTarget(org.w3c.dom.events.EventTarget)

Example 7 with Spell

use of com.lilithsthrone.game.combat.Spell in project liliths-throne-public by Innoxia.

the class InventoryTooltipEventListener method weaponTooltip.

private void weaponTooltip(AbstractWeapon absWep) {
    int yIncrease = 0;
    int listIncrease = absWep.getAttributeModifiers().size();
    listIncrease += absWep.getSpells().size();
    yIncrease += Math.max(0, listIncrease - 3);
    // Title:
    tooltipSB.setLength(0);
    tooltipSB.append("<body>" + "<div class='container-full-width center'><h5>" + Util.capitaliseSentence(absWep.getDisplayName(true)) + "</h5></div>");
    // Core info:
    tooltipSB.append("<div class='container-half-width titular' style='color:" + absWep.getDamageType().getMultiplierAttribute().getColour().toWebHexString() + ";'>" + Util.capitaliseSentence(absWep.getDamageType().getName()) + " damage</div>");
    tooltipSB.append("<div class='container-half-width titular'>" + (absWep.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? "Primary Slot" : "Secondary Slot") + "</div>");
    // Attribute modifiers:
    tooltipSB.append("<div class='container-full-width'>" + "<div class='container-half-width titular' style='width:calc(66.6% - 16px);'>");
    if (equippedToCharacter != null) {
        tooltipSB.append("<b>" + Attack.getMinimumDamage(owner, null, absWep.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? Attack.MAIN : Attack.OFFHAND, absWep) + " - " + Attack.getMaximumDamage(owner, null, absWep.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? Attack.MAIN : Attack.OFFHAND, absWep) + "</b>" + " <b style='color:" + absWep.getDamageType().getMultiplierAttribute().getColour().toWebHexString() + ";'>Damage</b>");
    } else {
        tooltipSB.append("<b>" + Attack.getMinimumDamage(Main.game.getPlayer(), null, absWep.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? Attack.MAIN : Attack.OFFHAND, absWep) + " - " + Attack.getMaximumDamage(Main.game.getPlayer(), null, absWep.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? Attack.MAIN : Attack.OFFHAND, absWep) + "</b>" + " <b style='color:" + absWep.getDamageType().getMultiplierAttribute().getColour().toWebHexString() + ";'>Damage</b>");
    }
    // Spell school:
    tooltipSB.append("</br>" + "<b>" + (absWep.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? "Offensive" : "Defensive") + "</b>" + " <b style='color:" + absWep.getSpellSchool().getColour().toWebHexString() + ";'>" + Util.capitaliseSentence(absWep.getSpellSchool().getName()) + "</b>" + " <b>spells</b>");
    // }
    for (Entry<Attribute, Integer> entry : absWep.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>");
    }
    for (Spell s : absWep.getSpells()) {
        tooltipSB.append("</br><b style='color:" + Colour.DAMAGE_TYPE_SPELL.toWebHexString() + ";'>Grants Spell</b><b>:</b> <b style='color:" + s.getSpellSchool().getColour().toWebHexString() + ";'>" + Util.capitaliseSentence(s.getName()) + "</b>");
    }
    tooltipSB.append("</div>");
    // Picture:
    tooltipSB.append("<div class='container-half-width' style='width:calc(33.3% - 16px);'>" + absWep.getSVGString() + "</div>");
    tooltipSB.append("</div>");
    tooltipSB.append("<div class='container-full-width' style='padding:8px; height:106px;'>" + absWep.getWeaponType().getDescription() + "</div>");
    if (InventoryDialogue.getInventoryNPC() != null && InventoryDialogue.getNPCInventoryInteraction() == InventoryInteraction.TRADING) {
        if (owner.isPlayer()) {
            if (InventoryDialogue.getInventoryNPC().willBuy(absWep)) {
                tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + UtilText.formatAsMoney(absWep.getValue()) + " | " + InventoryDialogue.getInventoryNPC().getName("The") + " offers: " + UtilText.formatAsMoney(absWep.getPrice(InventoryDialogue.getInventoryNPC().getBuyModifier())) + "</div>");
            } else {
                tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + UtilText.formatAsMoney(absWep.getValue()) + " | " + "<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: " + UtilText.formatAsMoney(absWep.getValue()) + " | " + InventoryDialogue.getInventoryNPC().getName("The") + " wants " + UtilText.formatAsMoney(+getBuybackPriceFor(absWep)) + "</div>");
            } else {
                tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + UtilText.formatAsMoney(absWep.getValue()) + " | " + InventoryDialogue.getInventoryNPC().getName("The") + " wants " + UtilText.formatAsMoney(absWep.getPrice(InventoryDialogue.getInventoryNPC().getSellModifier())) + "</div>");
            }
        }
    } else {
        tooltipSB.append("<div class='container-full-width titular'>" + "Value: " + UtilText.formatAsMoney(absWep.getValue()) + "</div>");
    }
    tooltipSB.append("</body>");
    Main.mainController.setTooltipSize(360, 356 + (yIncrease * LINE_HEIGHT_TITULAR));
    Main.mainController.setTooltipContent(UtilText.parse(tooltipSB.toString()));
}
Also used : Attribute(com.lilithsthrone.game.character.attributes.Attribute) Spell(com.lilithsthrone.game.combat.Spell)

Aggregations

Spell (com.lilithsthrone.game.combat.Spell)7 Attribute (com.lilithsthrone.game.character.attributes.Attribute)5 ArrayList (java.util.ArrayList)4 InventorySelectedItemEventListener (com.lilithsthrone.controller.eventListeners.InventorySelectedItemEventListener)2 InventoryTooltipEventListener (com.lilithsthrone.controller.eventListeners.InventoryTooltipEventListener)2 TooltipInformationEventListener (com.lilithsthrone.controller.eventListeners.TooltipInformationEventListener)2 GameCharacter (com.lilithsthrone.game.character.GameCharacter)2 Perk (com.lilithsthrone.game.character.effects.Perk)2 StatusEffect (com.lilithsthrone.game.character.effects.StatusEffect)2 Fetish (com.lilithsthrone.game.character.fetishes.Fetish)2 SpecialAttack (com.lilithsthrone.game.combat.SpecialAttack)2 SpellSchool (com.lilithsthrone.game.combat.SpellSchool)2 InventorySlot (com.lilithsthrone.game.inventory.InventorySlot)2 EventTarget (org.w3c.dom.events.EventTarget)2 NPC (com.lilithsthrone.game.character.npc.NPC)1 TestNPC (com.lilithsthrone.game.character.npc.dominion.TestNPC)1 Response (com.lilithsthrone.game.dialogue.responses.Response)1 AbstractClothing (com.lilithsthrone.game.inventory.clothing.AbstractClothing)1 AbstractItem (com.lilithsthrone.game.inventory.item.AbstractItem)1 AbstractWeapon (com.lilithsthrone.game.inventory.weapon.AbstractWeapon)1