Class Room

Object
Room
All Implemented Interfaces:
Serializable, AttributeWrangler, DisplayInterface, ItemWrangler, Ownage

@Entity public class Room extends Object implements Serializable, DisplayInterface, ItemWrangler, AttributeWrangler, Ownage
A room. Bear in mind that this room has potential exits to the north, south, east, west, up and down, which are also rooms. The structure forms a kind of graph.
Author:
maartenl
See Also:
  • Field Details

    • STARTERS_ROOM

      public static final long STARTERS_ROOM
      The first room that new characters appear in.
      See Also:
  • Constructor Details

  • Method Details

    • getId

      public Long getId()
    • setId

      public void setId(Long id)
    • getContents

      public String getContents()
      A description of the room.
      Returns:
      a description
    • setContents

      public void setContents(String contents)
      Parameters:
      contents - the new description
      See Also:
    • getBody

      public String getBody()
      Description copied from interface: DisplayInterface
      The body to be displayed on the screen. In general the first letter of the body is converted to an image on the client side.
      Specified by:
      getBody in interface DisplayInterface
      Returns:
    • getCreation

      public LocalDateTime getCreation()
    • setCreation

      public void setCreation(LocalDateTime creation)
    • getTitle

      public String getTitle()
    • getMainTitle

      public String getMainTitle()
      Description copied from interface: DisplayInterface
      The title as visible on the screen.
      Specified by:
      getMainTitle in interface DisplayInterface
      Returns:
    • setTitle

      public void setTitle(String title)
    • getPicture

      public String getPicture()
    • getImage

      public String getImage()
      Description copied from interface: DisplayInterface
      Returns an url pointing to an image.
      Specified by:
      getImage in interface DisplayInterface
      Returns:
    • setPicture

      public void setPicture(String picture)
    • getOwner

      public Admin getOwner()
      Description copied from interface: Ownage
      Retrieves the owner, the administrator, of this object. In case this is null, anyone can edit the object.
      Specified by:
      getOwner in interface Ownage
      Returns:
    • setOwner

      public void setOwner(Admin owner)
      Description copied from interface: Ownage
      Sets the owner, the administrator, of this object.
      Specified by:
      setOwner in interface Ownage
      Parameters:
      owner - the owner/administrator of the object. In case this is null, which is allowed, any administrator can edit this object. This is what happens when an object is "disowned".
    • getRoomCollection

      public Collection<Room> getRoomCollection()
    • setRoomCollection

      public void setRoomCollection(Collection<Room> roomCollection)
    • getDown

      public Room getDown()
    • setDown

      public void setDown(Room down)
    • getRoomCollection1

      public Collection<Room> getRoomCollection1()
    • setRoomCollection1

      public void setRoomCollection1(Collection<Room> roomCollection1)
    • getUp

      public Room getUp()
    • setUp

      public void setUp(Room up)
    • getRoomCollection2

      public Collection<Room> getRoomCollection2()
    • setRoomCollection2

      public void setRoomCollection2(Collection<Room> roomCollection2)
    • getWest

      public Room getWest()
    • setWest

      public void setWest(Room west)
    • getRoomCollection3

      public Collection<Room> getRoomCollection3()
    • setRoomCollection3

      public void setRoomCollection3(Collection<Room> roomCollection3)
    • getEast

      public Room getEast()
    • setEast

      public void setEast(Room east)
    • getRoomCollection4

      public Collection<Room> getRoomCollection4()
    • setRoomCollection4

      public void setRoomCollection4(Collection<Room> roomCollection4)
    • getSouth

      public Room getSouth()
    • setSouth

      public void setSouth(Room south)
    • getRoomCollection5

      public Collection<Room> getRoomCollection5()
    • setRoomCollection5

      public void setRoomCollection5(Collection<Room> roomCollection5)
    • getNorth

      public Room getNorth()
    • setNorth

      public void setNorth(Room north)
    • getArea

      public Area getArea()
    • setArea

      public void setArea(Area area)
    • getAttributes

      public Set<Roomattribute> getAttributes()
    • setAttributes

      public void setAttributes(Set<Roomattribute> attributes)
    • getItems

      public Set<Item> getItems()
      Description copied from interface: ItemWrangler
      Retrieves a set of items that this entity has.
      Specified by:
      getItems in interface ItemWrangler
      Returns:
      A set of items.
    • setItems

      public void setItems(Set<Item> items)
    • getMinimumPoint

      public Position getMinimumPoint()
      Returns:
      Returns the minimum point of a cube.
    • getMaximumPoint

      public Position getMaximumPoint()
      Returns:
      Returns the maximum point of a cube.
    • getCenterPoint

      public Position getCenterPoint()
      Returns:
      Returns the center point of a cube. This is the point where a person can stand in the cube, if he previously didn't have any coordinates assigned but it in the room.
    • setMinimumPoint

      public void setMinimumPoint(Position position)
      Sets the minimum point of a cube.
    • setMaximumPoint

      public void setMaximumPoint(Position position)
      Sets the maximum point of a cube.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • retrievePerson

      public Person retrievePerson(String aName)
      retrieve the character from the list of characters currently active in the current room.
      Parameters:
      aName - name of the character to search for. Case matters not.
      Returns:
      Character/Person in the room. Will return null pointer if character not found.
      See Also:
    • retrieveUser

      public User retrieveUser(String aName)
      retrieve the player from the list of characters currently active in the current room.
      Parameters:
      aName - name of the player to search for.
      Returns:
      Player in the room. Will return null pointer if character not found or character is not a "real" player.
      See Also:
    • getBoard

      public Board getBoard(String aName)
      retrieve the board in the room. May be null if there is no board.
      Parameters:
      aName - name of the board to search for.
      Returns:
      Board in the room. Will return null pointer if board not found.
    • findItems

      public List<Item> findItems(List<String> parsed)
      Returns items if found, otherwise returns an empty list.
      Specified by:
      findItems in interface ItemWrangler
      Parameters:
      parsed - the parsed description of the item as given by the user, for example {"light-green", "leather", "pants"}.
      Returns:
      list of found items, empty if not found.
    • removeAttribute

      public boolean removeAttribute(String name)
      Description copied from interface: AttributeWrangler
      Removes an attribute by name.
      Specified by:
      removeAttribute in interface AttributeWrangler
      Parameters:
      name - the name of the attribute, for example "guildwish".
      Returns:
      false if not found, true if removed.
    • getAttribute

      public Attribute getAttribute(String name)
      Description copied from interface: AttributeWrangler
      Retrieves an attribute, returns null if not found.
      Specified by:
      getAttribute in interface AttributeWrangler
      Parameters:
      name - the name of the attribute
      Returns:
      an attribute
    • setAttribute

      public void setAttribute(String name, String value)
      Description copied from interface: AttributeWrangler
      Set the value of the attribute, creates the attribute if the attribute does not exist.
      Specified by:
      setAttribute in interface AttributeWrangler
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
    • verifyAttribute

      public boolean verifyAttribute(String name, String value)
      Description copied from interface: AttributeWrangler
      Verify if the attribute exists, and has the proper value.
      Specified by:
      verifyAttribute in interface AttributeWrangler
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      true if it exists, false otherwise.
    • destroyItem

      public boolean destroyItem(Item item)
      Description copied from interface: ItemWrangler
      Physically destroys an item instance.
      Specified by:
      destroyItem in interface ItemWrangler
      Parameters:
      item - the item to be destroyed
      Returns:
      returns true, if the item was found and destroyed. False if the item was not found.
    • drop

      public boolean drop(Item item)
      A person, apparently, dropped this into the room.
      Parameters:
      item - the item he dropped.
      Returns:
      boolean, true if it was added, false otherwise.
    • get

      public void get(Item item)
    • getPersons

      public List<Person> getPersons(Person excluding)
      Returns all persons in the room, can be bots or shopkeepers or normal players.
      Parameters:
      excluding - this user is excluded. Can be null, in this case all persons in the room are returned.
      Returns:
      a list of persons in the room.
    • getPerson

      public Person getPerson(String name)
      Retrieves a specific person of the room, by (case-insensitive) name.
      Parameters:
      name - the name of the person to look for.
      Returns:
      Person in the room, null if not found.
    • addItem

      public Item addItem(Item item)
      Adds an Item to the room.
      Specified by:
      addItem in interface ItemWrangler
      Parameters:
      item - the new item. May not be null.
      Returns:
      the new item, null if unable to add.
    • addPerson

      public void addPerson(Person person)
      Should ONLY be used for testing!!!!
      Parameters:
      person -