Search in sources :

Example 1 with Spell

use of com.lilithsthrone.game.combat.Spell 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);
                }
            }
        }
    }
}
Also used : TooltipInformationEventListener(com.lilithsthrone.controller.eventListeners.TooltipInformationEventListener) TestNPC(com.lilithsthrone.game.character.npc.dominion.TestNPC) NPC(com.lilithsthrone.game.character.npc.NPC) Attribute(com.lilithsthrone.game.character.attributes.Attribute) ArrayList(java.util.ArrayList) Spell(com.lilithsthrone.game.combat.Spell) InventorySelectedItemEventListener(com.lilithsthrone.controller.eventListeners.InventorySelectedItemEventListener) Fetish(com.lilithsthrone.game.character.fetishes.Fetish) InventoryTooltipEventListener(com.lilithsthrone.controller.eventListeners.InventoryTooltipEventListener) GameCharacter(com.lilithsthrone.game.character.GameCharacter) SpecialAttack(com.lilithsthrone.game.combat.SpecialAttack) AbstractWeapon(com.lilithsthrone.game.inventory.weapon.AbstractWeapon) EventTarget(org.w3c.dom.events.EventTarget) InventorySlot(com.lilithsthrone.game.inventory.InventorySlot) AbstractClothing(com.lilithsthrone.game.inventory.clothing.AbstractClothing) AbstractItem(com.lilithsthrone.game.inventory.item.AbstractItem) Perk(com.lilithsthrone.game.character.effects.Perk) StatusEffect(com.lilithsthrone.game.character.effects.StatusEffect)

Example 2 with Spell

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

the class AbstractWeapon method getDescription.

public String getDescription() {
    descriptionSB = new StringBuilder();
    descriptionSB.append("<p>" + "<b>" + Attack.getMinimumDamage(Main.game.getPlayer(), null, this.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? Attack.MAIN : Attack.OFFHAND, this) + "-" + Attack.getMaximumDamage(Main.game.getPlayer(), null, this.getWeaponType().getSlot() == InventorySlot.WEAPON_MAIN ? Attack.MAIN : Attack.OFFHAND, this) + "</b>" + " <b style='color:" + damageType.getMultiplierAttribute().getColour().toWebHexString() + ";'>" + damageType.getName() + "</b>" + " damage" + "</p>" + "<p>" + weaponType.getDescription() + "</p>");
    if (!attributeModifiers.isEmpty()) {
        descriptionSB.append("<p>It provides ");
        int i = 0;
        for (Entry<Attribute, Integer> e : attributeModifiers.entrySet()) {
            if (i != 0) {
                if (i + 1 == attributeModifiers.size())
                    descriptionSB.append(" and ");
                else
                    descriptionSB.append(", ");
            }
            descriptionSB.append(" <b>" + e.getValue() + "</b> <b style='color: " + e.getKey().getColour().toWebHexString() + ";'> " + e.getKey().getName() + "</b>");
            i++;
        }
        descriptionSB.append(".</p>");
    }
    if (!spells.isEmpty()) {
        descriptionSB.append("<p>Its arcane power grants you the ability to cast ");
        int i = 0;
        for (Spell s : spells) {
            if (i != 0) {
                if (i + 1 == spells.size())
                    descriptionSB.append(" and ");
                else
                    descriptionSB.append(", ");
            }
            descriptionSB.append("<b style='color:" + s.getDamageType().getMultiplierAttribute().getColour().toWebHexString() + ";'>" + Util.capitaliseSentence(s.getName()) + "</b>");
            i++;
        }
        descriptionSB.append(".</p>");
    }
    descriptionSB.append("<p>It has a value of " + UtilText.formatAsMoney(getValue()) + ".</p>");
    return descriptionSB.toString();
}
Also used : Attribute(com.lilithsthrone.game.character.attributes.Attribute) Spell(com.lilithsthrone.game.combat.Spell)

Example 3 with Spell

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

the class GameCharacter method getOffensiveSpells.

/**
 * Base spells, modified by primary weapon SpellSchool.
 */
public List<Spell> getOffensiveSpells() {
    SpellSchool school = SpellSchool.DEFAULT;
    if (getMainWeapon() != null) {
        school = getMainWeapon().getSpellSchool();
    }
    List<Spell> tempListSpells = new ArrayList<>();
    for (Spell s : Spell.getSpellsFromSchoolMap().get(school)) {
        if (s.getType() == SpellType.OFFENSIVE) {
            tempListSpells.add(s);
        }
    }
    return tempListSpells;
}
Also used : SpellSchool(com.lilithsthrone.game.combat.SpellSchool) ArrayList(java.util.ArrayList) Spell(com.lilithsthrone.game.combat.Spell)

Example 4 with Spell

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

the class GameCharacter method getDefensiveSpells.

/**
 * Base spells, modified by secondary weapon SpellSchool.
 */
public List<Spell> getDefensiveSpells() {
    SpellSchool school = SpellSchool.DEFAULT;
    if (getOffhandWeapon() != null) {
        school = getOffhandWeapon().getSpellSchool();
    }
    List<Spell> tempListSpells = new ArrayList<>();
    for (Spell s : Spell.getSpellsFromSchoolMap().get(school)) {
        if (s.getType() == SpellType.DEFENSIVE) {
            tempListSpells.add(s);
        }
    }
    return tempListSpells;
}
Also used : SpellSchool(com.lilithsthrone.game.combat.SpellSchool) ArrayList(java.util.ArrayList) Spell(com.lilithsthrone.game.combat.Spell)

Example 5 with Spell

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

the class AbstractWeapon method saveAsXML.

public Element saveAsXML(Element parentElement, Document doc) {
    Element element = doc.createElement("weapon");
    parentElement.appendChild(element);
    CharacterUtils.addAttribute(doc, element, "id", this.getWeaponType().getId());
    CharacterUtils.addAttribute(doc, element, "damageType", this.getDamageType().toString());
    CharacterUtils.addAttribute(doc, element, "coreEnchantment", (this.getCoreEnchantment() == null ? "null" : this.getCoreEnchantment().toString()));
    Element attributeElement = doc.createElement("attributeModifiers");
    element.appendChild(attributeElement);
    for (Entry<Attribute, Integer> entry : this.getAttributeModifiers().entrySet()) {
        Element modifier = doc.createElement("modifier");
        attributeElement.appendChild(modifier);
        CharacterUtils.addAttribute(doc, modifier, "attribute", entry.getKey().toString());
        CharacterUtils.addAttribute(doc, modifier, "value", String.valueOf(entry.getValue()));
    }
    Element innerElement = doc.createElement("spells");
    element.appendChild(innerElement);
    for (Spell s : this.getSpells()) {
        Element spell = doc.createElement("spell");
        innerElement.appendChild(spell);
        CharacterUtils.addAttribute(doc, spell, "value", s.toString());
    }
    return element;
}
Also used : Attribute(com.lilithsthrone.game.character.attributes.Attribute) Element(org.w3c.dom.Element) 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