Search in sources :

Example 6 with Colour

use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.

the class AbstractClothing method loadFromXML.

public static AbstractClothing loadFromXML(Element parentElement, Document doc) {
    AbstractClothing clothing = null;
    try {
        clothing = AbstractClothingType.generateClothing(ClothingType.getClothingTypeFromId(parentElement.getAttribute("id")), false);
    } catch (Exception ex) {
        System.err.println("Warning: An instance of AbstractClothing was unable to be imported. (" + parentElement.getAttribute("id") + ")");
        return null;
    }
    if (clothing == null) {
        System.err.println("Warning: An instance of AbstractClothing was unable to be imported. (" + parentElement.getAttribute("id") + ")");
        return null;
    }
    // Try to load colour:
    try {
        clothing.setColour(Colour.valueOf(parentElement.getAttribute("colour")));
        if (!parentElement.getAttribute("colourSecondary").isEmpty()) {
            Colour secColour = Colour.valueOf(parentElement.getAttribute("colourSecondary"));
            if (clothing.clothingType.getAllAvailableSecondaryColours().contains(secColour)) {
                clothing.setSecondaryColour(secColour);
            }
        }
        if (!parentElement.getAttribute("colourTertiary").isEmpty()) {
            Colour terColour = Colour.valueOf(parentElement.getAttribute("colourTertiary"));
            if (clothing.clothingType.getAllAvailableTertiaryColours().contains(terColour)) {
                clothing.setTertiaryColour(terColour);
            }
        }
    } catch (Exception ex) {
    }
    // Try to load core features:
    try {
        if (!parentElement.getAttribute("sealed").isEmpty()) {
            clothing.setSealed(Boolean.valueOf(parentElement.getAttribute("sealed")));
        }
        clothing.setDirty(Boolean.valueOf(parentElement.getAttribute("isDirty")));
        clothing.setEnchantmentKnown(Boolean.valueOf(parentElement.getAttribute("enchantmentKnown")));
    } catch (Exception ex) {
    }
    if (parentElement.getElementsByTagName("attributeModifiers") != null && parentElement.getElementsByTagName("attributeModifiers").getLength() > 0) {
        if (clothing.getClothingType().getClothingSet() == null) {
            clothing.getEffects().clear();
            Element element = (Element) parentElement.getElementsByTagName("attributeModifiers").item(0);
            for (int i = 0; i < element.getElementsByTagName("modifier").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("modifier").item(i));
                try {
                    Attribute att = Attribute.valueOf(e.getAttribute("attribute"));
                    int value = Integer.valueOf(e.getAttribute("value"));
                    TFPotency pot = TFPotency.BOOST;
                    if (value <= -5) {
                        pot = TFPotency.MAJOR_DRAIN;
                    } else if (value <= -3) {
                        pot = TFPotency.DRAIN;
                    } else if (value <= -1) {
                        pot = TFPotency.MINOR_DRAIN;
                    } else if (value <= 1) {
                        pot = TFPotency.MINOR_BOOST;
                    } else if (value <= 3) {
                        pot = TFPotency.BOOST;
                    } else {
                        pot = TFPotency.MAJOR_BOOST;
                    }
                    for (TFModifier mod : TFModifier.getClothingAttributeList()) {
                        if (mod.getAssociatedAttribute() == att) {
                            clothing.addEffect(new ItemEffect(ItemEffectType.CLOTHING, TFModifier.CLOTHING_ATTRIBUTE, mod, pot, 0));
                            break;
                        }
                    }
                } catch (Exception ex) {
                }
            }
        }
    } else {
        try {
            clothing.getEffects().clear();
            Element element = (Element) parentElement.getElementsByTagName("effects").item(0);
            for (int i = 0; i < element.getElementsByTagName("effect").getLength(); i++) {
                Element e = ((Element) element.getElementsByTagName("effect").item(i));
                clothing.addEffect(ItemEffect.loadFromXML(e, doc));
            }
        } catch (Exception ex) {
        }
    }
    // Try to load displacements:
    try {
        clothing.displacedList = new ArrayList<>();
        Element displacementElement = (Element) parentElement.getElementsByTagName("displacedList").item(0);
        for (int i = 0; i < displacementElement.getElementsByTagName("displacementType").getLength(); i++) {
            Element e = ((Element) displacementElement.getElementsByTagName("displacementType").item(i));
            clothing.displacedList.add(DisplacementType.valueOf(e.getAttribute("value")));
        }
    } catch (Exception ex) {
    }
    return clothing;
}
Also used : TFModifier(com.lilithsthrone.game.inventory.enchanting.TFModifier) Attribute(com.lilithsthrone.game.character.attributes.Attribute) Element(org.w3c.dom.Element) TFPotency(com.lilithsthrone.game.inventory.enchanting.TFPotency) ItemEffect(com.lilithsthrone.game.inventory.item.ItemEffect) Colour(com.lilithsthrone.utils.Colour)

