Search in sources :

Example 1 with WorldType

use of com.lilithsthrone.world.WorldType in project liliths-throne-public by Innoxia.

the class Game method importGame.

public static void importGame(String name) {
    Game newGame = new Game();
    Main.game = newGame;
    File file = new File("data/saves/" + name + ".xml");
    if (file.exists()) {
        try {
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(file);
            // Cast magic:
            doc.getDocumentElement().normalize();
            Element gameElement = (Element) doc.getElementsByTagName("game").item(0);
            Element informationNode = (Element) gameElement.getElementsByTagName("coreInfo").item(0);
            String version = informationNode.getAttribute("version");
            newGame.minutesPassed = Long.valueOf(informationNode.getAttribute("minutesPassed"));
            newGame.debugMode = Boolean.valueOf(informationNode.getAttribute("debugMode"));
            newGame.imperialMeasurements = Boolean.valueOf(informationNode.getAttribute("imperialMeasurements"));
            newGame.currentWeather = Weather.valueOf(informationNode.getAttribute("weather"));
            newGame.nextStormTime = Long.valueOf(informationNode.getAttribute("nextStormTime"));
            newGame.weatherTimeRemaining = Integer.valueOf(informationNode.getAttribute("weatherTimeRemaining"));
            Element dateNode = (Element) gameElement.getElementsByTagName("date").item(0);
            newGame.startingDate = LocalDateTime.of(Integer.valueOf(dateNode.getAttribute("year")), Integer.valueOf(dateNode.getAttribute("month")), Integer.valueOf(dateNode.getAttribute("dayOfMonth")), Integer.valueOf(dateNode.getAttribute("hour")), Integer.valueOf(dateNode.getAttribute("minute")));
            newGame.dialogueFlags = DialogueFlags.loadFromXML((Element) gameElement.getElementsByTagName("dialogueFlags").item(0), doc);
            for (int i = 0; i < ((Element) gameElement.getElementsByTagName("eventLog").item(0)).getElementsByTagName("eventLogEntry").getLength(); i++) {
                Element e = (Element) ((Element) gameElement.getElementsByTagName("eventLog").item(0)).getElementsByTagName("eventLogEntry").item(i);
                newGame.eventLog.add(EventLogEntry.loadFromXML(e, doc));
            }
            newGame.eventLog.sort(Comparator.comparingLong(EventLogEntry::getTime));
            NodeList nodes = gameElement.getElementsByTagName("slaveryEventLog");
            Element extraEffectNode = (Element) nodes.item(0);
            if (extraEffectNode != null) {
                for (int i = 0; i < extraEffectNode.getElementsByTagName("day").getLength(); i++) {
                    Element e = (Element) gameElement.getElementsByTagName("day").item(i);
                    int day = Integer.valueOf(e.getAttribute("value"));
                    newGame.slaveryEventLog.put(day, new ArrayList<>());
                    for (int j = 0; j < e.getElementsByTagName("eventLogEntry").getLength(); j++) {
                        Element entry = (Element) e.getElementsByTagName("eventLogEntry").item(j);
                        newGame.slaveryEventLog.get(day).add(SlaveryEventLogEntry.loadFromXML(entry, doc));
                    }
                }
            }
            // Maps:
            for (int i = 0; i < ((Element) gameElement.getElementsByTagName("maps").item(0)).getElementsByTagName("world").getLength(); i++) {
                Element e = (Element) ((Element) gameElement.getElementsByTagName("maps").item(0)).getElementsByTagName("world").item(i);
                if ((!e.getAttribute("worldType").equals("SEWERS") || !Main.isVersionOlderThan(version, "0.2.0.5")) && (!e.getAttribute("worldType").equals("SUBMISSION") || !Main.isVersionOlderThan(version, "0.2.1.5")) && (!e.getAttribute("worldType").equals("DOMINION") || !Main.isVersionOlderThan(version, "0.2.1.5")) && (!e.getAttribute("worldType").equals("HARPY_NEST") || !Main.isVersionOlderThan(version, "0.2.1.5"))) {
                    World world = World.loadFromXML(e, doc);
                    newGame.worlds.put(world.getWorldType(), world);
                }
            }
            // Add missing world types:
            for (WorldType wt : WorldType.values()) {
                Generation gen = new Generation();
                if (Main.isVersionOlderThan(version, "0.1.99.5")) {
                    gen.worldGeneration(WorldType.SHOPPING_ARCADE);
                }
                if (Main.isVersionOlderThan(version, "0.2.1.5")) {
                    gen.worldGeneration(WorldType.SUBMISSION);
                    gen.worldGeneration(WorldType.DOMINION);
                    gen.worldGeneration(WorldType.HARPY_NEST);
                }
                if (newGame.worlds.get(wt) == null) {
                    gen.worldGeneration(wt);
                }
            }
            newGame.player = PlayerCharacter.loadFromXML(null, (Element) ((Element) gameElement.getElementsByTagName("playerCharacter").item(0)), doc);
            List<String> addedIds = new ArrayList<>();
            List<NPC> slaveImports = new ArrayList<>();
            // Load NPCs:
            for (int i = 0; i < gameElement.getElementsByTagName("NPC").getLength(); i++) {
                Element e = (Element) gameElement.getElementsByTagName("NPC").item(i);
                if (!addedIds.contains(((Element) e.getElementsByTagName("id").item(0)).getAttribute("value"))) {
                    @SuppressWarnings("unchecked") Class<? extends NPC> npcClass = (Class<? extends NPC>) Class.forName(((Element) e.getElementsByTagName("pathName").item(0)).getAttribute("value"));
                    Method m = npcClass.getMethod("loadFromXML", Element.class, Document.class, CharacterImportSetting[].class);
                    NPC npc = npcClass.getDeclaredConstructor(boolean.class).newInstance(true);
                    m.invoke(npc, e, doc, new CharacterImportSetting[] {});
                    newGame.addNPC(npc, true);
                    addedIds.add(npc.getId());
                    // To fix issues with older versions hair length:
                    if (Main.isVersionOlderThan(version, "0.1.90.5")) {
                        npc.getBody().getHair().setLength(null, npc.isFeminine() ? RacialBody.valueOfRace(npc.getRace()).getFemaleHairLength() : RacialBody.valueOfRace(npc.getRace()).getMaleHairLength());
                    }
                    // Generate desires in non-unique NPCs:
                    if (Main.isVersionOlderThan(version, "0.1.98.5") && !npc.isUnique() && npc.getFetishDesireMap().isEmpty()) {
                        CharacterUtils.generateDesires(npc);
                    }
                    if (Main.isVersionOlderThan(version, "0.2.0") && npc.getFetishDesireMap().size() > 10) {
                        npc.clearFetishDesires();
                        CharacterUtils.generateDesires(npc);
                    }
                    if (npc instanceof SlaveImport) {
                        slaveImports.add(npc);
                    }
                } else {
                    System.err.println("duplicate character attempted to be imported");
                }
            }
            // Add in new NPCS:
            if (!newGame.NPCMap.containsKey(newGame.getUniqueNPCId(Zaranix.class))) {
                Zaranix zaranix = new Zaranix();
                newGame.addNPC(zaranix, false);
                ZaranixMaidKatherine katherine = new ZaranixMaidKatherine();
                newGame.addNPC(katherine, false);
                ZaranixMaidKelly kelly = new ZaranixMaidKelly();
                newGame.addNPC(kelly, false);
                Amber amber = new Amber();
                newGame.addNPC(amber, false);
                zaranix.setAffection(katherine, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                zaranix.setAffection(kelly, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                zaranix.setAffection(amber, AffectionLevel.POSITIVE_FOUR_LOVE.getMedianValue());
                amber.setAffection(zaranix, AffectionLevel.POSITIVE_FOUR_LOVE.getMedianValue());
                amber.setAffection(kelly, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                amber.setAffection(katherine, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                kelly.setAffection(zaranix, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                kelly.setAffection(katherine, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                kelly.setAffection(amber, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                katherine.setAffection(zaranix, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                katherine.setAffection(kelly, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                katherine.setAffection(amber, AffectionLevel.POSITIVE_THREE_CARING.getMedianValue());
                newGame.addNPC(new Arthur(), false);
            }
            if (!newGame.NPCMap.containsKey(newGame.getUniqueNPCId(Ashley.class))) {
                newGame.addNPC(new Ashley(), false);
            }
            if (!newGame.NPCMap.containsKey(newGame.getUniqueNPCId(SupplierLeader.class))) {
                newGame.addNPC(new SupplierLeader(), false);
            }
            if (!newGame.NPCMap.containsKey(newGame.getUniqueNPCId(SupplierPartner.class))) {
                newGame.addNPC(new SupplierPartner(), false);
            }
            // To prevent errors from previous versions, reset Zaranix progress if prior to 0.1.95:
            if (Main.isVersionOlderThan(version, "0.1.90.5")) {
                if (Main.game.getPlayer().getWorldLocation() == WorldType.ZARANIX_HOUSE_GROUND_FLOOR || Main.game.getPlayer().getWorldLocation() == WorldType.ZARANIX_HOUSE_FIRST_FLOOR) {
                    Main.game.getPlayer().setLocation(WorldType.DOMINION, PlaceType.DOMINION_DEMON_HOME, false);
                    ZaranixHomeGroundFloor.resetHouseAfterLeaving();
                    Main.game.getDialogueFlags().setFlag(DialogueFlagValue.zaranixDiscoveredHome, false);
                    Main.game.getDialogueFlags().setFlag(DialogueFlagValue.zaranixKickedDownDoor, false);
                    Main.game.getDialogueFlags().setFlag(DialogueFlagValue.zaranixKnockedOnDoor, false);
                    Main.game.getDialogueFlags().setFlag(DialogueFlagValue.zaranixMaidsHostile, false);
                    Main.game.getArthur().setLocation(WorldType.ZARANIX_HOUSE_FIRST_FLOOR, PlaceType.ZARANIX_FF_OFFICE, true);
                    if (Main.game.getPlayer().isQuestProgressGreaterThan(QuestLine.MAIN, Quest.MAIN_1_H_THE_GREAT_ESCAPE)) {
                        Main.game.getPlayer().setQuestProgress(QuestLine.MAIN, Quest.MAIN_1_H_THE_GREAT_ESCAPE);
                    }
                }
            }
            if (Main.isVersionOlderThan(version, "0.1.95")) {
                if (Main.game.getPlayer().isQuestProgressGreaterThan(QuestLine.MAIN, Quest.MAIN_1_H_THE_GREAT_ESCAPE)) {
                    Main.game.getArthur().setLocation(WorldType.LILAYAS_HOUSE_GROUND_FLOOR, PlaceType.LILAYA_HOME_LAB, true);
                }
            }
            Main.game.pendingSlaveInStocksReset = false;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    Main.game.setRenderMap(true);
    Main.game.setRenderAttributesSection(true);
    Main.game.started = true;
    DialogueNodeOld startingDialogueNode = Main.game.getPlayerCell().getPlace().getDialogue(false);
    Main.game.addEvent(new EventLogEntry(Main.game.getMinutesPassed(), "[style.colourGood(Game loaded)]", "data/saves/" + name + ".xml"), false);
    Main.game.setContent(new Response(startingDialogueNode.getLabel(), startingDialogueNode.getDescription(), startingDialogueNode), false);
    newGame.endTurn(0);
}
Also used : TestNPC(com.lilithsthrone.game.character.npc.dominion.TestNPC) NPC(com.lilithsthrone.game.character.npc.NPC) GenericFemaleNPC(com.lilithsthrone.game.character.npc.GenericFemaleNPC) GenericAndrogynousNPC(com.lilithsthrone.game.character.npc.GenericAndrogynousNPC) GenericMaleNPC(com.lilithsthrone.game.character.npc.GenericMaleNPC) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Amber(com.lilithsthrone.game.character.npc.dominion.Amber) Arthur(com.lilithsthrone.game.character.npc.dominion.Arthur) EventLogEntry(com.lilithsthrone.game.dialogue.eventLog.EventLogEntry) SlaveryEventLogEntry(com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry) Element(org.w3c.dom.Element) DialogueNodeOld(com.lilithsthrone.game.dialogue.DialogueNodeOld) ArrayList(java.util.ArrayList) SlaveImport(com.lilithsthrone.game.character.npc.SlaveImport) Document(org.w3c.dom.Document) World(com.lilithsthrone.world.World) Zaranix(com.lilithsthrone.game.character.npc.dominion.Zaranix) WorldType(com.lilithsthrone.world.WorldType) CharacterImportSetting(com.lilithsthrone.game.character.CharacterImportSetting) SupplierPartner(com.lilithsthrone.game.character.npc.dominion.SupplierPartner) NodeList(org.w3c.dom.NodeList) ZaranixMaidKelly(com.lilithsthrone.game.character.npc.dominion.ZaranixMaidKelly) Method(java.lang.reflect.Method) TransformerException(javax.xml.transform.TransformerException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Response(com.lilithsthrone.game.dialogue.responses.Response) Generation(com.lilithsthrone.world.Generation) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Ashley(com.lilithsthrone.game.character.npc.dominion.Ashley) File(java.io.File) ZaranixMaidKatherine(com.lilithsthrone.game.character.npc.dominion.ZaranixMaidKatherine) SupplierLeader(com.lilithsthrone.game.character.npc.dominion.SupplierLeader)

Example 2 with WorldType

use of com.lilithsthrone.world.WorldType in project liliths-throne-public by Innoxia.

the class GameCharacter method loadGameCharacterVariablesFromXML.

public static void loadGameCharacterVariablesFromXML(GameCharacter character, StringBuilder log, Element parentElement, Document doc, CharacterImportSetting... settings) {
    boolean noPregnancy = Arrays.asList(settings).contains(CharacterImportSetting.NO_PREGNANCY);
    // ************** Core information **************//
    NodeList nodes = parentElement.getElementsByTagName("core");
    Element element = (Element) nodes.item(0);
    String version = "";
    if (element.getElementsByTagName("version").item(0) != null) {
        version = ((Element) element.getElementsByTagName("version").item(0)).getAttribute("value");
    }
    if (((Element) element.getElementsByTagName("id").item(0)) != null) {
        character.setId(((Element) element.getElementsByTagName("id").item(0)).getAttribute("value"));
        CharacterUtils.appendToImportLog(log, "</br>Set id: " + character.getId());
    }
    // Name:
    if (!((Element) element.getElementsByTagName("name").item(0)).getAttribute("value").isEmpty()) {
        character.setName(new NameTriplet(((Element) element.getElementsByTagName("name").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set name: " + ((Element) element.getElementsByTagName("name").item(0)).getAttribute("value"));
    } else {
        Element nameElement = ((Element) element.getElementsByTagName("name").item(0));
        character.setName(new NameTriplet(nameElement.getAttribute("nameMasculine"), nameElement.getAttribute("nameAndrogynous"), nameElement.getAttribute("nameFeminine")));
    }
    // Surname:
    if (element.getElementsByTagName("surname") != null && element.getElementsByTagName("surname").getLength() > 0) {
        character.setSurname(((Element) element.getElementsByTagName("surname").item(0)).getAttribute("value"));
        CharacterUtils.appendToImportLog(log, "</br>Set surname: " + ((Element) element.getElementsByTagName("surname").item(0)).getAttribute("value"));
    }
    // Level:
    character.setLevel(Integer.valueOf(((Element) element.getElementsByTagName("level").item(0)).getAttribute("value")));
    CharacterUtils.appendToImportLog(log, "</br>Set level: " + Integer.valueOf(((Element) element.getElementsByTagName("level").item(0)).getAttribute("value")));
    // Sexual Orientation:
    if (element.getElementsByTagName("sexualOrientation").getLength() != 0) {
        if (!((Element) element.getElementsByTagName("sexualOrientation").item(0)).getAttribute("value").equals("null")) {
            character.setSexualOrientation(SexualOrientation.valueOf(((Element) element.getElementsByTagName("sexualOrientation").item(0)).getAttribute("value")));
            CharacterUtils.appendToImportLog(log, "</br>Set Sexual Orientation: " + SexualOrientation.valueOf(((Element) element.getElementsByTagName("sexualOrientation").item(0)).getAttribute("value")));
        } else {
            character.setSexualOrientation(SexualOrientation.AMBIPHILIC);
            CharacterUtils.appendToImportLog(log, "</br>Set Sexual Orientation: " + SexualOrientation.AMBIPHILIC);
        }
    }
    if (element.getElementsByTagName("description").getLength() != 0) {
        character.setDescription(((Element) element.getElementsByTagName("description").item(0)).getAttribute("value"));
        CharacterUtils.appendToImportLog(log, "</br>Set description");
    }
    if (element.getElementsByTagName("playerPetName").getLength() != 0) {
        String petName = ((Element) element.getElementsByTagName("playerPetName").item(0)).getAttribute("value");
        character.setPlayerPetName(petName);
        CharacterUtils.appendToImportLog(log, "</br>Set playerPetName: " + petName);
    }
    if (element.getElementsByTagName("playerKnowsName").getLength() != 0) {
        character.setPlayerKnowsName(Boolean.valueOf(((Element) element.getElementsByTagName("playerKnowsName").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set playerKnowsName: " + character.isPlayerKnowsName());
    }
    if (element.getElementsByTagName("history").getLength() != 0) {
        try {
            character.setHistory(History.valueOf(((Element) element.getElementsByTagName("history").item(0)).getAttribute("value")));
            CharacterUtils.appendToImportLog(log, "</br>Set history: " + character.getHistory());
        } catch (Exception ex) {
            character.setHistory(History.STUDENT);
            CharacterUtils.appendToImportLog(log, "</br>History import failed. Set history to: " + character.getHistory());
        }
    }
    if (element.getElementsByTagName("personality").getLength() != 0) {
        String personality = ((Element) element.getElementsByTagName("personality").item(0)).getAttribute("value");
        if (personality.equals("AIR_SOCIALABLE")) {
            personality = "AIR_SOCIABLE";
        }
        character.setPersonality(Personality.valueOf(personality));
        CharacterUtils.appendToImportLog(log, "</br>Set personality: " + character.getPersonality());
    }
    if (element.getElementsByTagName("obedience").getLength() != 0) {
        character.setObedience(Float.valueOf(((Element) element.getElementsByTagName("obedience").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set obedience: " + character.getObedience());
    }
    boolean setGenderIdentity = false;
    if (element.getElementsByTagName("genderIdentity").getLength() != 0) {
        try {
            if (!((Element) element.getElementsByTagName("genderIdentity").item(0)).getAttribute("value").equals("null")) {
                character.setGenderIdentity(Gender.valueOf(((Element) element.getElementsByTagName("genderIdentity").item(0)).getAttribute("value")));
                CharacterUtils.appendToImportLog(log, "</br>Set genderIdentity: " + character.getGenderIdentity());
                setGenderIdentity = true;
            }
        } catch (Exception ex) {
        }
    }
    int extraLevelUpPoints = 0;
    // If there is a version number, attributes should be working correctly:
    if (element.getElementsByTagName("version").item(0) != null) {
        nodes = parentElement.getElementsByTagName("attributes");
        Element attElement = (Element) nodes.item(0);
        for (int i = 0; i < attElement.getElementsByTagName("attribute").getLength(); i++) {
            Element e = ((Element) attElement.getElementsByTagName("attribute").item(i));
            try {
                if (e.getAttribute("type").equals("CORRUPTION")) {
                    character.setAttribute(Attribute.MAJOR_CORRUPTION, Float.valueOf(e.getAttribute("value")), false);
                } else if (e.getAttribute("type").equals("STRENGTH") || e.getAttribute("type").equals("MAJOR_STRENGTH")) {
                    character.setAttribute(Attribute.MAJOR_PHYSIQUE, Float.valueOf(e.getAttribute("value")), false);
                } else {
                    if (!version.isEmpty() && Main.isVersionOlderThan(version, "0.2.0")) {
                        Attribute att = Attribute.valueOf(e.getAttribute("type"));
                        switch(att) {
                            case DAMAGE_FIRE:
                            case DAMAGE_ICE:
                            case DAMAGE_LUST:
                            case DAMAGE_PHYSICAL:
                            case DAMAGE_POISON:
                            case DAMAGE_SPELLS:
                                character.setAttribute(att, Float.valueOf(e.getAttribute("value")) - 100, false);
                                break;
                            default:
                                character.setAttribute(att, Float.valueOf(e.getAttribute("value")), false);
                                break;
                        }
                    } else {
                        character.setAttribute(Attribute.valueOf(e.getAttribute("type")), Float.valueOf(e.getAttribute("value")), false);
                    }
                }
                CharacterUtils.appendToImportLog(log, "</br>Set Attribute: " + Attribute.valueOf(e.getAttribute("type")).getName() + " to " + Float.valueOf(e.getAttribute("value")));
            } catch (IllegalArgumentException ex) {
            }
        }
    } else {
        extraLevelUpPoints = (Integer.valueOf(((Element) element.getElementsByTagName("level").item(0)).getAttribute("value")) * 5);
        CharacterUtils.appendToImportLog(log, "</br>Old character version. Extra LevelUpPoints set to: " + (Integer.valueOf(((Element) element.getElementsByTagName("level").item(0)).getAttribute("value")) * 5));
    }
    if (element.getElementsByTagName("health").getLength() != 0) {
        character.setHealth(Float.valueOf(((Element) element.getElementsByTagName("health").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set health: " + character.getHealth());
    }
    if (element.getElementsByTagName("mana").getLength() != 0) {
        character.setMana(Float.valueOf(((Element) element.getElementsByTagName("mana").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set mana: " + character.getMana());
    }
    nodes = parentElement.getElementsByTagName("playerKnowsAreas");
    Element knowsElement = (Element) nodes.item(0);
    if (knowsElement != null) {
        for (int i = 0; i < knowsElement.getElementsByTagName("area").getLength(); i++) {
            Element e = ((Element) knowsElement.getElementsByTagName("area").item(i));
            try {
                character.getPlayerKnowsAreas().add(CoverableArea.valueOf(e.getAttribute("type")));
                CharacterUtils.appendToImportLog(log, "</br>Added knows area: " + CoverableArea.valueOf(e.getAttribute("type")).getName());
            } catch (IllegalArgumentException ex) {
            }
        }
    }
    nodes = parentElement.getElementsByTagName("playerCore");
    if (nodes.getLength() > 0) {
        // Old version support:
        character.setPerkPoints((Integer.valueOf(((Element) element.getElementsByTagName("level").item(0)).getAttribute("value"))) - 1);
        CharacterUtils.appendToImportLog(log, "</br>Set perkPoints: (TEMP FIX) " + (Integer.valueOf(((Element) element.getElementsByTagName("level").item(0)).getAttribute("value")) - 1));
        element = (Element) nodes.item(0);
        character.incrementExperience(Integer.valueOf(((Element) element.getElementsByTagName("experience").item(0)).getAttribute("value")), false);
        CharacterUtils.appendToImportLog(log, "</br>Set experience: " + Integer.valueOf(((Element) element.getElementsByTagName("experience").item(0)).getAttribute("value")));
    } else {
        character.incrementExperience(Integer.valueOf(((Element) element.getElementsByTagName("experience").item(0)).getAttribute("value")), false);
        CharacterUtils.appendToImportLog(log, "</br>Set experience: " + Integer.valueOf(((Element) element.getElementsByTagName("experience").item(0)).getAttribute("value")));
        try {
            character.setPerkPoints(Integer.valueOf(((Element) element.getElementsByTagName("perkPoints").item(0)).getAttribute("value")));
            CharacterUtils.appendToImportLog(log, "</br>Set perkPoints: " + (Integer.valueOf(((Element) element.getElementsByTagName("perkPoints").item(0)).getAttribute("value")) + extraLevelUpPoints));
        } catch (Exception ex) {
        }
    }
    // ************** Location Information **************//
    nodes = parentElement.getElementsByTagName("locationInformation");
    element = (Element) nodes.item(0);
    if (element != null) {
        WorldType worldType = WorldType.valueOf(((Element) element.getElementsByTagName("worldLocation").item(0)).getAttribute("value"));
        if ((worldType == WorldType.DOMINION || worldType == WorldType.SUBMISSION || worldType == WorldType.HARPY_NEST) && Main.isVersionOlderThan(version, "0.2.1.5")) {
            PlaceType placeType = PlaceType.DOMINION_BACK_ALLEYS;
            if (character.isPlayer()) {
                if (worldType == WorldType.DOMINION) {
                    placeType = PlaceType.DOMINION_AUNTS_HOME;
                } else if (worldType == WorldType.SUBMISSION) {
                    placeType = PlaceType.SUBMISSION_ENTRANCE;
                } else {
                    placeType = PlaceType.HARPY_NESTS_ENTRANCE_ENFORCER_POST;
                }
            } else {
                if (character instanceof DominionAlleywayAttacker) {
                    placeType = PlaceType.DOMINION_BACK_ALLEYS;
                } else if (character instanceof DominionSuccubusAttacker) {
                    placeType = PlaceType.DOMINION_DARK_ALLEYS;
                } else if (character instanceof Cultist) {
                    placeType = PlaceType.DOMINION_STREET;
                } else if (character instanceof ReindeerOverseer) {
                    placeType = PlaceType.DOMINION_STREET;
                } else if (character instanceof SubmissionAttacker) {
                    placeType = PlaceType.SUBMISSION_TUNNELS;
                } else if (character instanceof HarpyNestsAttacker) {
                    placeType = PlaceType.HARPY_NESTS_WALKWAYS;
                } else if (character instanceof HarpyBimbo || character instanceof HarpyBimboCompanion) {
                    placeType = PlaceType.HARPY_NESTS_HARPY_NEST_YELLOW;
                } else if (character instanceof HarpyDominant || character instanceof HarpyDominantCompanion) {
                    placeType = PlaceType.HARPY_NESTS_HARPY_NEST_RED;
                } else if (character instanceof HarpyNympho || character instanceof HarpyNymphoCompanion) {
                    placeType = PlaceType.HARPY_NESTS_HARPY_NEST_PINK;
                } else if (character instanceof Scarlett || character instanceof Alexa) {
                    placeType = PlaceType.HARPY_NESTS_ALEXAS_NEST;
                }
            }
            character.setLocation(worldType, Main.game.getWorlds().get(worldType).getRandomUnoccupiedCell(placeType).getLocation(), true);
        } else {
            character.setLocation(worldType, new Vector2i(Integer.valueOf(((Element) element.getElementsByTagName("location").item(0)).getAttribute("x")), Integer.valueOf(((Element) element.getElementsByTagName("location").item(0)).getAttribute("y"))), false);
            character.setHomeLocation(WorldType.valueOf(((Element) element.getElementsByTagName("homeWorldLocation").item(0)).getAttribute("value")), new Vector2i(Integer.valueOf(((Element) element.getElementsByTagName("homeLocation").item(0)).getAttribute("x")), Integer.valueOf(((Element) element.getElementsByTagName("homeLocation").item(0)).getAttribute("y"))));
        }
    } else {
        character.setLocation(new Vector2i(0, 0));
    }
    // ************** Body **************//
    character.body = Body.loadFromXML(log, (Element) parentElement.getElementsByTagName("body").item(0), doc);
    if (!setGenderIdentity) {
        character.setGenderIdentity(character.getGender());
    }
    // ************** Inventory **************//
    character.resetInventory();
    nodes = parentElement.getElementsByTagName("characterInventory");
    element = (Element) nodes.item(0);
    if (element != null) {
        character.inventory = CharacterInventory.loadFromXML(element, doc);
        for (AbstractClothing clothing : character.getClothingCurrentlyEquipped()) {
            character.applyEquipClothingEffects(clothing);
        }
        if (character.getMainWeapon() != null) {
            for (Entry<Attribute, Integer> e : character.getMainWeapon().getAttributeModifiers().entrySet()) {
                character.incrementBonusAttribute(e.getKey(), e.getValue());
            }
        }
        if (character.getOffhandWeapon() != null) {
            for (Entry<Attribute, Integer> e : character.getOffhandWeapon().getAttributeModifiers().entrySet()) {
                character.incrementBonusAttribute(e.getKey(), e.getValue());
            }
        }
    } else {
        CharacterCreation.getDressed(character, false);
    }
    // ************** Attributes **************//
    // Core attributes are set in the first section.
    // Potion attributes:
    nodes = parentElement.getElementsByTagName("potionAttributes");
    Element attElement = (Element) nodes.item(0);
    if (attElement != null) {
        for (int i = 0; i < attElement.getElementsByTagName("attribute").getLength(); i++) {
            Element e = ((Element) attElement.getElementsByTagName("attribute").item(i));
            try {
                character.addPotionEffect(Attribute.valueOf(e.getAttribute("type")), Float.valueOf(e.getAttribute("value")));
                CharacterUtils.appendToImportLog(log, "</br>Set Potion Attribute: " + Attribute.valueOf(e.getAttribute("type")).getName() + " to " + Float.valueOf(e.getAttribute("value")));
            } catch (IllegalArgumentException ex) {
            }
        }
    }
    // Perks:
    nodes = parentElement.getElementsByTagName("traits");
    element = (Element) nodes.item(0);
    if (element != null) {
        for (int i = 0; i < element.getElementsByTagName("perk").getLength(); i++) {
            Element e = ((Element) element.getElementsByTagName("perk").item(i));
            character.addTrait(Perk.valueOf(e.getAttribute("type")));
            CharacterUtils.appendToImportLog(log, "</br>Added Equipped Perk: " + Perk.valueOf(e.getAttribute("type")).getName(character));
        }
    }
    nodes = parentElement.getElementsByTagName("perks");
    element = (Element) nodes.item(0);
    if (element != null) {
        if (!version.isEmpty() && Main.isVersionOlderThan(version, "0.2.0.2")) {
            int points = character.getPerkPointsAtLevel(character.getLevel());
            character.setPerkPoints(points);
            character.clearTraits();
            CharacterUtils.appendToImportLog(log, "</br>Added Perk Points: " + points);
        } else {
            for (int i = 0; i < element.getElementsByTagName("perk").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("perk").item(i));
                String type = e.getAttribute("type");
                type = type.replaceAll("STRENGTH_", "PHYSIQUE_");
                try {
                    character.addPerk(Integer.valueOf(e.getAttribute("row")), Perk.valueOf(type));
                    CharacterUtils.appendToImportLog(log, "</br>Added Perk: " + Perk.valueOf(type).getName(character));
                } catch (Exception ex) {
                }
            }
        }
    }
    // Fetishes:
    nodes = parentElement.getElementsByTagName("fetishes");
    element = (Element) nodes.item(0);
    if (element != null) {
        if (element.getElementsByTagName("fetish").item(0) != null && !((Element) element.getElementsByTagName("fetish").item(0)).getAttribute("value").isEmpty()) {
            for (int i = 0; i < element.getElementsByTagName("fetish").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("fetish").item(i));
                try {
                    if (e.getAttribute("type").equals("FETISH_NON_CON")) {
                        // Support for old non-con fetish:
                        character.incrementEssenceCount(TFEssence.ARCANE, 5);
                        CharacterUtils.appendToImportLog(log, "</br>Added refund for old non-con fetish. (+5 arcane essences)");
                    } else if (Fetish.valueOf(e.getAttribute("type")) != null) {
                        if (Boolean.valueOf(((Element) element.getElementsByTagName("fetish").item(0)).getAttribute("value"))) {
                            character.addFetish(Fetish.valueOf(e.getAttribute("type")));
                            CharacterUtils.appendToImportLog(log, "</br>Added Fetish: " + Fetish.valueOf(e.getAttribute("type")).getName(character));
                        }
                    }
                } catch (IllegalArgumentException ex) {
                }
            }
        } else {
            for (int i = 0; i < element.getElementsByTagName("fetish").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("fetish").item(i));
                try {
                    if (e.getAttribute("type").equals("FETISH_NON_CON")) {
                        // Support for old non-con fetish:
                        character.incrementEssenceCount(TFEssence.ARCANE, 5);
                        CharacterUtils.appendToImportLog(log, "</br>Added refund for old non-con fetish. (+5 arcane essences)");
                    } else if (Fetish.valueOf(e.getAttribute("type")) != null) {
                        character.addFetish(Fetish.valueOf(e.getAttribute("type")));
                        CharacterUtils.appendToImportLog(log, "</br>Added Fetish: " + Fetish.valueOf(e.getAttribute("type")).getName(character));
                    }
                } catch (IllegalArgumentException ex) {
                }
            }
        }
    }
    nodes = parentElement.getElementsByTagName("fetishDesire");
    element = (Element) nodes.item(0);
    if (element != null) {
        for (int i = 0; i < element.getElementsByTagName("entry").getLength(); i++) {
            Element e = ((Element) element.getElementsByTagName("entry").item(i));
            try {
                character.setFetishDesire(Fetish.valueOf(e.getAttribute("fetish")), FetishDesire.valueOf(e.getAttribute("desire")));
                CharacterUtils.appendToImportLog(log, "</br>Set fetish desire: " + e.getAttribute("fetish") + " , " + e.getAttribute("desire"));
            } catch (IllegalArgumentException ex) {
            }
        }
    }
    nodes = parentElement.getElementsByTagName("fetishExperience");
    element = (Element) nodes.item(0);
    if (element != null) {
        for (int i = 0; i < element.getElementsByTagName("entry").getLength(); i++) {
            Element e = ((Element) element.getElementsByTagName("entry").item(i));
            try {
                character.setFetishExperience(Fetish.valueOf(e.getAttribute("fetish")), Integer.valueOf(e.getAttribute("experience")));
                CharacterUtils.appendToImportLog(log, "</br>Set fetish experience: " + e.getAttribute("fetish") + " , " + e.getAttribute("experience"));
            } catch (IllegalArgumentException ex) {
            }
        }
    }
    // Status Effects:
    nodes = parentElement.getElementsByTagName("statusEffects");
    element = (Element) nodes.item(0);
    for (int i = 0; i < element.getElementsByTagName("statusEffect").getLength(); i++) {
        Element e = ((Element) element.getElementsByTagName("statusEffect").item(i));
        try {
            if (Integer.valueOf(e.getAttribute("value")) != -1) {
                StatusEffect effect = StatusEffect.valueOf(e.getAttribute("type"));
                if (!noPregnancy || (effect != StatusEffect.PREGNANT_0 && effect != StatusEffect.PREGNANT_1 && effect != StatusEffect.PREGNANT_2 && effect != StatusEffect.PREGNANT_3)) {
                    character.addStatusEffect(effect, Integer.valueOf(e.getAttribute("value")));
                    CharacterUtils.appendToImportLog(log, "</br>Added Status Effect: " + StatusEffect.valueOf(e.getAttribute("type")).getName(character) + " (" + Integer.valueOf(e.getAttribute("value")) + " minutes)");
                }
            }
        } catch (IllegalArgumentException ex) {
        }
    }
    // ************** Relationships **************//
    nodes = parentElement.getElementsByTagName("characterRelationships");
    element = (Element) nodes.item(0);
    if (element != null) {
        for (int i = 0; i < element.getElementsByTagName("relationship").getLength(); i++) {
            Element e = ((Element) element.getElementsByTagName("relationship").item(i));
            character.setAffection(e.getAttribute("character"), Float.valueOf(e.getAttribute("value")));
            CharacterUtils.appendToImportLog(log, "</br>Set Relationship: " + e.getAttribute("character") + " , " + Float.valueOf(e.getAttribute("value")));
        }
    }
    if (!noPregnancy) {
        nodes = parentElement.getElementsByTagName("pregnancy");
        Element pregnancyElement = (Element) nodes.item(0);
        if (pregnancyElement != null) {
            CharacterUtils.appendToImportLog(log, "</br></br>Pregnancies:");
            character.setTimeProgressedToFinalPregnancyStage(Integer.valueOf(pregnancyElement.getAttribute("timeProgressedToFinalPregnancyStage")));
            nodes = pregnancyElement.getElementsByTagName("potentialPartnersAsMother");
            element = (Element) nodes.item(0);
            if (element != null) {
                for (int i = 0; i < element.getElementsByTagName("pregnancyPossibility").getLength(); i++) {
                    Element e = ((Element) element.getElementsByTagName("pregnancyPossibility").item(i));
                    character.getPotentialPartnersAsMother().add(PregnancyPossibility.loadFromXML(e, doc));
                    CharacterUtils.appendToImportLog(log, "</br>Added Pregnancy Possibility as mother.");
                }
            }
            nodes = pregnancyElement.getElementsByTagName("potentialPartnersAsFather");
            element = (Element) nodes.item(0);
            if (element != null) {
                for (int i = 0; i < element.getElementsByTagName("pregnancyPossibility").getLength(); i++) {
                    Element e = ((Element) element.getElementsByTagName("pregnancyPossibility").item(i));
                    character.getPotentialPartnersAsFather().add(PregnancyPossibility.loadFromXML(e, doc));
                    CharacterUtils.appendToImportLog(log, "</br>Added Pregnancy Possibility as father.");
                }
            }
            nodes = pregnancyElement.getElementsByTagName("pregnantLitter");
            element = (Element) ((Element) nodes.item(0)).getElementsByTagName("litter").item(0);
            if (element != null) {
                character.setPregnantLitter(Litter.loadFromXML(element, doc));
                CharacterUtils.appendToImportLog(log, "</br>Added Pregnant litter.");
            }
            nodes = pregnancyElement.getElementsByTagName("birthedLitters");
            element = (Element) nodes.item(0);
            if (element != null) {
                for (int i = 0; i < element.getElementsByTagName("litter").getLength(); i++) {
                    Element e = ((Element) element.getElementsByTagName("litter").item(i));
                    character.getLittersBirthed().add(Litter.loadFromXML(e, doc));
                    CharacterUtils.appendToImportLog(log, "</br>Added litter birthed.");
                }
            }
            nodes = pregnancyElement.getElementsByTagName("littersFathered");
            element = (Element) nodes.item(0);
            if (element != null) {
                for (int i = 0; i < element.getElementsByTagName("litter").getLength(); i++) {
                    Element e = ((Element) element.getElementsByTagName("litter").item(i));
                    character.getLittersFathered().add(Litter.loadFromXML(e, doc));
                    CharacterUtils.appendToImportLog(log, "</br>Added litter fathered.");
                }
            }
        }
    }
    // ************** Family **************//
    nodes = parentElement.getElementsByTagName("family");
    Element familyElement = (Element) nodes.item(0);
    if (familyElement != null) {
        character.setMother(((Element) familyElement.getElementsByTagName("motherId").item(0)).getAttribute("value"));
        character.setFather(((Element) familyElement.getElementsByTagName("fatherId").item(0)).getAttribute("value"));
        character.setDayOfConception(Integer.valueOf(((Element) familyElement.getElementsByTagName("dayOfConception").item(0)).getAttribute("value")));
        character.setDayOfBirth(Integer.valueOf(((Element) familyElement.getElementsByTagName("dayOfBirth").item(0)).getAttribute("value")));
    }
    // ************** Slavery **************//
    nodes = parentElement.getElementsByTagName("slavery");
    Element slaveryElement = (Element) nodes.item(0);
    if (slaveryElement != null) {
        for (int i = 0; i < ((Element) slaveryElement.getElementsByTagName("slavesOwned").item(0)).getElementsByTagName("slave").getLength(); i++) {
            Element e = ((Element) slaveryElement.getElementsByTagName("slave").item(i));
            if (!e.getAttribute("id").equals("NOT_SET")) {
                character.getSlavesOwned().add(e.getAttribute("id"));
                CharacterUtils.appendToImportLog(log, "</br>Added owned slave: " + e.getAttribute("id"));
            }
        }
        character.setOwner(((Element) slaveryElement.getElementsByTagName("owner").item(0)).getAttribute("value"));
        CharacterUtils.appendToImportLog(log, "</br>Set owner: " + character.getOwnerId());
        character.setSlaveJob(SlaveJob.valueOf(((Element) slaveryElement.getElementsByTagName("slaveJob").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set slave job: " + character.getSlaveJob());
        for (int i = 0; i < ((Element) slaveryElement.getElementsByTagName("slaveJobSettings").item(0)).getElementsByTagName("setting").getLength(); i++) {
            Element e = ((Element) slaveryElement.getElementsByTagName("setting").item(i));
            SlaveJobSetting setting = SlaveJobSetting.valueOf(e.getAttribute("value"));
            character.addSlaveJobSettings(setting);
            CharacterUtils.appendToImportLog(log, "</br>Added slave job setting: " + setting);
        }
        // Clear settings first:
        for (SlavePermission key : character.getSlavePermissionSettings().keySet()) {
            character.getSlavePermissionSettings().get(key).clear();
        }
        for (int i = 0; i < ((Element) slaveryElement.getElementsByTagName("slavePermissionSettings").item(0)).getElementsByTagName("permission").getLength(); i++) {
            Element e = ((Element) slaveryElement.getElementsByTagName("permission").item(i));
            SlavePermission slavePermission = SlavePermission.valueOf(e.getAttribute("type"));
            for (int j = 0; j < e.getElementsByTagName("setting").getLength(); j++) {
                Element e2 = ((Element) e.getElementsByTagName("setting").item(j));
                SlavePermissionSetting setting = SlavePermissionSetting.valueOf(e2.getAttribute("value"));
                character.addSlavePermissionSetting(slavePermission, setting);
                CharacterUtils.appendToImportLog(log, "</br>Added slave permission setting: " + slavePermission + ", " + setting);
            }
        }
        Element workHourElement = ((Element) slaveryElement.getElementsByTagName("slaveWorkHours").item(0));
        for (int i = 0; i < character.workHours.length; i++) {
            character.workHours[i] = Boolean.valueOf(workHourElement.getAttribute("hour" + String.valueOf(i)));
            CharacterUtils.appendToImportLog(log, "</br>Set work hour: " + i + ", " + character.workHours[i]);
        }
    }
    // ************** Sex Stats **************//
    nodes = parentElement.getElementsByTagName("sexStats");
    Element sexStatsElement = (Element) nodes.item(0);
    if (sexStatsElement.getElementsByTagName("sexConsensualCount").getLength() != 0) {
        character.setSexConsensualCount(Integer.valueOf(((Element) sexStatsElement.getElementsByTagName("sexConsensualCount").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set consensual sex count: " + character.getSexConsensualCount());
    }
    if (sexStatsElement.getElementsByTagName("sexAsSubCount").getLength() != 0) {
        character.setSexAsSubCount(Integer.valueOf(((Element) sexStatsElement.getElementsByTagName("sexAsSubCount").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set sub sex count: " + character.getSexAsSubCount());
    }
    if (sexStatsElement.getElementsByTagName("sexAsDomCount").getLength() != 0) {
        character.setSexAsDomCount(Integer.valueOf(((Element) sexStatsElement.getElementsByTagName("sexAsDomCount").item(0)).getAttribute("value")));
        CharacterUtils.appendToImportLog(log, "</br>Set dom sex count: " + character.getSexAsDomCount());
    }
    // Cummed in areas:
    element = (Element) ((Element) nodes.item(0)).getElementsByTagName("cummedInAreas").item(0);
    if (element != null) {
        for (int i = 0; i < element.getElementsByTagName("entry").getLength(); i++) {
            Element e = ((Element) element.getElementsByTagName("entry").item(i));
            try {
                character.setCummedInArea(OrificeType.valueOf(e.getAttribute("orifice")), Integer.valueOf(e.getAttribute("cumQuantity")));
                CharacterUtils.appendToImportLog(log, "</br>Added cummed in area: " + e.getAttribute("orifice") + ", " + Integer.valueOf(e.getAttribute("cumQuantity")) + "ml");
            } catch (Exception ex) {
            }
        }
    }
    // Cum counts:
    element = (Element) ((Element) nodes.item(0)).getElementsByTagName("cumCounts").item(0);
    for (int i = 0; i < element.getElementsByTagName("cumCount").getLength(); i++) {
        Element e = ((Element) element.getElementsByTagName("cumCount").item(i));
        try {
            for (int it = 0; it < Integer.valueOf(e.getAttribute("count")); it++) {
                character.incrementCumCount(new SexType(SexParticipantType.valueOf(e.getAttribute("participantType")), PenetrationType.valueOf(e.getAttribute("penetrationType")), OrificeType.valueOf(e.getAttribute("orificeType"))));
            }
            CharacterUtils.appendToImportLog(log, "</br>Added cum count:" + e.getAttribute("penetrationType") + " " + e.getAttribute("orificeType") + " x " + Integer.valueOf(e.getAttribute("count")));
        } catch (Exception ex) {
        }
    }
    // Sex counts:
    element = (Element) ((Element) nodes.item(0)).getElementsByTagName("sexCounts").item(0);
    for (int i = 0; i < element.getElementsByTagName("sexCount").getLength(); i++) {
        Element e = ((Element) element.getElementsByTagName("sexCount").item(i));
        try {
            for (int it = 0; it < Integer.valueOf(e.getAttribute("count")); it++) {
                character.incrementSexCount(new SexType(SexParticipantType.valueOf(e.getAttribute("participantType")), PenetrationType.valueOf(e.getAttribute("penetrationType")), OrificeType.valueOf(e.getAttribute("orificeType"))));
            }
            CharacterUtils.appendToImportLog(log, "</br>Added sex count:" + e.getAttribute("penetrationType") + " " + e.getAttribute("orificeType") + " x " + Integer.valueOf(e.getAttribute("count")));
        } catch (Exception ex) {
        }
    }
    // Virginity losses:
    element = (Element) ((Element) nodes.item(0)).getElementsByTagName("virginityTakenBy").item(0);
    for (int i = 0; i < element.getElementsByTagName("virginity").getLength(); i++) {
        Element e = ((Element) element.getElementsByTagName("virginity").item(i));
        try {
            character.setVirginityLoss(new SexType(SexParticipantType.valueOf(e.getAttribute("participantType")), PenetrationType.valueOf(e.getAttribute("penetrationType")), OrificeType.valueOf(e.getAttribute("orificeType"))), e.getAttribute("takenBy"));
            CharacterUtils.appendToImportLog(log, "</br>Added virginity loss:" + e.getAttribute("penetrationType") + " " + e.getAttribute("orificeType") + " (taken by:" + e.getAttribute("takenBy") + ")");
        } catch (Exception ex) {
        }
    }
    element = (Element) ((Element) nodes.item(0)).getElementsByTagName("sexPartnerMap").item(0);
    if (element != null) {
        for (int i = 0; i < element.getElementsByTagName("id").getLength(); i++) {
            Element e = ((Element) element.getElementsByTagName("id").item(i));
            character.sexPartnerMap.put(e.getAttribute("value"), new HashMap<>());
            for (int j = 0; j < element.getElementsByTagName("entry").getLength(); j++) {
                Element e2 = ((Element) element.getElementsByTagName("entry").item(j));
                try {
                    character.sexPartnerMap.get(e.getAttribute("value")).put(new SexType(SexParticipantType.valueOf(e.getAttribute("participantType")), PenetrationType.valueOf(e2.getAttribute("penetrationType")), OrificeType.valueOf(e2.getAttribute("orificeType"))), Integer.valueOf(e2.getAttribute("count")));
                    CharacterUtils.appendToImportLog(log, "</br>Added sex tracking: " + e.getAttribute("value") + " " + e2.getAttribute("penetrationType") + "/" + e2.getAttribute("orificeType") + " " + Integer.valueOf(e2.getAttribute("count")));
                } catch (Exception ex) {
                }
            }
        }
    }
    // ************** Addictions **************//
    // Element characterAddictions = doc.createElement("addictions");
    // properties.appendChild(characterAddictions);
    // for(Addiction add : addictions) {
    // add.saveAsXML(characterAddictions, doc);
    // }
    // 
    // CharacterUtils.addAttribute(doc, characterAddictions, "alcoholLevel", String.valueOf(alcoholLevel));
    // 
    // Element psychoactives = doc.createElement("psychoactiveFluids");
    // properties.appendChild(psychoactives);
    // for(FluidType ft : this.getPsychoactiveFluidsIngested()) {
    // Element element = doc.createElement("fluid");
    // psychoactives.appendChild(element);
    // CharacterUtils.addAttribute(doc, element, "value", ft.toString());
    // }
    nodes = parentElement.getElementsByTagName("addictionsCore");
    Element addictionsElement = (Element) nodes.item(0);
    if (addictionsElement != null) {
        if (!addictionsElement.getAttribute("alcoholLevel").isEmpty()) {
            try {
                character.alcoholLevel = (Float.valueOf(addictionsElement.getAttribute("alcoholLevel")));
            } catch (Exception ex) {
            }
        }
        element = (Element) addictionsElement.getElementsByTagName("psychoactiveFluids").item(0);
        if (element != null) {
            for (int i = 0; i < element.getElementsByTagName("fluid").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("fluid").item(i));
                character.addPsychoactiveFluidIngested(FluidType.valueOf(e.getAttribute("value")));
                CharacterUtils.appendToImportLog(log, "</br>Added psychoactive fluid:" + e.getAttribute("value"));
            }
        }
        // Old addiction support: //TODO test
        element = (Element) addictionsElement.getElementsByTagName("addictionSatisfiedMap").item(0);
        if (element != null) {
            for (int i = 0; i < element.getElementsByTagName("addiction").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("addiction").item(i));
                character.setLastTimeSatisfiedAddiction(FluidType.valueOf(e.getAttribute("type")), Long.valueOf(e.getAttribute("value")));
                CharacterUtils.appendToImportLog(log, "</br>Set satisfied time:" + e.getAttribute("type") + " " + e.getAttribute("value"));
            }
        }
        // New addiction:
        element = (Element) addictionsElement.getElementsByTagName("addictions").item(0);
        if (element != null) {
            for (int i = 0; i < element.getElementsByTagName("addiction").getLength(); i++) {
                try {
                    character.addAddiction(Addiction.loadFromXML(log, ((Element) element.getElementsByTagName("addiction").item(i)), doc));
                } catch (Exception ex) {
                }
            }
        }
    }
}
Also used : SlaveJobSetting(com.lilithsthrone.game.slavery.SlaveJobSetting) PlaceType(com.lilithsthrone.world.places.PlaceType) Attribute(com.lilithsthrone.game.character.attributes.Attribute) Element(org.w3c.dom.Element) SlavePermission(com.lilithsthrone.game.slavery.SlavePermission) DominionSuccubusAttacker(com.lilithsthrone.game.character.npc.dominion.DominionSuccubusAttacker) ReindeerOverseer(com.lilithsthrone.game.character.npc.dominion.ReindeerOverseer) HarpyNymphoCompanion(com.lilithsthrone.game.character.npc.dominion.HarpyNymphoCompanion) HarpyBimbo(com.lilithsthrone.game.character.npc.dominion.HarpyBimbo) WorldType(com.lilithsthrone.world.WorldType) Scarlett(com.lilithsthrone.game.character.npc.dominion.Scarlett) SubmissionAttacker(com.lilithsthrone.game.character.npc.submission.SubmissionAttacker) HarpyBimboCompanion(com.lilithsthrone.game.character.npc.dominion.HarpyBimboCompanion) HarpyDominant(com.lilithsthrone.game.character.npc.dominion.HarpyDominant) DominionAlleywayAttacker(com.lilithsthrone.game.character.npc.dominion.DominionAlleywayAttacker) Vector2i(com.lilithsthrone.utils.Vector2i) Cultist(com.lilithsthrone.game.character.npc.dominion.Cultist) SexType(com.lilithsthrone.game.sex.SexType) HarpyDominantCompanion(com.lilithsthrone.game.character.npc.dominion.HarpyDominantCompanion) Alexa(com.lilithsthrone.game.character.npc.dominion.Alexa) NodeList(org.w3c.dom.NodeList) HarpyNestsAttacker(com.lilithsthrone.game.character.npc.dominion.HarpyNestsAttacker) AbstractClothing(com.lilithsthrone.game.inventory.clothing.AbstractClothing) StatusEffect(com.lilithsthrone.game.character.effects.StatusEffect) SlavePermissionSetting(com.lilithsthrone.game.slavery.SlavePermissionSetting) HarpyNympho(com.lilithsthrone.game.character.npc.dominion.HarpyNympho)

Aggregations

WorldType (com.lilithsthrone.world.WorldType)2 Element (org.w3c.dom.Element)2 NodeList (org.w3c.dom.NodeList)2 CharacterImportSetting (com.lilithsthrone.game.character.CharacterImportSetting)1 Attribute (com.lilithsthrone.game.character.attributes.Attribute)1 StatusEffect (com.lilithsthrone.game.character.effects.StatusEffect)1 GenericAndrogynousNPC (com.lilithsthrone.game.character.npc.GenericAndrogynousNPC)1 GenericFemaleNPC (com.lilithsthrone.game.character.npc.GenericFemaleNPC)1 GenericMaleNPC (com.lilithsthrone.game.character.npc.GenericMaleNPC)1 NPC (com.lilithsthrone.game.character.npc.NPC)1 SlaveImport (com.lilithsthrone.game.character.npc.SlaveImport)1 Alexa (com.lilithsthrone.game.character.npc.dominion.Alexa)1 Amber (com.lilithsthrone.game.character.npc.dominion.Amber)1 Arthur (com.lilithsthrone.game.character.npc.dominion.Arthur)1 Ashley (com.lilithsthrone.game.character.npc.dominion.Ashley)1 Cultist (com.lilithsthrone.game.character.npc.dominion.Cultist)1 DominionAlleywayAttacker (com.lilithsthrone.game.character.npc.dominion.DominionAlleywayAttacker)1 DominionSuccubusAttacker (com.lilithsthrone.game.character.npc.dominion.DominionSuccubusAttacker)1 HarpyBimbo (com.lilithsthrone.game.character.npc.dominion.HarpyBimbo)1 HarpyBimboCompanion (com.lilithsthrone.game.character.npc.dominion.HarpyBimboCompanion)1