Search in sources :

Example 1 with SlaveryEventLogEntry

use of com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry in project liliths-throne-public by Innoxia.

the class SlaveryUtil method performHourlyUpdate.

public void performHourlyUpdate(int day, int hour) {
    clearSlavesJobTracking();
    // First need to set correct jobs:
    for (String id : Main.game.getPlayer().getSlavesOwned()) {
        NPC slave = (NPC) Main.game.getNPCById(id);
        if (slave.getWorkHours()[hour]) {
            slave.getSlaveJob().sendToWorkLocation(slave);
            slavesAtJob.get(slave.getSlaveJob()).add(slave);
        } else {
            slave.setLocation(slave.getHomeWorldLocation(), slave.getHomeLocation(), false);
            slavesResting.add(slave);
        }
    }
    // Now can apply changes and generate events based on who else is present in the job:
    for (String id : Main.game.getPlayer().getSlavesOwned()) {
        NPC slave = (NPC) Main.game.getNPCById(id);
        slave.incrementAffection(slave.getOwner(), slave.getHourlyAffectionChange(hour));
        slave.incrementObedience(slave.getHourlyObedienceChange(hour), false);
        // If at work:
        if (slave.getWorkHours()[hour]) {
            // Get paid for hour's work:
            int income = slave.getSlaveJob().getFinalHourlyIncomeAfterModifiers(slave);
            generatedIncome += income;
            incrementSlaveDailyIncome(slave, income);
            // Overworked effect:
            if (slave.hasStatusEffect(StatusEffect.OVERWORKED)) {
                slave.incrementAffection(slave.getOwner(), -0.1f);
            }
        } else {
            if (slave.hasSlavePermissionSetting(SlavePermissionSetting.SEX_MASTURBATE)) {
                slave.setLastTimeHadSex((day * 24 * 60l) + hour * 60l, true);
            }
        }
        // Washing body:
        if (slave.hasSlavePermissionSetting(SlavePermissionSetting.CLEANLINESS_WASH_BODY) && !slave.getWorkHours()[hour] && (slave.hasStatusEffect(StatusEffect.CREAMPIE_ANUS) || slave.hasStatusEffect(StatusEffect.CREAMPIE_VAGINA) || slave.hasStatusEffect(StatusEffect.CREAMPIE_NIPPLES))) {
            SlaveryEventLogEntry entry = new SlaveryEventLogEntry(hour, slave, SlaveEvent.WASHED_BODY, null, true);
            if (slave.hasStatusEffect(StatusEffect.CREAMPIE_ANUS)) {
                entry.addTag(SlaveEventTag.WASHED_BODY_ANAL_CREAMPIE, slave, true);
            }
            if (slave.hasStatusEffect(StatusEffect.CREAMPIE_VAGINA)) {
                entry.addTag(SlaveEventTag.WASHED_BODY_VAGINAL_CREAMPIE, slave, true);
            }
            if (slave.hasStatusEffect(StatusEffect.CREAMPIE_NIPPLES)) {
                entry.addTag(SlaveEventTag.WASHED_BODY_NIPPLE_CREAMPIE, slave, true);
            }
            Main.game.addSlaveryEvent(day, slave, entry);
        }
        // Washing clothes:
        if ((slave.hasStatusEffect(StatusEffect.CLOTHING_CUM) || !slave.getDirtySlots().isEmpty()) && !slave.getWorkHours()[hour] && slave.hasSlavePermissionSetting(SlavePermissionSetting.CLEANLINESS_WASH_CLOTHES)) {
            Main.game.addSlaveryEvent(day, slave, new SlaveryEventLogEntry(hour, slave, SlaveEvent.WASHED_CLOTHES, Util.newArrayListOfValues(new ListValue<>(SlaveEventTag.WASHED_CLOTHES)), true));
        }
        // Events:
        boolean eventAdded = false;
        SlaveryEventLogEntry entry = null;
        // Interaction events:
        if (slavesAtJob.get(slave.getSlaveJob()).size() > 1) {
            if (Math.random() < 0.25f) {
                entry = generateNPCInteractionEvent(day, hour, slave, slavesAtJob.get(slave.getSlaveJob()));
                if (entry != null) {
                    Main.game.addSlaveryEvent(day, slave, entry);
                    eventAdded = true;
                }
            }
        }
        // Standard events:
        if (!eventAdded) {
            if (Math.random() < 0.05f || (Math.random() < 0.5f && slave.getSlaveJob() == SlaveJob.PUBLIC_STOCKS)) {
                entry = generateEvent(hour, slave);
                if (entry != null) {
                    Main.game.addSlaveryEvent(day, slave, entry);
                    eventAdded = true;
                }
            }
        }
        if (hour % 24 == 0) {
            // At the start of a new day:
            SlaveryEventLogEntry dailyEntry = new SlaveryEventLogEntry(hour, slave, SlaveEvent.DAILY_UPDATE, null, true);
            // Payments:
            if (slaveDailyIncome.containsKey(slave)) {
                dailyEntry.addExtraEffect("[style.boldGood(Earned)] " + UtilText.formatAsMoney(slaveDailyIncome.get(slave)));
            }
            // Muscle:
            if (slave.hasSlavePermissionSetting(SlavePermissionSetting.EXERCISE_FORBIDDEN) && slave.getMuscleValue() > 0) {
                dailyEntry.addTag(SlaveEventTag.DAILY_MUSCLE_LOSS_LARGE, slave, true);
            } else if (slave.hasSlavePermissionSetting(SlavePermissionSetting.EXERCISE_REST) && slave.getMuscleValue() > 0) {
                dailyEntry.addTag(SlaveEventTag.DAILY_MUSCLE_LOSS, slave, true);
            } else if (slave.hasSlavePermissionSetting(SlavePermissionSetting.EXERCISE_TRAINING) && slave.getMuscleValue() < 100) {
                dailyEntry.addTag(SlaveEventTag.DAILY_MUSCLE_GAIN, slave, true);
            } else if (slave.hasSlavePermissionSetting(SlavePermissionSetting.EXERCISE_BODY_BUILDING) && slave.getMuscleValue() < 100) {
                dailyEntry.addTag(SlaveEventTag.DAILY_MUSCLE_GAIN_LARGE, slave, true);
            }
            // Body size:
            if (slave.hasSlavePermissionSetting(SlavePermissionSetting.FOOD_DIET_EXTREME) && slave.getBodySizeValue() > 0) {
                dailyEntry.addTag(SlaveEventTag.DAILY_BODY_SIZE_LOSS_LARGE, slave, true);
            } else if (slave.hasSlavePermissionSetting(SlavePermissionSetting.FOOD_DIET) && slave.getMuscleValue() > 0) {
                dailyEntry.addTag(SlaveEventTag.DAILY_BODY_SIZE_LOSS, slave, true);
            } else if (slave.hasSlavePermissionSetting(SlavePermissionSetting.FOOD_PLUS) && slave.getMuscleValue() < 100) {
                dailyEntry.addTag(SlaveEventTag.DAILY_BODY_SIZE_GAIN, slave, true);
            } else if (slave.hasSlavePermissionSetting(SlavePermissionSetting.FOOD_LAVISH) && slave.getMuscleValue() < 100) {
                dailyEntry.addTag(SlaveEventTag.DAILY_BODY_SIZE_GAIN_LARGE, slave, true);
            }
            if (dailyEntry.getTags() != null || dailyEntry.getExtraEffects() != null) {
                Main.game.addSlaveryEvent(day, slave, dailyEntry);
            }
            slave.resetSlaveFlags();
        }
    }
    if (hour % 24 == 0) {
        // Reset daily income tracking:
        slaveDailyIncome.clear();
        // Rooms:
        for (Cell c : SlaveryManagementDialogue.importantCells) {
            generatedUpkeep += c.getPlace().getUpkeep();
        }
    }
}
Also used : NPC(com.lilithsthrone.game.character.npc.NPC) SlaveryEventLogEntry(com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry) Cell(com.lilithsthrone.world.Cell)

