use of com.lilithsthrone.game.inventory.item.ItemEffect in project liliths-throne-public by Innoxia.
the class Nyan method generateRareClothing.
private static AbstractClothing generateRareClothing(AbstractClothingType type) {
List<ItemEffect> effects = new ArrayList<>();
List<TFModifier> attributeMods = new ArrayList<>(TFModifier.getClothingAttributeList());
TFModifier rndMod = attributeMods.get(Util.random.nextInt(attributeMods.size()));
attributeMods.remove(rndMod);
TFModifier rndMod2 = attributeMods.get(Util.random.nextInt(attributeMods.size()));
effects.add(new ItemEffect(ItemEffectType.CLOTHING, TFModifier.CLOTHING_ATTRIBUTE, rndMod, TFPotency.MAJOR_BOOST, 0));
effects.add(new ItemEffect(ItemEffectType.CLOTHING, TFModifier.CLOTHING_ATTRIBUTE, rndMod2, TFPotency.MAJOR_BOOST, 0));
return AbstractClothingType.generateClothing(type, type.getAvailablePrimaryColours().get(Util.random.nextInt(type.getAvailablePrimaryColours().size())), effects);
}
use of com.lilithsthrone.game.inventory.item.ItemEffect in project liliths-throne-public by Innoxia.
the class AbstractClothing method saveAsXML.
public Element saveAsXML(Element parentElement, Document doc) {
Element element = doc.createElement("clothing");
parentElement.appendChild(element);
CharacterUtils.addAttribute(doc, element, "id", this.getClothingType().getId());
CharacterUtils.addAttribute(doc, element, "colour", this.getColour().toString());
CharacterUtils.addAttribute(doc, element, "colourSecondary", this.getSecondaryColour().toString());
CharacterUtils.addAttribute(doc, element, "colourTertiary", this.getTertiaryColour().toString());
CharacterUtils.addAttribute(doc, element, "isDirty", String.valueOf(this.isDirty()));
CharacterUtils.addAttribute(doc, element, "enchantmentKnown", String.valueOf(this.isEnchantmentKnown()));
Element innerElement = doc.createElement("effects");
element.appendChild(innerElement);
for (ItemEffect ie : this.getEffects()) {
ie.saveAsXML(innerElement, doc);
}
innerElement = doc.createElement("displacedList");
element.appendChild(innerElement);
for (DisplacementType dt : this.getDisplacedList()) {
Element displacementType = doc.createElement("displacementType");
innerElement.appendChild(displacementType);
CharacterUtils.addAttribute(doc, displacementType, "value", dt.toString());
}
return element;
}
use of com.lilithsthrone.game.inventory.item.ItemEffect 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;
}
use of com.lilithsthrone.game.inventory.item.ItemEffect in project liliths-throne-public by Innoxia.
the class AbstractClothingType method generateClothingWithEnchantment.
/**
* Generates clothing with a random enchantment.
*/
public static AbstractClothing generateClothingWithEnchantment(AbstractClothingType clothingType, Colour colour) {
List<ItemEffect> effects = new ArrayList<>();
TFModifier rndMod = TFModifier.getClothingAttributeList().get(Util.random.nextInt(TFModifier.getClothingAttributeList().size()));
effects.add(new ItemEffect(ItemEffectType.CLOTHING, TFModifier.CLOTHING_ATTRIBUTE, rndMod, TFPotency.getRandomWeightedPositivePotency(), 0));
return generateClothing(clothingType, colour, effects);
}
use of com.lilithsthrone.game.inventory.item.ItemEffect in project liliths-throne-public by Innoxia.
the class EnchantingUtils method getPotionName.
public static String getPotionName(AbstractCoreItem ingredient, List<ItemEffect> effects) {
if (ingredient.getEnchantmentItemType(effects) instanceof AbstractClothingType) {
return Util.capitaliseSentence(ingredient.getName());
}
if (((AbstractItem) ingredient).getItemType().getId().equals(ItemType.ORIENTATION_HYPNO_WATCH.getId())) {
if (effects.isEmpty() || effects.get(0).getPrimaryModifier() == TFModifier.REMOVAL) {
return "Hypno-Watch";
}
if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_GYNEPHILIC) {
return "Gynephilic Hypno-Watch";
} else if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_AMBIPHILIC) {
return "Ambiphilic Hypno-Watch";
} else {
return "Androphilic Hypno-Watch";
}
}
String potionName = ((AbstractItemType) ingredient.getEnchantmentItemType(effects)).getName(false);
String potionDescriptor = "";
String potionSuffix = "";
// it was either PreSuffix or PrefixSuffix...
String potionPreSuffix = "";
if (ingredient != null) {
switch(ingredient.getEnchantmentEffect()) {
case ATTRIBUTE_CORRUPTION:
potionDescriptor = "viscous ";
break;
case ATTRIBUTE_ARCANE:
potionDescriptor = "soothing ";
break;
case ATTRIBUTE_PHYSIQUE:
potionDescriptor = "vivid ";
break;
case ATTRIBUTE_SEXUAL:
potionDescriptor = "aphrodisiac ";
break;
case RACE_CAT_MORPH:
potionDescriptor = "feline ";
break;
case RACE_DOG_MORPH:
potionDescriptor = "canine ";
break;
case RACE_HORSE_MORPH:
potionDescriptor = "equine ";
break;
case RACE_WOLF_MORPH:
potionDescriptor = "lupine ";
break;
case RACE_HARPY:
potionDescriptor = "avian ";
break;
case RACE_HUMAN:
potionDescriptor = "human ";
break;
case RACE_DEMON:
potionDescriptor = "demonic ";
break;
case RACE_COW_MORPH:
potionDescriptor = "bovine ";
break;
case RACE_SQUIRREL_MORPH:
potionDescriptor = "squirrel ";
break;
case RACE_ALLIGATOR_MORPH:
potionDescriptor = "alligator ";
break;
default:
break;
}
}
String finalPotionName = potionDescriptor + potionName;
for (ItemEffect ie : effects) {
if (ie.getPrimaryModifier() != null && ie.getPrimaryModifier() != TFModifier.NONE) {
potionSuffix = ie.getPrimaryModifier().getDescriptor();
if (ie.getSecondaryModifier() != TFModifier.NONE) {
potionPreSuffix = ie.getSecondaryModifier().getDescriptor();
}
if (potionSuffix != "") {
if (potionPreSuffix != "") {
if (ie.getSecondaryModifier().isSoloDescriptor())
finalPotionName += " of " + potionPreSuffix;
else
finalPotionName += " of " + potionPreSuffix + " " + potionSuffix;
} else {
finalPotionName += " of " + potionSuffix;
}
}
break;
}
}
return Util.capitaliseSentence(finalPotionName);
}
Aggregations