use of com.lilithsthrone.game.inventory.CharacterInventory in project liliths-throne-public by Innoxia.
the class GameCharacter method resetInventory.
/**
* First unequips all clothing into void, so that clothing effects are preserved.
*/
public void resetInventory() {
unequipAllClothingIntoVoid();
this.inventory = new CharacterInventory(0);
}
use of com.lilithsthrone.game.inventory.CharacterInventory in project liliths-throne-public by Innoxia.
the class PlayerCharacter method loadFromXML.
public static PlayerCharacter loadFromXML(StringBuilder log, Element parentElement, Document doc, CharacterImportSetting... settings) {
PlayerCharacter character = new PlayerCharacter(new NameTriplet(""), "", 0, Gender.F_V_B_FEMALE, RacialBody.HUMAN, RaceStage.HUMAN, new CharacterInventory(0), WorldType.DOMINION, PlaceType.DOMINION_AUNTS_HOME);
GameCharacter.loadGameCharacterVariablesFromXML(character, log, parentElement, doc, settings);
NodeList nodes = parentElement.getElementsByTagName("core");
Element element = (Element) nodes.item(0);
String version = "";
if (element.getElementsByTagName("version").item(0) != null) {
version = ((Element) element.getElementsByTagName("version").item(0)).getAttribute("value");
}
Element playerSpecificElement = (Element) parentElement.getElementsByTagName("playerSpecific").item(0);
if (playerSpecificElement != null) {
if (playerSpecificElement.getElementsByTagName("title").getLength() != 0) {
character.setTitle(((Element) playerSpecificElement.getElementsByTagName("title").item(0)).getAttribute("value"));
}
if (playerSpecificElement.getElementsByTagName("karma").getLength() != 0) {
character.setKarma(Integer.valueOf(((Element) playerSpecificElement.getElementsByTagName("karma").item(0)).getAttribute("value")));
}
if (playerSpecificElement.getElementsByTagName("mainQuestUpdated").getLength() != 0) {
character.setMainQuestUpdated(Boolean.valueOf(((Element) playerSpecificElement.getElementsByTagName("mainQuestUpdated").item(0)).getAttribute("value")));
}
if (playerSpecificElement.getElementsByTagName("sideQuestUpdated").getLength() != 0) {
character.setSideQuestUpdated(Boolean.valueOf(((Element) playerSpecificElement.getElementsByTagName("sideQuestUpdated").item(0)).getAttribute("value")));
}
if (playerSpecificElement.getElementsByTagName("romanceQuestUpdated").getLength() != 0) {
character.setRomanceQuestUpdated(Boolean.valueOf(((Element) playerSpecificElement.getElementsByTagName("romanceQuestUpdated").item(0)).getAttribute("value")));
}
try {
if (playerSpecificElement.getElementsByTagName("racesDiscovered").item(0) != null) {
for (int i = 0; i < ((Element) playerSpecificElement.getElementsByTagName("racesDiscovered").item(0)).getElementsByTagName("race").getLength(); i++) {
Element e = (Element) ((Element) playerSpecificElement.getElementsByTagName("racesDiscovered").item(0)).getElementsByTagName("race").item(i);
character.addRaceDiscoveredFromBook(Race.valueOf(e.getAttribute("value")));
}
}
} catch (Exception ex) {
}
if (playerSpecificElement.getElementsByTagName("charactersEncountered").item(0) != null) {
for (int i = 0; i < ((Element) playerSpecificElement.getElementsByTagName("charactersEncountered").item(0)).getElementsByTagName("id").getLength(); i++) {
Element e = (Element) ((Element) playerSpecificElement.getElementsByTagName("charactersEncountered").item(0)).getElementsByTagName("id").item(i);
character.addCharacterEncountered(e.getAttribute("value"));
}
}
if (Main.isVersionOlderThan(version, "0.1.99.5")) {
if (playerSpecificElement.getElementsByTagName("questMap").item(0) != null) {
for (int i = 0; i < ((Element) playerSpecificElement.getElementsByTagName("questMap").item(0)).getElementsByTagName("entry").getLength(); i++) {
Element e = (Element) ((Element) playerSpecificElement.getElementsByTagName("questMap").item(0)).getElementsByTagName("entry").item(i);
try {
int progress = Integer.valueOf(e.getAttribute("progress"));
QuestLine questLine = QuestLine.valueOf(e.getAttribute("questLine"));
TreeNode<Quest> q = questLine.getQuestTree();
for (int it = 0; it < progress; it++) {
if (!q.getChildren().isEmpty()) {
q = q.getChildren().get(0);
}
}
// // Add one if quest is complete: (This is due to adding a 'complete quest' at the end of each quest line.)
// if(questLine!=QuestLine.MAIN && !q.getChildren().isEmpty() && q.getChildren().get(0).getChildren().isEmpty()) {
// q = q.getChildren().get(0);
// }
character.quests.put(questLine, q.getData());
} catch (Exception ex) {
System.err.println("ERR Quest!");
}
}
}
} else {
if (playerSpecificElement.getElementsByTagName("questMap").item(0) != null) {
for (int i = 0; i < ((Element) playerSpecificElement.getElementsByTagName("questMap").item(0)).getElementsByTagName("entry").getLength(); i++) {
Element e = (Element) ((Element) playerSpecificElement.getElementsByTagName("questMap").item(0)).getElementsByTagName("entry").item(i);
try {
character.quests.put(QuestLine.valueOf(e.getAttribute("questLine")), Quest.valueOf(e.getAttribute("quest")));
} catch (Exception ex) {
}
}
}
}
}
return character;
}
use of com.lilithsthrone.game.inventory.CharacterInventory 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