Search in sources :

Example 1 with SlaveInStocks

use of com.lilithsthrone.game.character.npc.dominion.SlaveInStocks in project liliths-throne-public by Innoxia.

the class Game method endTurn.

public void endTurn(int turnTime, boolean advanceTime) {
    // long tStart = System.nanoTime();
    long startHour = getHour();
    if (advanceTime) {
        minutesPassed += turnTime;
        updateResponses();
    }
    if (Main.game.getCurrentWeather() != Weather.SNOW && Main.game.getSeason() != Season.WINTER) {
        Main.game.getDialogueFlags().values.remove(DialogueFlagValue.hasSnowedThisWinter);
        for (NPC npc : Main.game.getReindeerOverseers()) {
            if (npc.getLocation() != Main.game.getPlayer().getLocation()) {
                npc.setLocation(WorldType.EMPTY, PlaceType.GENERIC_EMPTY_TILE, true);
            }
        }
    }
    // Slavery: TODO
    int hoursPassed = (int) (getHour() - startHour);
    int hourStartTo24 = (int) (startHour % 24);
    for (int i = 1; i <= hoursPassed; i++) {
        slaveryUtil.performHourlyUpdate(this.getDayNumber(startHour * 60 + i * 60), (hourStartTo24 + i) % 24);
    }
    // If the time has passed midnight on this turn:
    boolean newDay = ((int) (minutesPassed / (60 * 24)) != (int) (((minutesPassed - turnTime) / (60 * 24))));
    if (newDay) {
        // TODO replace with methods in each GenericPlace:
        AbstractClothing goggles = AbstractClothingType.generateClothing(ClothingType.SCIENTIST_EYES_SAFETY_GOGGLES, Colour.CLOTHING_BLACK, false);
        if (!Main.game.getWorlds().get(WorldType.LILAYAS_HOUSE_GROUND_FLOOR).getCell(PlaceType.LILAYA_HOME_LAB).getInventory().hasClothing(goggles)) {
            Main.game.getWorlds().get(WorldType.LILAYAS_HOUSE_GROUND_FLOOR).getCell(PlaceType.LILAYA_HOME_LAB).getInventory().addClothing(goggles);
        }
        pendingSlaveInStocksReset = true;
        // Reindeer:
        for (NPC npc : Main.game.getReindeerOverseers()) {
            if (npc.getLocationPlace().getPlaceType() == PlaceType.DOMINION_STREET && !npc.getLocation().equals(Main.game.getPlayer().getLocation())) {
                npc.moveToAdjacentMatchingCellType();
                Main.game.getDialogueFlags().dailyReindeerReset(npc.getId());
            }
        }
    }
    if (pendingSlaveInStocksReset && Main.game.getPlayer().getLocationPlace().getPlaceType() != PlaceType.SLAVER_ALLEY_PUBLIC_STOCKS) {
        for (NPC npc : Main.game.getCharactersPresent(Main.game.getWorlds().get(WorldType.SLAVER_ALLEY).getCell(PlaceType.SLAVER_ALLEY_PUBLIC_STOCKS))) {
            if (npc instanceof SlaveInStocks) {
                Main.game.banishNPC(npc);
            }
        }
        for (int i = 0; i < 4; i++) {
            SlaveInStocks slave = new SlaveInStocks(GenderPreference.getGenderFromUserPreferences());
            if (Math.random() > 0.5f) {
                Main.game.getGenericFemaleNPC().addSlave(slave);
            } else {
                Main.game.getGenericMaleNPC().addSlave(slave);
            }
            try {
                Main.game.addNPC(slave, false);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        pendingSlaveInStocksReset = false;
    }
    handleAtmosphericConditions(turnTime);
    // Apply status effects and update all NPCs:
    isInNPCUpdateLoop = true;
    for (NPC npc : NPCMap.values()) {
        // Remove Dominion attackers if they aren't in alleyways: TODO this is because storm attackers need to be removed after a storm
        if (npc.getLocationPlace().getPlaceType() != PlaceType.DOMINION_BACK_ALLEYS && npc.getWorldLocation() == WorldType.DOMINION && npc instanceof DominionAlleywayAttacker && !Main.game.getPlayer().getLocation().equals(npc.getLocation())) {
            banishNPC(npc);
        }
        // Non-slave NPCs clean clothes:
        if (!npc.isSlave() && !Main.game.getPlayer().getLocation().equals(npc.getLocation())) {
            npc.cleanAllClothing();
            npc.cleanAllDirtySlots();
        }
        // Set NPC resource values:
        if (!Main.game.isInCombat() && !Main.game.isInSex()) {
            if (!Main.game.getPlayer().getLocation().equals(npc.getLocation())) {
                npc.setHealthPercentage(1);
                npc.setManaPercentage(1);
            // npc.setLust(npc.getRestingLust());
            }
            npc.alignLustToRestingLust(turnTime * 10);
        }
        npc.calculateStatusEffects(turnTime);
        if ((npc.isPendingClothingDressing() || (!npc.isSlave() && !npc.isUnique() && (npc.hasStatusEffect(StatusEffect.EXPOSED) || npc.hasStatusEffect(StatusEffect.EXPOSED_BREASTS) || npc.hasStatusEffect(StatusEffect.EXPOSED_PLUS_BREASTS)))) && (Main.game.getCurrentDialogueNode().equals(Main.game.getPlayer().getLocationPlace().getDialogue(false)) || !(npc.getWorldLocation() == Main.game.getPlayer().getWorldLocation() && npc.getLocation().equals(Main.game.getPlayer().getLocation())))) {
            npc.equipClothing(true, true);
            npc.setPendingClothingDressing(false);
        }
        if (npc.isPendingTransformationToGenderIdentity()) {
            npc.setBody(npc.getGenderIdentity(), RacialBody.valueOfRace(npc.getRace()), npc.getRaceStage());
            CharacterUtils.randomiseBody(npc);
            npc.setPendingTransformationToGenderIdentity(false);
        }
        // Prostitutes stay on promiscuity pills to avoid pregnancies, and, if the NPC is male, to avoid knocking up their clients
        if ((!npc.isPregnant() && !npc.isSlave() && npc.getHistory() == History.PROSTITUTE && !npc.hasStatusEffect(StatusEffect.PROMISCUITY_PILL) && !npc.getLocation().equals(Main.game.getPlayer().getLocation())) || (npc.isSlave() && npc.getSlaveJobSettings().contains(SlaveJobSetting.SEX_PROMISCUITY_PILLS))) {
            npc.useItem(AbstractItemType.generateItem(ItemType.PROMISCUITY_PILL), npc, false);
        }
        if (npc.isSlave() && npc.getSlaveJobSettings().contains(SlaveJobSetting.SEX_VIXENS_VIRILITY)) {
            npc.useItem(AbstractItemType.generateItem(ItemType.VIXENS_VIRILITY), npc, false);
        }
        if (npc.hasStatusEffect(StatusEffect.PREGNANT_3) && (minutesPassed - npc.getTimeProgressedToFinalPregnancyStage()) > (12 * 60)) {
            if (npc instanceof Lilaya) {
                if (!Main.game.getDialogueFlags().values.contains(DialogueFlagValue.reactedToPregnancyLilaya)) {
                    // Lilaya will only end pregnancy after you've seen it.
                    npc.endPregnancy(true);
                }
            } else {
                npc.endPregnancy(true);
                if (npc instanceof Kate) {
                    Main.game.getDialogueFlags().values.remove(DialogueFlagValue.reactedToKatePregnancy);
                }
            }
        }
        if (npc.getLocation().equals(Main.game.getPlayer().getLocation()) && npc.getWorldLocation() == Main.game.getPlayer().getWorldLocation()) {
            for (CoverableArea ca : CoverableArea.values()) {
                if (npc.isCoverableAreaExposed(ca) && ca != CoverableArea.MOUTH) {
                    npc.getPlayerKnowsAreas().add(ca);
                }
            }
        }
        if (newDay) {
            npc.dailyReset();
        }
    }
    isInNPCUpdateLoop = false;
    for (NPC npc : npcsToRemove) {
        NPCMap.remove(npc.getId());
    }
    for (NPC npc : npcsToAdd) {
        NPCMap.put(npc.getId(), npc);
    }
    npcsToRemove.clear();
    npcsToAdd.clear();
    // If not in combat:
    if (!isInCombat()) {
        // Regenerate health and stamina over time:
        if (!isInSex() && !currentDialogueNode.isRegenerationDisabled()) {
            if (Main.game.getPlayer().getHealthPercentage() < 1) {
                Main.game.getPlayer().incrementHealth(turnTime * 0.1f);
            }
            if (Main.game.getPlayer().getManaPercentage() < 1) {
                Main.game.getPlayer().incrementMana(turnTime * 0.1f);
            }
            Main.game.getPlayer().alignLustToRestingLust(turnTime);
        }
    }
    if (Main.game.getCurrentDialogueNode() != MiscDialogue.STATUS_EFFECTS) {
        Main.game.getPlayer().calculateStatusEffects(turnTime);
    }
    RenderingEngine.ENGINE.renderButtons();
    Main.mainController.updateUI();
    Main.mainController.getTooltip().hide();
    if (!Main.game.getPlayer().getStatusEffectDescriptions().isEmpty() && Main.game.getCurrentDialogueNode() != MiscDialogue.STATUS_EFFECTS) {
        if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.NORMAL) {
            Main.game.saveDialogueNode();
        }
        Main.game.setContent(new Response("", "", MiscDialogue.STATUS_EFFECTS) {

            @Override
            public void effects() {
                if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_ENCHANTMENT_DISCOVERY) && Main.game.getPlayer().hasNonArcaneEssences()) {
                    Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().startQuest(QuestLine.SIDE_ENCHANTMENT_DISCOVERY));
                }
                if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_FIRST_TIME_PREGNANCY) && Main.game.getPlayer().isVisiblyPregnant()) {
                    Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().startQuest(QuestLine.SIDE_FIRST_TIME_PREGNANCY));
                }
            }
        });
        Main.game.getPlayer().getStatusEffectDescriptions().clear();
    }