Example 7 with Colour

use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.

the class AbstractClothingType method generateClothing.

/**
 * Generates clothing with the provided enchantments.
 */
public static AbstractClothing generateClothing(AbstractClothingType clothingType, Colour primaryColour, Colour secondaryColour, Colour tertiaryColour, List<ItemEffect> effects) {
    Colour c1 = primaryColour;
    Colour c2 = secondaryColour;
    Colour c3 = tertiaryColour;
    if (clothingType.getAllAvailablePrimaryColours() != null) {
        if (!clothingType.getAllAvailablePrimaryColours().contains(primaryColour)) {
            c1 = clothingType.getAllAvailablePrimaryColours().get(Util.random.nextInt(clothingType.getAllAvailablePrimaryColours().size()));
        }
    }
    if (secondaryColour == null || !clothingType.getAllAvailableSecondaryColours().contains(secondaryColour)) {
        if (clothingType.getAvailableSecondaryColours().isEmpty()) {
            c2 = Colour.CLOTHING_BLACK;
        } else {
            c2 = clothingType.getAvailableSecondaryColours().get(Util.random.nextInt(clothingType.getAvailableSecondaryColours().size()));
        }
    }
    if (tertiaryColour == null || !clothingType.getAllAvailableTertiaryColours().contains(tertiaryColour)) {
        if (clothingType.getAvailableTertiaryColours().isEmpty()) {
            c3 = Colour.CLOTHING_BLACK;
        } else {
            c3 = clothingType.getAvailableTertiaryColours().get(Util.random.nextInt(clothingType.getAvailableTertiaryColours().size()));
        }
    }
    return new AbstractClothing(clothingType, c1, c2, c3, effects) {

        private static final long serialVersionUID = 1L;
    };
}
Also used : Colour(com.lilithsthrone.utils.Colour)

Example 8 with Colour

use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.

the class AbstractClothingType method generateClothing.

public static AbstractClothing generateClothing(AbstractClothingType clothingType, Colour primaryColour, Colour secondaryColour, Colour tertiaryColour, boolean allowRandomEnchantment) {
    Colour c1 = primaryColour;
    Colour c2 = secondaryColour;
    Colour c3 = tertiaryColour;
    if (clothingType.getAllAvailablePrimaryColours() != null) {
        if (!clothingType.getAllAvailablePrimaryColours().contains(primaryColour)) {
            c1 = clothingType.getAllAvailablePrimaryColours().get(Util.random.nextInt(clothingType.getAllAvailablePrimaryColours().size()));
        }
    }
    if (secondaryColour == null) {
        if (clothingType.getAvailableSecondaryColours().isEmpty()) {
            c2 = Colour.CLOTHING_BLACK;
        } else {
            c2 = clothingType.getAvailableSecondaryColours().get(Util.random.nextInt(clothingType.getAvailableSecondaryColours().size()));
        }
    } else if (!clothingType.getAllAvailableSecondaryColours().contains(secondaryColour)) {
        if (clothingType.getAllAvailableSecondaryColours().isEmpty()) {
            c2 = Colour.CLOTHING_BLACK;
        } else {
            c2 = clothingType.getAllAvailableSecondaryColours().get(Util.random.nextInt(clothingType.getAllAvailableSecondaryColours().size()));
        }
    }
    if (tertiaryColour == null) {
        if (clothingType.getAvailableTertiaryColours().isEmpty()) {
            c3 = Colour.CLOTHING_BLACK;
        } else {
            c3 = clothingType.getAvailableTertiaryColours().get(Util.random.nextInt(clothingType.getAvailableTertiaryColours().size()));
        }
    } else if (!clothingType.getAllAvailableTertiaryColours().contains(tertiaryColour)) {
        if (clothingType.getAllAvailableTertiaryColours().isEmpty()) {
            c3 = Colour.CLOTHING_BLACK;
        } else {
            c3 = clothingType.getAllAvailableTertiaryColours().get(Util.random.nextInt(clothingType.getAllAvailableTertiaryColours().size()));
        }
    }
    return new AbstractClothing(clothingType, c1, c2, c3, allowRandomEnchantment) {

        private static final long serialVersionUID = 1L;
    };
}
Also used : Colour(com.lilithsthrone.utils.Colour)

