Search in sources :

Example 1 with ShopTransaction

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();
}
Also used : NPC(com.lilithsthrone.game.character.npc.NPC) ShopTransaction(com.lilithsthrone.game.inventory.ShopTransaction) AbstractWeapon(com.lilithsthrone.game.inventory.weapon.AbstractWeapon)

Example 2 with ShopTransaction

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();
}
Also used : NPC(com.lilithsthrone.game.character.npc.NPC) ShopTransaction(com.lilithsthrone.game.inventory.ShopTransaction) AbstractItem(com.lilithsthrone.game.inventory.item.AbstractItem)

Example 3 with ShopTransaction

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();
}
Also used : NPC(com.lilithsthrone.game.character.npc.NPC) AbstractClothing(com.lilithsthrone.game.inventory.clothing.AbstractClothing) ShopTransaction(com.lilithsthrone.game.inventory.ShopTransaction)

Aggregations

NPC (com.lilithsthrone.game.character.npc.NPC)3 ShopTransaction (com.lilithsthrone.game.inventory.ShopTransaction)3 AbstractClothing (com.lilithsthrone.game.inventory.clothing.AbstractClothing)1 AbstractItem (com.lilithsthrone.game.inventory.item.AbstractItem)1 AbstractWeapon (com.lilithsthrone.game.inventory.weapon.AbstractWeapon)1