// System.out.println((System.nanoTime()-tStart)/1000000000d+"s");
}
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) CoverableArea(com.lilithsthrone.game.character.body.CoverableArea) Kate(com.lilithsthrone.game.character.npc.dominion.Kate) AbstractClothing(com.lilithsthrone.game.inventory.clothing.AbstractClothing) TransformerException(javax.xml.transform.TransformerException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Lilaya(com.lilithsthrone.game.character.npc.dominion.Lilaya) Response(com.lilithsthrone.game.dialogue.responses.Response) SlaveInStocks(com.lilithsthrone.game.character.npc.dominion.SlaveInStocks) DominionAlleywayAttacker(com.lilithsthrone.game.character.npc.dominion.DominionAlleywayAttacker)

Aggregations

CoverableArea (com.lilithsthrone.game.character.body.CoverableArea)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 DominionAlleywayAttacker (com.lilithsthrone.game.character.npc.dominion.DominionAlleywayAttacker)1 Kate (com.lilithsthrone.game.character.npc.dominion.Kate)1 Lilaya (com.lilithsthrone.game.character.npc.dominion.Lilaya)1 SlaveInStocks (com.lilithsthrone.game.character.npc.dominion.SlaveInStocks)1 TestNPC (com.lilithsthrone.game.character.npc.dominion.TestNPC)1 Response (com.lilithsthrone.game.dialogue.responses.Response)1 AbstractClothing (com.lilithsthrone.game.inventory.clothing.AbstractClothing)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1