Example 9 with Colour

use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.

the class EnchantingUtils method getImportedSVGString.

public static String getImportedSVGString(AbstractCoreItem item, Colour importedColour, List<ItemEffect> effects) {
    if (((AbstractItem) item).getItemType().getId().equals(ItemType.ORIENTATION_HYPNO_WATCH.getId())) {
        if (effects.isEmpty() || effects.get(0).getPrimaryModifier() == TFModifier.REMOVAL) {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchBase();
        }
        if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_GYNEPHILIC) {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchGynephilic();
        } else if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_AMBIPHILIC) {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAmbiphilic();
        } else {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAndrophilic();
        }
    }
    StringBuilder SVGImageSB = new StringBuilder();
    String importedColourString = SVGImages.SVG_IMAGE_PROVIDER.getRefinedBackgroundMap().get(importedColour);
    if (importedColourString == null || importedColourString.isEmpty() || importedColourString.equals("null")) {
        importedColourString = SVGImages.SVG_IMAGE_PROVIDER.getRefinedBackgroundMap().get(effects.get(0).getItemEffectType().getColour());
    }
    SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + importedColourString + "</div>");
    String s = item.getSVGString();
    Colour colour = Colour.CLOTHING_BLUE_LIGHT;
    for (ItemEffect ie : effects) {
        if (ie.getPrimaryModifier() != null && ie.getPrimaryModifier() != TFModifier.NONE) {
            colour = ie.getPrimaryModifier().getColour();
            break;
        }
    }
    s = s.replaceAll("#ff2a2a", colour.getShades()[0]);
    s = s.replaceAll("#ff5555", colour.getShades()[1]);
    s = s.replaceAll("#ff8080", colour.getShades()[2]);
    s = s.replaceAll("#ffaaaa", colour.getShades()[3]);
    s = s.replaceAll("#ffd5d5", colour.getShades()[4]);
    SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + s + "</div>");
    for (ItemEffect ie : effects) {
        if (ie.getSecondaryModifier() != null && ie.getSecondaryModifier() != TFModifier.NONE) {
            SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + SVGImages.SVG_IMAGE_PROVIDER.getRefinedSwirlsMap().get(ie.getSecondaryModifier().getColour()) + "</div>");
            break;
        }
    }
    return SVGImageSB.toString();
}
Also used : ItemEffect(com.lilithsthrone.game.inventory.item.ItemEffect) AbstractItem(com.lilithsthrone.game.inventory.item.AbstractItem) Colour(com.lilithsthrone.utils.Colour)

Example 10 with Colour

use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.

the class EnchantingUtils method getSVGString.

