Class Shop


  • public class Shop
    extends java.lang.Object
    A class that represents a shop, providing various methods for interacting with the shop's items.
    • Constructor Summary

      Constructors 
      Constructor Description
      Shop()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<Item> all()
      Retrieves a list of all available items in the shop container.
      static java.util.List<Item> all​(java.util.function.Predicate<Item> predicate)
      Returns a list of all items in the shop that satisfy the given predicate.
      static int capacity()
      Returns the capacity of the shop.
      static boolean close()
      Closes the shop if it is currently open.
      static boolean contains​(int... itemIds)
      Checks if the shop contains any of the specified item IDs.
      static boolean contains​(java.lang.String... itemNames)
      Checks if any of the given item names are present in the shop.
      static boolean contains​(java.util.function.Predicate<Item> predicate)
      Determines if any item in the shop matches the given predicate.
      static boolean containsAll​(int... ids)
      Checks if all the given IDs are present in the list of items in the shop.
      static boolean containsAll​(java.lang.String... names)
      Determines if all the specified names are contained in the list of items.
      static boolean containsAll​(Item... checkItems)
      Checks if a list of items are all contained in the shop.
      static int count​(int id)
      Retrieves and returns the amount of a specific item in the shop.
      static int count​(java.lang.String name)
      Returns the amount of a specific item in a shop inventory.
      static int count​(java.util.function.Predicate<Item> predicate)
      Returns the total amount of items in the shop that satisfy the given predicate.
      static int emptySlotCount()
      Returns the number of empty slots available in the shop's inventory.
      static java.util.List<Item> except​(java.util.function.Predicate<Item> predicate)
      Returns a list of items from the shop excluding the ones that satisfy the given predicate.
      static Item get​(int... ids)
      Retrieves an Item from the Shop by its ID.
      static Item get​(java.lang.String... names)
      Retrieves an Item by its name from the Shop's list of all items.
      static Item get​(java.util.function.Predicate<Item> predicate)
      Retrieves an Item that satisfies the given predicate from all available items in the shop.
      static int getFirstEmptySlot()
      Returns the first empty slot in the shop.
      static int getIdForSlot​(int slot)
      Retrieves the ID of the item in the given slot.
      static Item getItemInSlot​(int slot)
      Returns the item in the specified slot of the shop's container widget.
      static java.lang.String getNameForSlot​(int slot)
      Retrieves the name of the item in the specified slot.
      static boolean isEmpty()
      Checks if the shop is empty.
      static boolean isFull()
      Checks if the shop is full.
      static boolean isOpen()
      Checks if the shop interface is currently open.
      static boolean onlyContains​(int... ids)
      Checks if the items in the shop only contain the specified IDs.
      static boolean onlyContains​(java.lang.String... names)
      Checks if all items returned by the "all" method have names that match the specified names.
      static boolean onlyContains​(java.util.function.Predicate<Item> predicate)
      Checks if all items in the shop meet a specified condition.
      static boolean purchaseFifty​(int itemId)
      Purchases fifty of the specified item from the shop.
      static boolean purchaseFifty​(java.lang.String itemName)
      Purchases fifty of a specified item from the shop.
      static boolean purchaseFifty​(java.util.function.Predicate<Item> predicate)
      Purchases fifty items from the shop that match the given predicate.
      static boolean purchaseFifty​(Item item)
      Purchases fifty quantities of the specified item from the shop.
      static boolean purchaseFive​(int itemId)
      Purchases five of a specified item from the shop.
      static boolean purchaseFive​(java.lang.String itemName)
      Purchases five instances of the specified item from the shop.
      static boolean purchaseFive​(java.util.function.Predicate<Item> predicate)
      Purchases five items from the shop based on the given predicate.
      static boolean purchaseFive​(Item item)
      Purchases five items of the specified type from the shop.
      static boolean purchaseOne​(int itemId)
      Purchases one unit of an item from the shop.
      static boolean purchaseOne​(java.lang.String itemName)
      Purchases one unit of the specified item from the shop.
      static boolean purchaseOne​(java.util.function.Predicate<Item> predicate)
      Purchases one item from the shop that matches the given predicate.
      static boolean purchaseOne​(Item item)
      Purchases one instance of a specified item from the shop.
      static boolean purchaseTen​(int itemId)
      Purchases ten items of a given item ID from the shop.
      static boolean purchaseTen​(java.lang.String itemName)
      Purchases ten of the specified item from the shop.
      static boolean purchaseTen​(java.util.function.Predicate<Item> predicate)
      Purchases ten items from the shop based on the given predicate.
      static boolean purchaseTen​(Item item)
      Purchases ten of the specified item from the shop.
      static boolean sellFifty​(int itemId)
      Sells fifty of a specified item in the shop.
      static boolean sellFifty​(java.lang.String itemName)
      Sells fifty of a specified item in the shop.
      static boolean sellFifty​(java.util.function.Predicate<Item> predicate)
      Sells fifty items from the shop that match the given predicate.
      static boolean sellFifty​(Item item)
      Sells fifty of the specified item in the current shop.
      static boolean sellFive​(int itemId)
      Sells five of a specified item in the shop.
      static boolean sellFive​(java.lang.String itemName)
      Sells five units of a specific item from the shop inventory.
      static boolean sellFive​(java.util.function.Predicate<Item> predicate)
      Sells five items from the shop based on the given predicate.
      static boolean sellFive​(Item item)
      Sells five quantities of the specified item in the shop.
      static boolean sellOne​(int itemId)
      Sells a single item from the shop.
      static boolean sellOne​(java.lang.String itemName)
      Sells one item of a specified name in the shop.
      static boolean sellOne​(java.util.function.Predicate<Item> predicate)
      Sells one item from the shop that matches the given predicate.
      static boolean sellOne​(Item item)
      Sells one quantity of the specified item to the shop.
      static boolean sellTen​(int itemId)
      Sells ten of the specified item in the shop.
      static boolean sellTen​(java.lang.String itemName)
      Sells ten quantities of the specified item in the shop.
      static boolean sellTen​(java.util.function.Predicate<Item> predicate)
      Sells ten items from the shop that meet the specified predicate.
      static boolean sellTen​(Item item)
      Sells ten quantities of a specified item in a shop.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Shop

        public Shop()
    • Method Detail

      • isOpen

        public static boolean isOpen()
        Checks if the shop interface is currently open.
        Returns:
        true if the shop interface is open, false otherwise.
      • close

        public static boolean close()
        Closes the shop if it is currently open.
        Returns:
        true if the shop is successfully closed, false otherwise.
      • all

        public static java.util.List<Item> all()
        Retrieves a list of all available items in the shop container.
        Returns:
        a list of Item objects representing the items in the shop container.
      • all

        public static java.util.List<Item> all​(java.util.function.Predicate<Item> predicate)
        Returns a list of all items in the shop that satisfy the given predicate.
        Parameters:
        predicate - the condition to be applied on each item
        Returns:
        a list of items that meet the given condition
      • except

        public static java.util.List<Item> except​(java.util.function.Predicate<Item> predicate)
        Returns a list of items from the shop excluding the ones that satisfy the given predicate.
        Parameters:
        predicate - the condition used to exclude items
        Returns:
        a list of items excluding the ones that satisfy the predicate
      • get

        public static Item get​(java.util.function.Predicate<Item> predicate)
        Retrieves an Item that satisfies the given predicate from all available items in the shop.
        Parameters:
        predicate - the condition to be tested on each Item
        Returns:
        the first encountered Item that matches the predicate, or null if no match is found
      • get

        public static Item get​(int... ids)
        Retrieves an Item from the Shop by its ID.
        Parameters:
        ids - the IDs of the items to search for in the Shop
        Returns:
        the Item with the matching ID, or null if not found
      • get

        public static Item get​(java.lang.String... names)
        Retrieves an Item by its name from the Shop's list of all items.
        Parameters:
        names - the names of the items to search for
        Returns:
        the Item with a matching name, or null if none is found
      • getItemInSlot

        public static Item getItemInSlot​(int slot)
        Returns the item in the specified slot of the shop's container widget.
        Parameters:
        slot - the slot of the item in the container
        Returns:
        the item in the specified slot, or null if no item is found
      • getFirstEmptySlot

        public static int getFirstEmptySlot()
        Returns the first empty slot in the shop.
        Returns:
        the first empty slot in the shop as an integer value.
      • getIdForSlot

        public static int getIdForSlot​(int slot)
        Retrieves the ID of the item in the given slot.
        Parameters:
        slot - the index of the inventory slot
        Returns:
        the ID of the item in the slot, or -1 if no item is present
      • getNameForSlot

        public static java.lang.String getNameForSlot​(int slot)
        Retrieves the name of the item in the specified slot.
        Parameters:
        slot - the slot from which to retrieve the item's name
        Returns:
        the name of the item in the slot, or null if the slot is empty
      • contains

        public static boolean contains​(int... itemIds)
        Checks if the shop contains any of the specified item IDs.
        Parameters:
        itemIds - the item IDs to check for
        Returns:
        true if the shop contains any of the item IDs, false otherwise
      • contains

        public static boolean contains​(java.lang.String... itemNames)
        Checks if any of the given item names are present in the shop.
        Parameters:
        itemNames - the array of item names to search for
        Returns:
        true if any of the item names are found in the shop, false otherwise
      • contains

        public static boolean contains​(java.util.function.Predicate<Item> predicate)
        Determines if any item in the shop matches the given predicate.
        Parameters:
        predicate - the condition to be tested on each item
        Returns:
        true if the shop contains an item that satisfies the predicate, false otherwise
      • containsAll

        public static boolean containsAll​(int... ids)
        Checks if all the given IDs are present in the list of items in the shop.
        Parameters:
        ids - the IDs to check for presence in the shop
        Returns:
        true if all the IDs are present, false otherwise
      • containsAll

        public static boolean containsAll​(java.lang.String... names)
        Determines if all the specified names are contained in the list of items.
        Parameters:
        names - the names to check for containment
        Returns:
        true if all the names are present, false otherwise
      • containsAll

        public static boolean containsAll​(Item... checkItems)
        Checks if a list of items are all contained in the shop.
        Parameters:
        checkItems - the items to be checked
        Returns:
        true if all items are present, false otherwise
      • onlyContains

        public static boolean onlyContains​(java.util.function.Predicate<Item> predicate)
        Checks if all items in the shop meet a specified condition.
        Parameters:
        predicate - the condition to be checked against each item
        Returns:
        true if all items satisfy the condition, false otherwise
      • onlyContains

        public static boolean onlyContains​(java.lang.String... names)
        Checks if all items returned by the "all" method have names that match the specified names.
        Parameters:
        names - the names to check against
        Returns:
        true if all items have names that match the specified names; otherwise, false
      • onlyContains

        public static boolean onlyContains​(int... ids)
        Checks if the items in the shop only contain the specified IDs.
        Parameters:
        ids - the array of IDs to check
        Returns:
        true if all items in the shop only have the specified IDs, false otherwise
      • count

        public static int count​(int id)
        Retrieves and returns the amount of a specific item in the shop.
        Parameters:
        id - the ID of the item to count
        Returns:
        the amount of the item in the shop, 0 if not found
      • count

        public static int count​(java.lang.String name)
        Returns the amount of a specific item in a shop inventory.
        Parameters:
        name - the name of the item to be counted
        Returns:
        the amount of the specified item in the shop inventory, or 0 if it does not exist
      • count

        public static int count​(java.util.function.Predicate<Item> predicate)
        Returns the total amount of items in the shop that satisfy the given predicate.
        Parameters:
        predicate - the condition used to filter the items in the shop
        Returns:
        the total amount of items that satisfy the predicate, or 0 if none are found
      • capacity

        public static int capacity()
        Returns the capacity of the shop.
        Returns:
        the capacity, which is currently set to 40.
      • isFull

        public static boolean isFull()
        Checks if the shop is full.
        Returns:
        true if the shop has 40 items, false otherwise.
      • isEmpty

        public static boolean isEmpty()
        Checks if the shop is empty.
        Returns:
        true if the shop is empty, false otherwise.
      • emptySlotCount

        public static int emptySlotCount()
        Returns the number of empty slots available in the shop's inventory.
        Returns:
        the count of empty slots in the shop's inventory
      • purchaseFifty

        public static boolean purchaseFifty​(Item item)
        Purchases fifty quantities of the specified item from the shop.
        Parameters:
        item - the item to purchase
        Returns:
        true if the purchase is successful, false otherwise
      • purchaseFifty

        public static boolean purchaseFifty​(int itemId)
        Purchases fifty of the specified item from the shop.
        Parameters:
        itemId - the ID of the item to be purchased
        Returns:
        true if the purchase is successful, false otherwise
      • purchaseFifty

        public static boolean purchaseFifty​(java.lang.String itemName)
        Purchases fifty of a specified item from the shop.
        Parameters:
        itemName - the name of the item to purchase
        Returns:
        true if the purchase is successful, false otherwise
      • purchaseFifty

        public static boolean purchaseFifty​(java.util.function.Predicate<Item> predicate)
        Purchases fifty items from the shop that match the given predicate.
        Parameters:
        predicate - the predicate to determine which items to purchase
        Returns:
        true if the purchase is successfully executed, false otherwise
      • purchaseTen

        public static boolean purchaseTen​(Item item)
        Purchases ten of the specified item from the shop.
        Parameters:
        item - the item to be purchased
        Returns:
        true if the purchase is successfully executed, false otherwise
      • purchaseTen

        public static boolean purchaseTen​(int itemId)
        Purchases ten items of a given item ID from the shop.
        Parameters:
        itemId - the ID of the item to purchase.
        Returns:
        true if the purchase is executed successfully, false otherwise.
      • purchaseTen

        public static boolean purchaseTen​(java.lang.String itemName)
        Purchases ten of the specified item from the shop.
        Parameters:
        itemName - the name of the item to purchase
        Returns:
        true if the purchase was successfully executed, false otherwise
      • purchaseTen

        public static boolean purchaseTen​(java.util.function.Predicate<Item> predicate)
        Purchases ten items from the shop based on the given predicate.
        Parameters:
        predicate - the condition to filter the items in the shop
        Returns:
        true if the purchase was successful, false otherwise
      • purchaseFive

        public static boolean purchaseFive​(Item item)
        Purchases five items of the specified type from the shop.
        Parameters:
        item - the item to be purchased
        Returns:
        true if the purchase was successful, false otherwise
      • purchaseFive

        public static boolean purchaseFive​(int itemId)
        Purchases five of a specified item from the shop.
        Parameters:
        itemId - the ID of the item to purchase
        Returns:
        true if the purchase is successful, false otherwise
      • purchaseFive

        public static boolean purchaseFive​(java.lang.String itemName)
        Purchases five instances of the specified item from the shop.
        Parameters:
        itemName - the name of the item to purchase
        Returns:
        true if the purchase is successfully executed, false otherwise
      • purchaseFive

        public static boolean purchaseFive​(java.util.function.Predicate<Item> predicate)
        Purchases five items from the shop based on the given predicate.
        Parameters:
        predicate - the condition to select the desired item
        Returns:
        true if the items are successfully purchased, false otherwise
      • purchaseOne

        public static boolean purchaseOne​(Item item)
        Purchases one instance of a specified item from the shop.
        Parameters:
        item - the item to be purchased
        Returns:
        true if the purchase is successful, false otherwise
      • purchaseOne

        public static boolean purchaseOne​(int itemId)
        Purchases one unit of an item from the shop.
        Parameters:
        itemId - the ID of the item to be purchased
        Returns:
        true if the purchase is successfully executed, false otherwise
      • purchaseOne

        public static boolean purchaseOne​(java.lang.String itemName)
        Purchases one unit of the specified item from the shop.
        Parameters:
        itemName - the name of the item to be purchased
        Returns:
        true if the purchase was successful, false otherwise
      • purchaseOne

        public static boolean purchaseOne​(java.util.function.Predicate<Item> predicate)
        Purchases one item from the shop that matches the given predicate.
        Parameters:
        predicate - the condition used to filter the items in the shop
        Returns:
        true if the purchase is successful, false otherwise
      • sellFifty

        public static boolean sellFifty​(Item item)
        Sells fifty of the specified item in the current shop.
        Parameters:
        item - the item to sell
        Returns:
        true if the selling action is successfully executed, false otherwise
      • sellFifty

        public static boolean sellFifty​(int itemId)
        Sells fifty of a specified item in the shop.
        Parameters:
        itemId - the ID of the item to sell
        Returns:
        true if the sale was executed successfully, false otherwise
      • sellFifty

        public static boolean sellFifty​(java.lang.String itemName)
        Sells fifty of a specified item in the shop.
        Parameters:
        itemName - the name of the item to sell
        Returns:
        true if the selling was executed successfully, false otherwise
      • sellFifty

        public static boolean sellFifty​(java.util.function.Predicate<Item> predicate)
        Sells fifty items from the shop that match the given predicate.
        Parameters:
        predicate - a predicate used to select the items to be sold
        Returns:
        true if the selling is executed successfully, false otherwise
      • sellTen

        public static boolean sellTen​(Item item)
        Sells ten quantities of a specified item in a shop.
        Parameters:
        item - the item to be sold
        Returns:
        true if the selling event was successfully executed, false otherwise
      • sellTen

        public static boolean sellTen​(int itemId)
        Sells ten of the specified item in the shop.
        Parameters:
        itemId - the ID of the item to be sold
        Returns:
        true if the sell event is successfully executed, false otherwise
      • sellTen

        public static boolean sellTen​(java.lang.String itemName)
        Sells ten quantities of the specified item in the shop.
        Parameters:
        itemName - the name of the item to be sold
        Returns:
        true if the selling event was successfully executed, false otherwise
      • sellTen

        public static boolean sellTen​(java.util.function.Predicate<Item> predicate)
        Sells ten items from the shop that meet the specified predicate.
        Parameters:
        predicate - the predicate used to filter the items
        Returns:
        true if the sell action was executed successfully, false otherwise
      • sellFive

        public static boolean sellFive​(Item item)
        Sells five quantities of the specified item in the shop.
        Parameters:
        item - the item to be sold
        Returns:
        true if the selling process is successfully executed, false otherwise
      • sellFive

        public static boolean sellFive​(int itemId)
        Sells five of a specified item in the shop.
        Parameters:
        itemId - the ID of the item to sell
        Returns:
        true if the sell event was successfully executed, false otherwise
      • sellFive

        public static boolean sellFive​(java.lang.String itemName)
        Sells five units of a specific item from the shop inventory.
        Parameters:
        itemName - the name of the item to be sold
        Returns:
        true if the selling action is successfully executed, false otherwise
      • sellFive

        public static boolean sellFive​(java.util.function.Predicate<Item> predicate)
        Sells five items from the shop based on the given predicate.
        Parameters:
        predicate - the condition to select the items to sell
        Returns:
        true if the items were successfully sold, false otherwise
      • sellOne

        public static boolean sellOne​(Item item)
        Sells one quantity of the specified item to the shop.
        Parameters:
        item - the item to be sold.
        Returns:
        true if the item was successfully sold, false otherwise.
      • sellOne

        public static boolean sellOne​(int itemId)
        Sells a single item from the shop.
        Parameters:
        itemId - the ID of the item to sell
        Returns:
        true if the item was sold successfully, false otherwise
      • sellOne

        public static boolean sellOne​(java.lang.String itemName)
        Sells one item of a specified name in the shop.
        Parameters:
        itemName - the name of the item to be sold
        Returns:
        true if the selling was executed successfully, false otherwise
      • sellOne

        public static boolean sellOne​(java.util.function.Predicate<Item> predicate)
        Sells one item from the shop that matches the given predicate.
        Parameters:
        predicate - the predicate used to match the item to be sold
        Returns:
        true if the item was successfully sold, false otherwise