Class ItemService

Object
ItemService

public class ItemService extends Object
Specific bean for the dropping, getting, selling and buying of items from containers, from rooms and from persons.
Author:
maartenl
  • Constructor Details

    • ItemService

      @Inject public ItemService(LogService logService)
  • Method Details

    • getEntityManager

      protected EntityManager getEntityManager()
      Returns the entity manager of JPA. This is defined in build/web/WEB-INF/classes/META-INF/persistence.xml.
      Returns:
      EntityManager
    • drop

      public boolean drop(Item item, Person person)
      Drops an item on the floor.
      Parameters:
      item - the item to be dropped.
      person - the person
      Returns:
      true if successful.
    • get

      public boolean get(Item item, Person person)
      Gets an item from off the floor/room.
      Parameters:
      item - the item to be retrieved from the room.
      person - the person
      Returns:
      true if successful.
    • give

      public boolean give(Item item, Person fromperson, Person toperson)
      Gives an item from one person to another person.
      Parameters:
      item - the item to be shared
      fromperson - the person giving the item
      toperson - the person receiving the item
      Returns:
      true if successful.
    • put

      public boolean put(Item item, Item container, Person person)
      Puts an item into a container.
      Parameters:
      item - the item to be put
      container - the container that the item should receive
      person - the person performing the action
      Returns:
      true if successful.
    • retrieve

      public boolean retrieve(Item item, Item container, Person person)
      Retrieves an item from a container.
      Parameters:
      item - the item to be retrieved
      container - the container that contains the item
      person - the person performing the action
      Returns:
      true if successful.
    • sell

      public Integer sell(Item item, User aUser, Shopkeeper shopkeeper)
      Sells an item from a user to a shopkeeper.
      Parameters:
      item - the item to be sold
      aUser - the user selling the item
      shopkeeper - the shopkeeper buying the item
      Returns:
      the amount of money transferred, or Null if it was unsuccessful.
    • buy

      public Integer buy(Item item, User aUser, Shopkeeper shopkeeper)
      Buys an item from a shopkeeper.
      Parameters:
      item - the item to be bought
      aUser - the user buying the item
      shopkeeper - the shopkeeper selling the item
      Returns:
      the amount of money transferred, or Null if it was unsuccessful.
    • createItem

      public Item createItem(long itemdefnr)