Search in sources :

Example 1 with SlaveEventTag

use of com.lilithsthrone.game.slavery.SlaveEventTag in project liliths-throne-public by Innoxia.

the class SlaveryEventLogEntry method getDescription.

public String getDescription() {
    descriptionSB.setLength(0);
    descriptionSB.append(event.getDescription());
    if (tags != null) {
        for (SlaveEventTag tag : tags) {
            if (descriptionSB.length() > 0) {
                descriptionSB.append("</br>");
            }
            descriptionSB.append(tag.getDescription());
        }
    }
    if (extraEffects != null) {
        for (String s : extraEffects) {
            if (descriptionSB.length() > 0) {
                descriptionSB.append("</br>");
            }
            descriptionSB.append(s);
        }
    }
    GameCharacter slave = Main.game.getNPCById(slaveID);
    if (slave != null) {
        return UtilText.parse(Main.game.getNPCById(slaveID), descriptionSB.toString());
    } else {
        return descriptionSB.toString();
    }
}
Also used : GameCharacter(com.lilithsthrone.game.character.GameCharacter) SlaveEventTag(com.lilithsthrone.game.slavery.SlaveEventTag)

Example 2 with SlaveEventTag

use of com.lilithsthrone.game.slavery.SlaveEventTag in project liliths-throne-public by Innoxia.

the class SlaveryEventLogEntry method loadFromXML.

public static SlaveryEventLogEntry loadFromXML(Element parentElement, Document doc) {
    List<SlaveEventTag> loadedTags = null;
    NodeList nodes = parentElement.getElementsByTagName("tags");
    Element tagNode = (Element) nodes.item(0);
    if (tagNode != null) {
        loadedTags = new ArrayList<>();
        for (int i = 0; i < tagNode.getElementsByTagName("tag").getLength(); i++) {
            Element e = ((Element) tagNode.getElementsByTagName("tag").item(i));
            try {
                loadedTags.add(SlaveEventTag.valueOf(e.getAttribute("value")));
            } catch (IllegalArgumentException ex) {
            }
        }
    }
    List<String> loadedExtraEffects = null;
    nodes = parentElement.getElementsByTagName("extraEffects");
    Element extraEffectNode = (Element) nodes.item(0);
    if (extraEffectNode != null) {
        loadedExtraEffects = new ArrayList<>();
        for (int i = 0; i < extraEffectNode.getElementsByTagName("entry").getLength(); i++) {
            Element e = ((Element) extraEffectNode.getElementsByTagName("entry").item(i));
            try {
                loadedExtraEffects.add(e.getAttribute("value"));
            } catch (IllegalArgumentException ex) {
            }
        }
    }
    return new SlaveryEventLogEntry(Long.valueOf(parentElement.getAttribute("time")), parentElement.getAttribute("slaveID"), SlaveEvent.valueOf(parentElement.getAttribute("event")), loadedTags, loadedExtraEffects);
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) SlaveEventTag(com.lilithsthrone.game.slavery.SlaveEventTag)

Example 3 with SlaveEventTag

use of com.lilithsthrone.game.slavery.SlaveEventTag in project liliths-throne-public by Innoxia.

the class SlaveryEventLogEntry method saveAsXML.

public Element saveAsXML(Element parentElement, Document doc) {
    Element element = doc.createElement("eventLogEntry");
    parentElement.appendChild(element);
    CharacterUtils.addAttribute(doc, element, "time", String.valueOf(time));
    CharacterUtils.addAttribute(doc, element, "slaveID", slaveID);
    CharacterUtils.addAttribute(doc, element, "event", event.toString());
    if (tags != null) {
        Element tagsNode = doc.createElement("tags");
        element.appendChild(tagsNode);
        for (SlaveEventTag tag : tags) {
            Element tagDataNode = doc.createElement("tag");
            tagsNode.appendChild(tagDataNode);
            CharacterUtils.addAttribute(doc, tagDataNode, "value", String.valueOf(tag));
        }
    }
    if (extraEffects != null) {
        Element extraEffectsNode = doc.createElement("extraEffects");
        element.appendChild(extraEffectsNode);
        for (String s : extraEffects) {
            Element extraEffectsDataNode = doc.createElement("entry");
            extraEffectsNode.appendChild(extraEffectsDataNode);
            CharacterUtils.addAttribute(doc, extraEffectsDataNode, "value", s);
        }
    }
    return element;
}
Also used : Element(org.w3c.dom.Element) SlaveEventTag(com.lilithsthrone.game.slavery.SlaveEventTag)

Aggregations

SlaveEventTag (com.lilithsthrone.game.slavery.SlaveEventTag)3 Element (org.w3c.dom.Element)2 GameCharacter (com.lilithsthrone.game.character.GameCharacter)1 NodeList (org.w3c.dom.NodeList)1