use of com.lilithsthrone.game.combat.SpecialAttack 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.combat.SpecialAttack 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);
}
}
}
}
Aggregations