public static String getSVGString(AbstractCoreItem ingredient, List<ItemEffect> effects) {
    if (ingredient.getEnchantmentItemType(effects) instanceof AbstractClothingType) {
        return ingredient.getSVGString();
    }
    if (((AbstractItem) ingredient).getItemType().getId().equals(ItemType.ORIENTATION_HYPNO_WATCH.getId())) {
        if (effects.isEmpty() || effects.get(0).getPrimaryModifier() == TFModifier.REMOVAL) {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchBase();
        }
        if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_GYNEPHILIC) {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchGynephilic();
        } else if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_AMBIPHILIC) {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAmbiphilic();
        } else {
            return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAndrophilic();
        }
    }
    StringBuilder SVGImageSB = new StringBuilder();
    SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + SVGImages.SVG_IMAGE_PROVIDER.getRefinedBackgroundMap().get(ingredient.getEnchantmentEffect().getColour()) + "</div>");
    String s = ((AbstractItemType) ingredient.getEnchantmentItemType(effects)).getSVGString();
    Colour colour = Colour.CLOTHING_BLUE_LIGHT;
    for (ItemEffect ie : effects) {
        if (ie.getPrimaryModifier() != null && ie.getPrimaryModifier() != TFModifier.NONE) {
            colour = ie.getPrimaryModifier().getColour();
            break;
        }
    }
    s = s.replaceAll("#ff2a2a", colour.getShades()[0]);
    s = s.replaceAll("#ff5555", colour.getShades()[1]);
    s = s.replaceAll("#ff8080", colour.getShades()[2]);
    s = s.replaceAll("#ffaaaa", colour.getShades()[3]);
    s = s.replaceAll("#ffd5d5", colour.getShades()[4]);
    SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + s + "</div>");
    for (ItemEffect ie : effects) {
        if (ie.getSecondaryModifier() != null && ie.getSecondaryModifier() != TFModifier.NONE) {
            SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + SVGImages.SVG_IMAGE_PROVIDER.getRefinedSwirlsMap().get(ie.getSecondaryModifier().getColour()) + "</div>");
            break;
        }
    }
    return SVGImageSB.toString();
}
Also used : AbstractItemType(com.lilithsthrone.game.inventory.item.AbstractItemType) AbstractClothingType(com.lilithsthrone.game.inventory.clothing.AbstractClothingType) ItemEffect(com.lilithsthrone.game.inventory.item.ItemEffect) AbstractItem(com.lilithsthrone.game.inventory.item.AbstractItem) Colour(com.lilithsthrone.utils.Colour)

Aggregations

Colour (com.lilithsthrone.utils.Colour)16 AbstractItem (com.lilithsthrone.game.inventory.item.AbstractItem)5 ItemEffect (com.lilithsthrone.game.inventory.item.ItemEffect)5 AbstractClothingType (com.lilithsthrone.game.inventory.clothing.AbstractClothingType)4 AbstractItemType (com.lilithsthrone.game.inventory.item.AbstractItemType)4 Attribute (com.lilithsthrone.game.character.attributes.Attribute)3 StatusEffect (com.lilithsthrone.game.character.effects.StatusEffect)3 Fetish (com.lilithsthrone.game.character.fetishes.Fetish)3 Gender (com.lilithsthrone.game.character.gender.Gender)3 GenderPreference (com.lilithsthrone.game.character.gender.GenderPreference)3 TFModifier (com.lilithsthrone.game.inventory.enchanting.TFModifier)3 TFPotency (com.lilithsthrone.game.inventory.enchanting.TFPotency)3 ArrayList (java.util.ArrayList)3 Entry (java.util.Map.Entry)3 EnchantmentEventListener (com.lilithsthrone.controller.eventListeners.EnchantmentEventListener)2 InventorySelectedItemEventListener (com.lilithsthrone.controller.eventListeners.InventorySelectedItemEventListener)2 InventoryTooltipEventListener (com.lilithsthrone.controller.eventListeners.InventoryTooltipEventListener)2 SetContentEventListener (com.lilithsthrone.controller.eventListeners.SetContentEventListener)2 TooltipHideEventListener (com.lilithsthrone.controller.eventListeners.TooltipHideEventListener)2 TooltipInformationEventListener (com.lilithsthrone.controller.eventListeners.TooltipInformationEventListener)2