Class Person

Object
Person
All Implemented Interfaces:
Serializable, AttributeWrangler, DisplayInterface, ItemWrangler, Ownage
Direct Known Subclasses:
Bot, Mob, User

@Entity public abstract class Person extends Object implements Serializable, AttributeWrangler, DisplayInterface, ItemWrangler, Ownage
A character in the game. Might be both a bot, a shopkeeper, a user, or an administrator.
Author:
maartenl
See Also:
  • Field Details

  • Constructor Details

    • Person

      public Person()
  • Method Details

    • getName

      public String getName()
      returns the name of the character.
      Returns:
      String containing the name
    • setName

      public void setName(String name) throws MudException
      Sets the name of the person. Should contain only alphabetical characters, but has to have at least size of 3.
      Parameters:
      name - the (new) name.
      Throws:
      MudException - if the name is not allowed.
    • getFamilyname

      @Nullable public String getFamilyname()
      Also known as a "surname" or last name.
      Returns:
      the family name, can be NULL.
    • setFamilyname

      public void setFamilyname(@Nullable String familyname)
      Sets the family name, see getFamilyname().
      Parameters:
      familyname - the new familyname or NULL.
    • getTitle

      public String getTitle()
      returns the title of the character.
      Returns:
      String containing the title
    • setTitle

      public void setTitle(String title)
      sets the title of the character.
      Parameters:
      title - String containing the title
    • getRace

      public String getRace()
      returns the race of the character.
      Returns:
      String containing the race
    • setRace

      public void setRace(String race)
    • getSex

      public Sex getSex()
      returns what gender the character is.
      Returns:
      Sex containing either male or female.
    • setSex

      public void setSex(Sex sex)
    • getAge

      public String getAge()
      returns the age of the character.
      Returns:
      String containing the age
    • setAge

      public void setAge(String age)
    • getHeight

      public String getHeight()
      returns the length of the character.
      Returns:
      String containing the length
    • setHeight

      public void setHeight(String height)
    • getWidth

      public String getWidth()
      returns the width of the character.
      Returns:
      String containing the width
    • setWidth

      public void setWidth(String width)
    • getComplexion

      public String getComplexion()
      returns the complexion of the character.
      Returns:
      String containing the complexion
    • setComplexion

      public void setComplexion(String complexion)
    • getEyes

      public String getEyes()
      returns the eyes of the character.
      Returns:
      String containing the eyes
    • setEyes

      public void setEyes(String eyes)
    • getFace

      public String getFace()
      returns the face of the character.
      Returns:
      String containing the face
    • setFace

      public void setFace(String face)
    • getHair

      public String getHair()
      returns the hair of the character.
      Returns:
      String containing the hair
    • setHair

      public void setHair(String hair)
    • getBeard

      public String getBeard()
      returns the beard of the character.
      Returns:
      String containing the beard
    • setBeard

      public void setBeard(String beard)
    • getArm

      public String getArm()
      returns the arms of the character.
      Returns:
      String containing the arms
    • setArm

      public void setArm(String arm)
    • getLeg

      public String getLeg()
      returns the legs of the character.
      Returns:
      String containing the legs
    • setLeg

      public void setLeg(String leg)
    • getCopper

      public Integer getCopper()
      Returns the amount of money a character has (in coppers). Basically 10 coppers is 1 silver, and 10 silvers is 1 gold.
      Returns:
      Integer with the amount of coppers.
    • getMoney

      public Integer getMoney()
      Returns:
      Integer with the amount of coppers
      See Also:
    • setCopper

      public void setCopper(Integer copper)
      Do not use this method ... ever! Used for testing and for inside this class itself.
      Parameters:
      copper - amount of copper of a person
    • getRoom

      public Room getRoom()
      returns in which Room the character is.
      Returns:
      Room the room that the character is currently occupying
    • setRoom

      public void setRoom(Room room)
      sets the room of the character.
      Parameters:
      room - the new current room of the character
    • getWimpy

      public Health getWimpy()
      get the setting for when to flee the fight.
      Returns:
      integer containing the setting
    • setWimpy

      public void setWimpy(Health wimpy)
      sets the wimpy of the character.
      Parameters:
      wimpy - Health enum containing the wimpy
      See Also:
    • getLevel

      public int getLevel()
      Returns the level of the character.
      Returns:
      integer.
    • getExperience

      public int getExperience()
      Returns the experience of the character.
      Returns:
      integer between 0 and 1000. The closer to 1000 is the closer to the next level.
    • getFightingwho

      public String getFightingwho()
    • setFightingwho

      public void setFightingwho(String fightingwho)
    • getSleep

      public boolean getSleep()
      returns whether or not the character is asleep.
      Returns:
      boolean, true if character is asleep.
    • isAfk

      public boolean isAfk()
    • getAfk

      @Nullable public String getAfk()
    • setAfk

      public void setAfk(String afk)
    • setSleep

      public void setSleep(Boolean sleep)
      sets the sleep status of the character.
      Parameters:
      sleep - boolean containing the sleep status
    • getFightable

      public Boolean getFightable()
      Indicates if this person can be fought with by other persons/users/players.
      Returns:
      true if can be fought with, false otherwise.
    • setFightable

      public void setFightable(Boolean fightable)
      Parameters:
      fightable - Indicates if this person can be fought with by other persons/users/players.
      See Also:
    • getVitals

      public Integer getVitals()
    • increaseHealth

      public void increaseHealth(Integer vitals)
    • decreaseHealth

      public void decreaseHealth(Integer vitals)
    • getHealth

      public Health getHealth()
    • isDead

      public boolean isDead()
    • getFysically

      public Integer getFysically()
    • setFysically

      public void setFysically(Integer fysically)
    • getMentally

      public Integer getMentally()
    • setMentally

      public void setMentally(Integer mentally)
    • getDrinkstats

      public Integer getDrinkstats()
    • setDrinkstats

      public void setDrinkstats(Integer drinkstats)
    • getEatstats

      public Integer getEatstats()
    • setEatstats

      public void setEatstats(Integer eatstats)
    • isActive

      public boolean isActive()
      Can tell you if a person is playing the game or not.
      Returns:
      boolean, true if the person is playing, false otherwise.
    • setActive

      public void setActive(Boolean active)
      Make a person actively playing the game (or not).
      Parameters:
      active - boolean, true if he's playing, false otherwise.
    • getBirth

      public LocalDateTime getBirth()
    • setBirth

      public void setBirth(LocalDateTime birth)
    • getGod

      public God getGod()
    • getStrength

      public Integer getStrength()
    • setStrength

      public void setStrength(Integer strength)
    • getIntelligence

      public Integer getIntelligence()
    • setIntelligence

      public void setIntelligence(Integer intelligence)
    • getDexterity

      public Integer getDexterity()
    • setDexterity

      public void setDexterity(Integer dexterity)
    • getConstitution

      public Integer getConstitution()
    • setConstitution

      public void setConstitution(Integer constitution)
    • getWisdom

      public Integer getWisdom()
    • setWisdom

      public void setWisdom(Integer wisdom)
    • getPractises

      public Integer getPractises()
    • setPractises

      public void setPractises(Integer practises)
    • getTraining

      public Integer getTraining()
    • setTraining

      public void setTraining(Integer training)
    • getBandage

      public Integer getBandage()
    • setBandage

      public void setBandage(Integer bandage)
    • getAlignment

      public Integer getAlignment()
    • setAlignment

      public void setAlignment(Integer alignment)
    • getManastats

      public Integer getManastats()
    • setManastats

      public void setManastats(Integer manastats)
    • getMovementstats

      public Integer getMovementstats()
    • setMovementstats

      public void setMovementstats(Integer movementstats)
    • getMaxmana

      public Integer getMaxmana()
    • setMaxmana

      public void setMaxmana(Integer maxmana)
    • getMaxmove

      public Integer getMaxmove()
    • setMaxmove

      public void setMaxmove(Integer maxmove)
    • getMaxvital

      public Integer getMaxvital()
    • setMaxvital

      public void setMaxvital(Integer maxvital)
    • getJumpmana

      public Integer getJumpmana()
    • setJumpmana

      public void setJumpmana(Integer jumpmana)
    • getJumpmove

      public Integer getJumpmove()
    • setJumpmove

      public void setJumpmove(Integer jumpmove)
    • getJumpvital

      public Integer getJumpvital()
    • setJumpvital

      public void setJumpvital(Integer jumpvital)
    • getCreation

      public LocalDateTime getCreation()
    • setCreation

      public void setCreation(LocalDateTime creation)
    • getNotes

      public String getNotes()
    • setNotes

      public void setNotes(String notes)
    • getState

      public String getState()
      returns the state of the character, for example "He seems to be on fire.". Primarily used for roleplaying.
      Returns:
      String containing the description of the current condition of the character.
    • setState

      public void setState(String state)
      sets the state/condition of the character.
      Parameters:
      state - String containing the description of the current condition of the character.
    • 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".
    • getDescription

      public String getDescription()
      Returns the description of the character. All characteristics, if possible, are taken into account. Does not provide any info on the name or title. It contains a strictly visual cue.
      Returns:
      String containing the description
    • isUser

      public boolean isUser()
      Indicates if this is a common user. This means it indicates that it is basically someone behind a keyboard.
      Returns:
      true if it is a common user (or a god/administrator), false otherwise.
    • isShopkeeper

      public boolean isShopkeeper()
      Indicates if this is a shopkeeper, a specialized bot.
      Returns:
      true if it is a shopkeeper, false otherwise.
    • 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
    • getStatistics

      public String getStatistics() throws MudException
      Display statistics .
      Returns:
      String containing all the statistics in html format.
      Throws:
      MudException
    • getLongDescription

      public String getLongDescription()
      returns the description of the character. All characteristics, if possible, are taken into account.
      Returns:
      String containing the description
    • 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.
    • 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.
    • getMainTitle

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

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

      public String getBody() throws MudException
      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:
      Throws:
      MudException
    • findItems

      public List<Item> findItems(List<String> parsed)
      Returns items in the inventory of this character, based on description provided by the user.
      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.
    • 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.
    • wears

      public Item wears(Wearing position)
      Returns the item being worn at that position.
      Parameters:
      position - the position to check.
      Returns:
      the item worn at that position, may be null if nothing is being worn there.
    • isWearing

      public boolean isWearing(Item item)
      Indicates if an item is being worn,
      Parameters:
      item - the item to check, if null provided it will never be worn, obviously.
      Returns:
      true if the item is being worn, false otherwise.
    • wear

      public void wear(Item item, Wearing position)
      Makes you wear an item at a specific position
      Parameters:
      item - the item to be worn. In case this is null, it means an item that used to be worn at this position will be removed.
      position - the position on which the item is to be worn
    • wields

      public Item wields(Wielding position)
      Returns the item being wielded at that position.
      Parameters:
      position - the position to check.
      Returns:
      the item wielded at that position, may be null if nothing is being wielded there.
    • isWielding

      public boolean isWielding(Item item)
      Indicates if an item is being wielded,
      Parameters:
      item - the item to check, if null provided it will never be wielded, obviously.
      Returns:
      true if the item is being wielded, false otherwise.
    • wield

      public void wield(Item item, Wielding position)
      Makes you wield an item at a specific position
      Parameters:
      item - the item to be wielded. In case this is null, it means an item that used to be wielded at this position will be removed.
      position - the position on which the item is to be wielded, lefthand, righthand or with both hands.
    • unused

      public boolean unused(Item item)
      Determines if the item is being used or not. If it is used, it is not allowed to be dropped, get, drunk, eaten, etc.
      Parameters:
      item - the item to check
      Returns:
      true if the item is available for use.
    • drop

      public void drop(Item item)
    • get

      public void get(Item item)
      Picked up an item from a room.
      Parameters:
      item -
    • transferMoney

      public void transferMoney(Integer newamount, Person target) throws MoneyException
      Transfers money from one person (this one) to another.
      Parameters:
      newamount - the amount of copper (base currency to move)
      target - the target that is to receive said money
      Throws:
      MoneyException - if the money amount is illegal, or the person simply does not have that much money.
    • isIgnoring

      public boolean isIgnoring(Person aSource)
    • canReceive

      public abstract boolean canReceive()
      Indicates whether or not this person can receive items or money from other players.
      Returns:
    • give

      public void give(Item item, Person toperson)
    • receive

      protected void receive(Item item)
    • addItem

      public Item addItem(Item item)
      Adds an Item to the inventory of this person. It is assumed that this item has not yet been assigned to something (a person, a room or a container (bag)).
      Specified by:
      addItem in interface ItemWrangler
      Parameters:
      item - the new item. May not be null.
      Returns:
      the new item, null if unable to add.
    • getVisible

      public boolean getVisible()
      A user is always visible, will return always true.
      Returns:
      true
    • setVisible

      public void setVisible(boolean visible)
      Empty implementation. A user is always visible.
      Parameters:
      visible -
    • getWebsocketSupport

      public boolean getWebsocketSupport()
      The idea here is that some people are having problems with websockets, meaning we need to fall back to the standard request-response model.
      Returns:
      true in case of websocket support, this is the default.
    • setWebsocketSupport

      public void setWebsocketSupport(boolean websocketSupport)
    • getTransform

      public Transform getTransform()
    • setTransform

      public void setTransform(Transform transform)