use of com.lilithsthrone.game.inventory.weapon.AbstractWeapon in project liliths-throne-public by Innoxia.
the class CharacterInventory method saveAsXML.
@Override
public Element saveAsXML(Element parentElement, Document doc) {
Element characterInventory = doc.createElement("characterInventory");
parentElement.appendChild(characterInventory);
CharacterUtils.createXMLElementWithValue(doc, characterInventory, "maxInventorySpace", String.valueOf(this.getMaximumInventorySpace()));
CharacterUtils.createXMLElementWithValue(doc, characterInventory, "money", String.valueOf(this.getMoney()));
CharacterUtils.createXMLElementWithValue(doc, characterInventory, "essences", String.valueOf(this.getEssenceCount(TFEssence.ARCANE)));
if (this.getMainWeapon() != null) {
Element mainWeapon = doc.createElement("mainWeapon");
characterInventory.appendChild(mainWeapon);
this.getMainWeapon().saveAsXML(mainWeapon, doc);
}
if (this.getOffhandWeapon() != null) {
Element offhandWeapon = doc.createElement("offhandWeapon");
characterInventory.appendChild(offhandWeapon);
this.getOffhandWeapon().saveAsXML(offhandWeapon, doc);
}
Element clothingEquipped = doc.createElement("clothingEquipped");
characterInventory.appendChild(clothingEquipped);
for (AbstractClothing clothing : this.getClothingCurrentlyEquipped()) {
clothing.saveAsXML(clothingEquipped, doc);
}
Element itemsInInventory = doc.createElement("itemsInInventory");
characterInventory.appendChild(itemsInInventory);
for (Entry<AbstractItem, Integer> item : this.getMapOfDuplicateItems().entrySet()) {
Element e = item.getKey().saveAsXML(itemsInInventory, doc);
CharacterUtils.addAttribute(doc, e, "count", String.valueOf(item.getValue()));
}
Element clothingInInventory = doc.createElement("clothingInInventory");
characterInventory.appendChild(clothingInInventory);
for (Entry<AbstractClothing, Integer> clothing : this.getMapOfDuplicateClothing().entrySet()) {
Element e = clothing.getKey().saveAsXML(clothingInInventory, doc);
CharacterUtils.addAttribute(doc, e, "count", String.valueOf(clothing.getValue()));
}
Element weaponsInInventory = doc.createElement("weaponsInInventory");
characterInventory.appendChild(weaponsInInventory);
for (Entry<AbstractWeapon, Integer> weapon : this.getMapOfDuplicateWeapons().entrySet()) {
Element e = weapon.getKey().saveAsXML(weaponsInInventory, doc);
CharacterUtils.addAttribute(doc, e, "count", String.valueOf(weapon.getValue()));
}
return characterInventory;
}
use of com.lilithsthrone.game.inventory.weapon.AbstractWeapon in project liliths-throne-public by Innoxia.
the class EnchantmentDialogue method craftItem.
public static void craftItem(AbstractCoreItem ingredient, List<ItemEffect> effects) {
if (ingredient instanceof AbstractItem) {
Main.game.getPlayer().removeItem((AbstractItem) ingredient);
AbstractItem craftedItem = EnchantingUtils.craftItem(ingredient, effects);
Main.game.getPlayer().addItem(craftedItem, false, true);
} else if (ingredient instanceof AbstractClothing) {
Main.game.getPlayer().removeClothing((AbstractClothing) ingredient);
AbstractClothing craftedClothing = EnchantingUtils.craftClothing(ingredient, effects);
Main.game.getPlayer().addClothing(craftedClothing, false);
} else if (ingredient instanceof AbstractWeapon) {
Main.game.getPlayer().removeWeapon((AbstractWeapon) ingredient);
}
Main.game.getPlayer().incrementEssenceCount(ingredient.getRelatedEssence(), -EnchantingUtils.getCost(ingredient, effects));
previousIngredient = ingredient;
previousPrimaryMod = primaryMod;
previousSecondaryMod = secondaryMod;
previousEffects.clear();
previousEffects.addAll(EnchantmentDialogue.effects);
resetEnchantmentVariables();
EnchantmentDialogue.effects.clear();
}
use of com.lilithsthrone.game.inventory.weapon.AbstractWeapon in project liliths-throne-public by Innoxia.
the class EnchantmentDialogue method inventoryView.
private static String inventoryView() {
inventorySB.setLength(0);
ItemEffect effect = new ItemEffect(ingredient.getEnchantmentEffect(), primaryMod, secondaryMod, potency, limit);
// Primary mods:
inventorySB.append("<div class='container-half-width' style='padding-bottom:0;'>");
for (TFModifier tfMod : ingredient.getEnchantmentEffect().getPrimaryModifiers()) {
inventorySB.append("<div class='modifier-icon " + tfMod.getRarity().getName() + "' style='width:11.5%;'>" + "<div class='modifier-icon-content'>" + tfMod.getSVGString() + "</div>" + "<div class='overlay' id='MOD_PRIMARY_" + tfMod.hashCode() + "'></div>" + "</div>");
}
for (int i = 32; i > ingredient.getEnchantmentEffect().getPrimaryModifiers().size(); i--) {
inventorySB.append("<div class='modifier-icon empty' style='width:11.5%;'></div>");
}
inventorySB.append("<div class='container-full-width'>" + "<div class='container-half-width' style='width:78%; margin:0 1%; text-align:center; line-height:100vh;'>" + "<h5 style='margin:0; padding:0;'>Primary Modifier</h5>" + "</div>" + "<div class='container-half-width' style='width:18%; margin:0 1%;'>");
if (primaryMod != null) {
inventorySB.append("<div class='modifier-icon " + primaryMod.getRarity().getName() + "' style='width:100%; margin:0;'>" + "<div class='modifier-icon-content'>" + primaryMod.getSVGString() + "</div>" + "<div class='overlay' id='MOD_PRIMARY_ENCHANTING'></div>" + "</div>");
} else {
inventorySB.append("<div class='modifier-icon empty' style='width:30%; margin:0 1%;'>" + "<div class='overlay' style='cursor:default;' id='MOD_PRIMARY_ENCHANTING'></div>" + "</div>");
}
inventorySB.append("</div></div>");
inventorySB.append("</div>");
// Secondary mods:
inventorySB.append("<div class='container-half-width' style='padding-bottom:0;'>");
for (TFModifier tfMod : ingredient.getEnchantmentEffect().getSecondaryModifiers(primaryMod)) {
inventorySB.append("<div class='modifier-icon " + tfMod.getRarity().getName() + "' style='width:11.5%;'>" + "<div class='modifier-icon-content'>" + tfMod.getSVGString() + "</div>" + "<div class='overlay' id='MOD_SECONDARY_" + tfMod.hashCode() + "'></div>" + "</div>");
}
for (int i = 32; i > ingredient.getEnchantmentEffect().getSecondaryModifiers(primaryMod).size(); i--) {
inventorySB.append("<div class='modifier-icon empty' style='width:11.5%;'></div>");
}
inventorySB.append("<div class='container-full-width'>" + "<div class='container-half-width' style='width:18%; margin:0 1%;'>");
if (secondaryMod != null) {
inventorySB.append("<div class='modifier-icon " + secondaryMod.getRarity().getName() + "' style='width:100%; margin:0;'>" + "<div class='modifier-icon-content'>" + secondaryMod.getSVGString() + "</div>" + "<div class='overlay' id='MOD_SECONDARY_ENCHANTING'></div>" + "</div>");
} else {
inventorySB.append("<div class='modifier-icon empty' style='width:30%; margin:0 1%;'>" + "<div class='overlay' style='cursor:default;' id='MOD_SECONDARY_ENCHANTING'></div>" + "</div>");
}
inventorySB.append("</div>" + "<div class='container-half-width' style='width:78%; margin:0 1%; text-align:center; line-height:100vh;'>" + "<h5 style='margin:0; padding:0;'>Secondary Modifier</h5>" + "</div>" + "</div>");
inventorySB.append("</div>");
// Potency:
inventorySB.append("<div class='container-full-width' style='text-align:center; padding:8px 0; margin-top:0;'>");
for (TFPotency potency : TFPotency.values()) {
inventorySB.append("<div class='normal-button" + (ingredient.getEnchantmentEffect().getPotencyModifiers(primaryMod, secondaryMod).contains(potency) ? "" : " disabled") + (EnchantmentDialogue.potency == potency ? " selected" : "") + "' id='POTENCY_" + potency + "'" + " style='" + (EnchantmentDialogue.potency == potency ? "color:" + potency.getColour().toWebHexString() + ";" : "") + " margin:0 1%; width:14%;'>" + potency.getName() + "</div>");
}
inventorySB.append("</div>");
// Limits:
int ingredientLimit = ingredient.getEnchantmentEffect().getLimits(primaryMod, secondaryMod);
if (ingredientLimit != 0) {
inventorySB.append("<div class='container-full-width' style='text-align:center; padding:8px 0; margin-top:0;'>" + "<div style='float:left; width:14.6%; margin:0 1%; padding:0;'>" + "<div class='normal-button" + (limit == 0 ? " disabled" : "") + "' id='LIMIT_MINIMUM' style='width:100%;'>Limit Min.</div>" + "</div>" + "<div style='float:left; width:14.6%; margin:0 1%; padding:0;'>" + "<div class='normal-button" + (limit == 0 ? " disabled" : "") + "' id='LIMIT_DECREASE_LARGE' style='width:100%;'>Limit--</div>" + "</div>" + "<div style='float:left; width:14.6%; margin:0 1%; padding:0;'>" + "<div class='normal-button" + (limit == 0 ? " disabled" : "") + "' id='LIMIT_DECREASE' style='width:100%;'>Limit-</div>" + "</div>" + "<div style='float:left; width:14.6%; margin:0 1%; padding:0;'>" + "<div class='normal-button" + (limit == ingredientLimit ? " disabled" : "") + "' id='LIMIT_INCREASE' style='width:100%;'>Limit+</div>" + "</div>" + "<div style='float:left; width:14.6%; margin:0 1%; padding:0;'>" + "<div class='normal-button" + (limit == ingredientLimit ? " disabled" : "") + "' id='LIMIT_INCREASE_LARGE' style='width:100%;'>Limit++</div>" + "</div>" + "<div style='float:left; width:14.6%; margin:0 1%; padding:0;'>" + "<div class='normal-button" + (limit == ingredientLimit ? " disabled" : "") + "' id='LIMIT_MAXIMUM' style='width:100%;'>Limit Max.</div>" + "</div>" + "</div>");
}
// Effect:
inventorySB.append("<div class='container-full-width' style='text-align:center; padding:8px 0; margin-top:0;'>");
inventorySB.append("<div class='container-half-width' style='width:28%; margin:0 1%;'>" + "<b style='color:" + ingredient.getRelatedEssence().getColour().toWebHexString() + ";'>Effect to be added:</b>" + "</div>");
inventorySB.append("<div class='container-half-width' style='width:48%; margin:0 1%;'>");
int i = 0;
if (effect.getEffectsDescription(Main.game.getPlayer(), Main.game.getPlayer()) != null) {
if (i > 0) {
inventorySB.append("</br>");
}
for (String s : effect.getEffectsDescription(Main.game.getPlayer(), Main.game.getPlayer())) {
inventorySB.append("<b>" + Util.capitaliseSentence(s) + "</b>");
}
i++;
} else {
inventorySB.append("<b>-</b>");
}
inventorySB.append("</div>");
inventorySB.append("<div class='container-half-width' style='width:18%; margin:0 1%;'>");
if (effects.size() >= ingredient.getEnchantmentLimit() || ingredient.getEnchantmentEffect().getEffectsDescription(primaryMod, secondaryMod, potency, limit, Main.game.getPlayer(), Main.game.getPlayer()) == null || ingredient.getEnchantmentEffect().getEffectsDescription(primaryMod, secondaryMod, potency, limit, Main.game.getPlayer(), Main.game.getPlayer()).isEmpty()) {
inventorySB.append("<div class='normal-button disabled' style='width:100%; margin:auto 0;'>" + "<b>Add</b> | " + UtilText.formatAsEssencesUncoloured(effect.getCost(), "b", false) + "<div class='overlay no-pointer' id='ENCHANT_ADD_BUTTON_DISABLED'></div>" + "</div>");
} else {
inventorySB.append("<div class='normal-button' style='width:100%; margin:auto 0;'>" + "<b style='color:" + Colour.GENERIC_GOOD.toWebHexString() + ";'>Add</b> | " + UtilText.formatAsEssences(effect.getCost(), "b", false) + "<div class='overlay' id='ENCHANT_ADD_BUTTON'></div>" + "</div>");
}
inventorySB.append("</div>");
inventorySB.append("</div>");
// Item crafting:
inventorySB.append("<div class='container-full-width' style='text-align:center; padding:8px 0; margin-top:0;'>");
int count = 1;
if (ingredient instanceof AbstractItem) {
count = Main.game.getPlayer().getItemCount((AbstractItem) ingredient);
} else if (ingredient instanceof AbstractClothing) {
count = Main.game.getPlayer().getClothingCount((AbstractClothing) ingredient);
} else if (ingredient instanceof AbstractWeapon) {
count = Main.game.getPlayer().getWeaponCount((AbstractWeapon) ingredient);
}
inventorySB.append("<div class='container-half-width' style='width:18%; margin:0 1%; text-align:center;'>");
inventorySB.append("<b>Input</b>" + "<div class='enchanting-ingredient " + ingredient.getRarity().getName() + "'>" + "<div class='enchanting-ingredient-content'>" + ingredient.getSVGString() + "</div>" + "<div class='overlay' id='INGREDIENT_ENCHANTING'></div>" + "<div class='enchanting-ingredient-count'><b>x" + count + "</b></div>" + "</div>");
inventorySB.append("</div>");
// Effects:
inventorySB.append("<div class='container-half-width' style='width:58%; margin:0 1%;'>");
inventorySB.append("<b>Effects (</b>" + (effects.size() >= ingredient.getEnchantmentLimit() ? "<b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" : "<b>") + "" + effects.size() + "/" + ingredient.getEnchantmentLimit() + "</b><b>)</b></br>" + "<b>" + Util.capitaliseSentence(EnchantingUtils.getPotionName(ingredient, effects)) + "</b> | Cost: " + UtilText.formatAsEssences(EnchantingUtils.getCost(ingredient, effects), "b", false));
if (effects.isEmpty()) {
inventorySB.append("</br><span style='color:" + Colour.TEXT_GREY.toWebHexString() + ";'>No effects added</span>");
} else {
i = 0;
for (ItemEffect ie : effects) {
for (String s : ie.getEffectsDescription(Main.game.getPlayer(), Main.game.getPlayer())) {
inventorySB.append("<div class='container-full-width' style='background:" + RenderingEngine.getEntryBackgroundColour(i % 2 == 0) + "; width:98%; margin:0 1%; padding:2px;'>" + Util.capitaliseSentence(s) + (ingredient.getEffects().size() > i && ingredient.getEffects().get(i).equals(ie) ? "<div class='normal-button' style='width:64px; height:22px; line-height:22px; font-size:16px; margin:0; padding:0 0 0 4px; float:right; text-align:left;'>" + "<b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>X</b> " + UtilText.formatAsEssences(ie.getCost(), "b", false) + "<div class='overlay' id='DELETE_EFFECT_" + i + "'></div></div>" : "<div class='normal-button' id='DELETE_EFFECT_" + i + "'" + " style='width:22px; height:22px; line-height:22px; font-size:16px; margin:0; padding:0; float:right; color:" + Colour.GENERIC_BAD.toWebHexString() + ";'><b>X</b></div>") + "</div>");
i++;
}
}
}
inventorySB.append("</div>");
inventorySB.append("<div class='container-half-width' style='width:18%; margin:0 1%; text-align:center;'>");
inventorySB.append("<b>Output</b>" + "<div class='enchanting-ingredient " + ingredient.getEnchantmentItemType(effects).getRarity().getName() + "'>" + "<div class='enchanting-ingredient-content'>" + EnchantingUtils.getSVGString(ingredient, effects) + "</div>" + "<div class='overlay' id='OUTPUT_ENCHANTING'></div>" + "</div>");
inventorySB.append("</div>");
inventorySB.append("</div>");
return inventorySB.toString();
}
use of com.lilithsthrone.game.inventory.weapon.AbstractWeapon in project liliths-throne-public by Innoxia.
the class Cell method resetInventory.
public void resetInventory(List<Rarity> rarityOfItemsToSave) {
if (rarityOfItemsToSave != null && !rarityOfItemsToSave.isEmpty()) {
List<AbstractItem> itemsToSave = new ArrayList<>();
for (AbstractItem item : this.inventory.getItemsInInventory()) {
if (rarityOfItemsToSave.contains(item.getRarity())) {
itemsToSave.add(item);
}
}
List<AbstractWeapon> weaponsToSave = new ArrayList<>();
for (AbstractWeapon weapon : this.inventory.getWeaponsInInventory()) {
if (rarityOfItemsToSave.contains(weapon.getRarity())) {
weaponsToSave.add(weapon);
}
}
List<AbstractClothing> clothingToSave = new ArrayList<>();
for (AbstractClothing clothing : this.inventory.getClothingInInventory()) {
if (rarityOfItemsToSave.contains(clothing.getRarity())) {
clothingToSave.add(clothing);
}
}
this.inventory = new CharacterInventory(0, 48);
for (AbstractItem item : itemsToSave) {
this.inventory.addItem(item);
}
for (AbstractWeapon weapon : weaponsToSave) {
this.inventory.addWeapon(weapon);
}
for (AbstractClothing clothing : clothingToSave) {
this.inventory.addClothing(clothing);
}
} else {
this.inventory = new CharacterInventory(0, 48);
}
}
Aggregations