use of com.lilithsthrone.game.inventory.ShopTransaction in project liliths-throne-public by Innoxia.
the class InventoryDialogue method sellWeapons.
private static void sellWeapons(GameCharacter from, GameCharacter to, AbstractWeapon weapon, int count, int itemPrice) {
if (to.isPlayer() ? (!to.isInventoryFull() || to.hasWeapon(weapon)) : true) {
if (buyback && to.isPlayer()) {
Main.game.getPlayer().incrementMoney(-itemPrice);
from.incrementMoney(itemPrice);
Main.game.getPlayer().addWeapon(weapon, false);
Main.game.getPlayer().getBuybackStack().remove(buyBackIndex);
} else {
List<AbstractWeapon> weapons = from.getAllWeaponsInInventory().stream().filter(weapon::equals).collect(Collectors.toList());
for (int i = 0; i < count; i++) {
if (from.isPlayer()) {
Main.game.getPlayer().getBuybackStack().push(new ShopTransaction(weapon, itemPrice));
} else {
to.addWeapon(weapons.get(i), false);
}
from.incrementMoney(itemPrice);
to.incrementMoney(-itemPrice);
from.removeWeapon(weapons.get(i));
}
}
if (to.isPlayer()) {
((NPC) from).handleSellingEffects(weapon, count, itemPrice);
}
}
resetPostAction();
}
use of com.lilithsthrone.game.inventory.ShopTransaction in project liliths-throne-public by Innoxia.
the class InventoryDialogue method sellItems.
private static void sellItems(GameCharacter from, GameCharacter to, AbstractItem item, int count, int itemPrice) {
if (!to.isPlayer() || !to.isInventoryFull() || to.hasItem(item)) {
if (buyback && to.isPlayer()) {
Main.game.getPlayer().incrementMoney(-itemPrice);
from.incrementMoney(itemPrice);
Main.game.getPlayer().addItem(item, false, true);
Main.game.getPlayer().getBuybackStack().remove(buyBackIndex);
} else {
List<AbstractItem> items = from.getAllItemsInInventory().stream().filter(item::equals).collect(Collectors.toList());
for (int i = 0; i < count; i++) {
if (from.isPlayer()) {
Main.game.getPlayer().getBuybackStack().push(new ShopTransaction(item, itemPrice));
} else {
to.addItem(items.get(i), false);
}
from.incrementMoney(itemPrice);
to.incrementMoney(-itemPrice);
from.removeItem(items.get(i));
}
}
if (to.isPlayer()) {
((NPC) from).handleSellingEffects(item, count, itemPrice);
}
}
resetPostAction();
}
use of com.lilithsthrone.game.inventory.ShopTransaction in project liliths-throne-public by Innoxia.
the class InventoryDialogue method sellClothing.
private static void sellClothing(GameCharacter from, GameCharacter to, AbstractClothing clothing, int count, int itemPrice) {
if (to.isPlayer() ? (!to.isInventoryFull() || to.hasClothing(clothing)) : true) {
if (buyback && to.isPlayer()) {
Main.game.getPlayer().incrementMoney(-itemPrice);
from.incrementMoney(itemPrice);
Main.game.getPlayer().addClothing(clothing, false);
Main.game.getPlayer().getBuybackStack().remove(buyBackIndex);
} else {
List<AbstractClothing> clothings = from.getAllClothingInInventory().stream().filter(clothing::equals).collect(Collectors.toList());
for (int i = 0; i < count; i++) {
if (from.isPlayer()) {
Main.game.getPlayer().getBuybackStack().push(new ShopTransaction(clothing, itemPrice));
} else {
to.addClothing(clothings.get(i), false);
}
from.incrementMoney(itemPrice);
to.incrementMoney(-itemPrice);
from.removeClothing(clothings.get(i));
}
}
if (to.isPlayer()) {
((NPC) from).handleSellingEffects(clothing, count, itemPrice);
}
}
resetPostAction();
}
Aggregations