Example 2 with SlaveryEventLogEntry

use of com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry in project liliths-throne-public by Innoxia.

the class SlaveryUtil method generateNPCInteractionEvent.

/**
 * @param hour Pass in hour of the day
 * @param slave
 * @param otherSlavesPresent
 * @return
 */
public static SlaveryEventLogEntry generateNPCInteractionEvent(int day, int hour, NPC slave, List<NPC> otherSlavesPresent) {
    if (slave.getSlaveJob() == SlaveJob.PUBLIC_STOCKS) {
        return null;
    }
    Collections.shuffle(otherSlavesPresent);
    for (NPC npc : otherSlavesPresent) {
        if (!npc.equals(slave)) {
            if (slave.getLastTimeHadSex() + 24 * 60 < Main.game.getMinutesPassed()) {
                // They only want sex once a day, to stop the logs from being flooded
                if (slave.isAttractedTo(npc) && npc.hasSlavePermissionSetting(SlavePermissionSetting.SEX_RECEIVE_SLAVES) && slave.hasSlavePermissionSetting(SlavePermissionSetting.SEX_INITIATE_SLAVES)) {
                    System.out.println("x");
                    boolean canImpregnate = slave.hasSlavePermissionSetting(SlavePermissionSetting.SEX_IMPREGNATE) && npc.hasSlavePermissionSetting(SlavePermissionSetting.SEX_IMPREGNATED) && slave.hasPenis() && slave.isAbleToAccessCoverableArea(CoverableArea.PENIS, true) && npc.hasVagina() && npc.isAbleToAccessCoverableArea(CoverableArea.VAGINA, true);
                    boolean canBeImpregnated = slave.hasSlavePermissionSetting(SlavePermissionSetting.SEX_IMPREGNATED) && npc.hasSlavePermissionSetting(SlavePermissionSetting.SEX_IMPREGNATE) && npc.hasPenis() && npc.isAbleToAccessCoverableArea(CoverableArea.PENIS, true) && slave.hasVagina() && slave.isAbleToAccessCoverableArea(CoverableArea.VAGINA, true);
                    boolean impregnationAttempt = false, gettingPregnantAttempt = false;
                    // Apply sex effects:
                    if (canImpregnate) {
                        npc.rollForPregnancy(slave);
                        if (slave.getPenisRawCumProductionValue() > 0) {
                            npc.addStatusEffect(StatusEffect.CREAMPIE_VAGINA, 240);
                        }
                        npc.setVaginaVirgin(false);
                        impregnationAttempt = true;
                    }
                    if (canBeImpregnated) {
                        slave.rollForPregnancy(npc);
                        if (npc.getPenisRawCumProductionValue() > 0) {
                            slave.addStatusEffect(StatusEffect.CREAMPIE_VAGINA, 240);
                        }
                        slave.setVaginaVirgin(false);
                        gettingPregnantAttempt = true;
                    }
                    slave.setLastTimeHadSex((day * 24 * 60l) + hour * 60l, true);
                    switch(slave.getSlaveJob()) {
                        case CLEANING:
                            return new SlaveryEventLogEntry(hour, slave, SlaveEvent.SLAVE_SEX, null, Util.newArrayListOfValues(new ListValue<>("While dusting one of the first-floor corridors, " + slave.getName() + " caught sight of [npc.name]," + " and couldn't resist pulling [npc.herHim] into an empty room and giving [npc.herHim] a " + slave.getSexPaceDomPreference().getName() + " fucking." + (impregnationAttempt ? UtilText.parse(npc, "</br>[style.colourSex([npc.Name] might have gotten pregnant!)]") : "") + (gettingPregnantAttempt ? "</br>[style.colourSex(" + slave.getName() + " might have gotten pregnant!)]" : ""))), true);
                        case // TODO
                        IDLE:
                            return new SlaveryEventLogEntry(hour, slave, SlaveEvent.SLAVE_SEX, null, Util.newArrayListOfValues(new ListValue<>(slave.getName() + " gave [npc.name] a " + slave.getSexPaceDomPreference().getName() + " fucking." + (impregnationAttempt ? UtilText.parse(npc, "</br>[style.colourSex([npc.Name] might have gotten pregnant!)]") : "") + (gettingPregnantAttempt ? "</br>[style.colourSex(" + slave.getName() + " might have gotten pregnant!)]" : ""))), true);
                        case KITCHEN:
                            return new SlaveryEventLogEntry(hour, slave, SlaveEvent.SLAVE_SEX, null, Util.newArrayListOfValues(new ListValue<>("While working in the kitchen, " + slave.getName() + " saw [npc.name] enter the pantry alone," + " and couldn't resist following [npc.herHim] inside, before locking the door and giving [npc.herHim] a " + slave.getSexPaceDomPreference().getName() + " fucking." + (impregnationAttempt ? UtilText.parse(npc, "</br>[style.colourSex([npc.Name] might have gotten pregnant!)]") : "") + (gettingPregnantAttempt ? "</br>[style.colourSex(" + slave.getName() + " might have gotten pregnant!)]" : ""))), true);
                        case LAB_ASSISTANT:
                        case TEST_SUBJECT:
                            return new SlaveryEventLogEntry(hour, slave, SlaveEvent.SLAVE_SEX, null, Util.newArrayListOfValues(new ListValue<>("When Lilaya left the lab to take a break, " + slave.getName() + " used the opportunity to give [npc.name] a " + slave.getSexPaceDomPreference().getName() + " fucking on one of the lab's tables." + (impregnationAttempt ? UtilText.parse(npc, "</br>[style.colourSex([npc.Name] might have gotten pregnant!)]") : "") + (gettingPregnantAttempt ? "</br>[style.colourSex(" + slave.getName() + " might have gotten pregnant!)]" : ""))), true);
                        case LIBRARY:
                            return new SlaveryEventLogEntry(hour, slave, SlaveEvent.SLAVE_SEX, null, Util.newArrayListOfValues(new ListValue<>(slave.getName() + " pulled [npc.name] behind one of the shelves in the Library, before giving [npc.herHim] a " + slave.getSexPaceDomPreference().getName() + " fucking." + (impregnationAttempt ? UtilText.parse(npc, "</br>[style.colourSex([npc.Name] might have gotten pregnant!)]") : "") + (gettingPregnantAttempt ? "</br>[style.colourSex(" + slave.getName() + " might have gotten pregnant!)]" : ""))), true);
                        case PUBLIC_STOCKS:
                            break;
                    }
                }
            }
        }
    }
    return null;
}
Also used : NPC(com.lilithsthrone.game.character.npc.NPC) ListValue(com.lilithsthrone.utils.Util.ListValue) SlaveryEventLogEntry(com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry)

Example 3 with SlaveryEventLogEntry

use of com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry in project liliths-throne-public by Innoxia.

the class Game method exportGame.

public static void exportGame(String exportFileName, boolean allowOverwrite) {
    File dir = new File("data/");
    dir.mkdir();
    dir = new File("data/saves");
    dir.mkdir();
    boolean overwrite = false;
    if (dir.isDirectory()) {
        File[] directoryListing = dir.listFiles((path, filename) -> filename.endsWith(".xml"));
        if (directoryListing != null) {
            for (File child : directoryListing) {
                if (child.getName().equals(exportFileName + ".xml")) {
                    if (!allowOverwrite) {
                        Main.game.flashMessage(Colour.GENERIC_BAD, "Name already exists!");
                        return;
                    } else {
                        overwrite = true;
                    }
                }
            }
        }
    }
    try {
        if (timeLog) {
            timeStart = System.nanoTime();
            System.out.println(timeStart);
        }
        // Starting stuff:
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.newDocument();
        // Writing game stuff to export:
        Element game = doc.createElement("game");
        doc.appendChild(game);
        Element informationNode = doc.createElement("coreInfo");
        game.appendChild(informationNode);
        CharacterUtils.addAttribute(doc, informationNode, "version", Main.VERSION_NUMBER);
        CharacterUtils.addAttribute(doc, informationNode, "minutesPassed", String.valueOf(Main.game.minutesPassed));
        CharacterUtils.addAttribute(doc, informationNode, "debugMode", String.valueOf(Main.game.debugMode));
        CharacterUtils.addAttribute(doc, informationNode, "imperialMeasurements", String.valueOf(Main.game.imperialMeasurements));
        CharacterUtils.addAttribute(doc, informationNode, "weather", Main.game.currentWeather.toString());
        CharacterUtils.addAttribute(doc, informationNode, "nextStormTime", String.valueOf(Main.game.nextStormTime));
        CharacterUtils.addAttribute(doc, informationNode, "weatherTimeRemaining", String.valueOf(Main.game.weatherTimeRemaining));
        Element dateNode = doc.createElement("date");
        informationNode.appendChild(dateNode);
        CharacterUtils.addAttribute(doc, dateNode, "year", String.valueOf(Main.game.startingDate.getYear()));
        CharacterUtils.addAttribute(doc, dateNode, "month", String.valueOf(Main.game.startingDate.getMonthValue()));
        CharacterUtils.addAttribute(doc, dateNode, "dayOfMonth", String.valueOf(Main.game.startingDate.getDayOfMonth()));
        CharacterUtils.addAttribute(doc, dateNode, "hour", String.valueOf(Main.game.startingDate.getHour()));
        CharacterUtils.addAttribute(doc, dateNode, "minute", String.valueOf(Main.game.startingDate.getMinute()));
        Main.game.dialogueFlags.saveAsXML(game, doc);
        Element eventLogNode = doc.createElement("eventLog");
        game.appendChild(eventLogNode);
        for (EventLogEntry event : Main.game.getEventLog().subList(Math.max(0, Main.game.getEventLog().size() - 50), Main.game.getEventLog().size())) {
            event.saveAsXML(eventLogNode, doc);
        }
        Element slaveryEventLogNode = doc.createElement("slaveryEventLog");
        game.appendChild(slaveryEventLogNode);
        for (int day : Main.game.getSlaveryEventLog().keySet()) {
            Element element = doc.createElement("day");
            slaveryEventLogNode.appendChild(element);
            CharacterUtils.addAttribute(doc, element, "value", String.valueOf(day));
            for (SlaveryEventLogEntry event : Main.game.getSlaveryEventLog().get(day)) {
                event.saveAsXML(element, doc);
            }
        }
        // Add maps:
        Element mapNode = doc.createElement("maps");
        game.appendChild(mapNode);
        for (World world : Main.game.getWorlds().values()) {
            if (world != null) {
                world.saveAsXML(mapNode, doc);
            }
        }
        // Add player:
        Element characterNode = doc.createElement("playerCharacter");
        game.appendChild(characterNode);
        Main.game.getPlayer().saveAsXML(characterNode, doc);
        // Add all NPCs:
        for (GameCharacter character : Main.game.getNPCMap().values()) {
            characterNode = doc.createElement("NPC");
            game.appendChild(characterNode);
            character.saveAsXML(characterNode, doc);
        }
        // Ending stuff:
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer1 = tf.newTransformer();
        transformer1.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        StringWriter writer = new StringWriter();
        transformer1.transform(new DOMSource(doc), new StreamResult(writer));
        // Save this xml:
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
        DOMSource source = new DOMSource(doc);
        String saveLocation = "data/saves/" + exportFileName + ".xml";
        StreamResult result = new StreamResult(new File(saveLocation));
        transformer.transform(source, result);
        if (!exportFileName.startsWith("AutoSave")) {
            if (overwrite) {
                Main.game.addEvent(new EventLogEntry(Main.game.getMinutesPassed(), "[style.colourGood(Game saved)]", saveLocation), false);
                Main.game.setContent(new Response("", "", Main.game.getCurrentDialogueNode()), false, Colour.GENERIC_GOOD, "Save game overwritten!");
            } else {
                Main.game.addEvent(new EventLogEntry(Main.game.getMinutesPassed(), "[style.colourGood(Game saved)]", saveLocation), false);
                Main.game.setContent(new Response("", "", Main.game.getCurrentDialogueNode()), false, Colour.GENERIC_GOOD, "Game saved!");
            }
        }
        if (timeLog) {
            System.out.println("Difference: " + (System.nanoTime() - timeStart) / 1000000000f);
        }
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (TransformerException tfe) {
        tfe.printStackTrace();
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) EventLogEntry(com.lilithsthrone.game.dialogue.eventLog.EventLogEntry) SlaveryEventLogEntry(com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) World(com.lilithsthrone.world.World) Response(com.lilithsthrone.game.dialogue.responses.Response) StringWriter(java.io.StringWriter) DocumentBuilder(javax.xml.parsers.DocumentBuilder) GameCharacter(com.lilithsthrone.game.character.GameCharacter) SlaveryEventLogEntry(com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) File(java.io.File) TransformerException(javax.xml.transform.TransformerException)

Aggregations

SlaveryEventLogEntry (com.lilithsthrone.game.dialogue.eventLog.SlaveryEventLogEntry)3 NPC (com.lilithsthrone.game.character.npc.NPC)2 GameCharacter (com.lilithsthrone.game.character.GameCharacter)1 EventLogEntry (com.lilithsthrone.game.dialogue.eventLog.EventLogEntry)1 Response (com.lilithsthrone.game.dialogue.responses.Response)1 ListValue (com.lilithsthrone.utils.Util.ListValue)1 Cell (com.lilithsthrone.world.Cell)1 World (com.lilithsthrone.world.World)1 File (java.io.File)1 StringWriter (java.io.StringWriter)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Transformer (javax.xml.transform.Transformer)1 TransformerException (javax.xml.transform.TransformerException)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1