Class Person
Object
Person
- All Implemented Interfaces:
Serializable
,AttributeWrangler
,DisplayInterface
,ItemWrangler
,Ownage
@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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds anItem
to the inventory of this person.abstract boolean
Indicates whether or not this person can receive items or money from other players.void
decreaseHealth
(Integer vitals) boolean
destroyItem
(Item item) Physically destroys an item instance.void
boolean
Returns items in the inventory of this character, based on description provided by the user.void
Picked up an item from a room.getAfk()
getAge()
returns the age of the character.getArm()
returns the arms of the character.getAttribute
(String name) Retrieves an attribute, returns null if not found.getBeard()
returns the beard of the character.getBirth()
getBody()
The body to be displayed on the screen.returns the complexion of the character.Returns the amount of money a character has (in coppers).Returns the description of the character.int
Returns the experience of the character.getEyes()
returns the eyes of the character.getFace()
returns the face of the character.Also known as a "surname" or last name.Indicates if this person can be fought with by other persons/users/players.getGod()
getHair()
returns the hair of the character.returns the length of the character.getImage()
Returns an url pointing to an image.getItems()
Retrieves a set of items that this entity has.getLeg()
returns the legs of the character.int
getLevel()
Returns the level of the character.returns the description of the character.The title as visible on the screen.getMoney()
getName()
returns the name of the character.getNotes()
getOwner()
Retrieves the owner, the administrator, of this object.getRace()
returns the race of the character.getRoom()
returns in which Room the character is.getSex()
returns what gender the character is.boolean
getSleep()
returns whether or not the character is asleep.getState()
returns the state of the character, for example "He seems to be on fire.".Display statistics .getTitle()
returns the title of the character.boolean
A user is always visible, will return always true.boolean
The idea here is that some people are having problems with websockets, meaning we need to fall back to the standard request-response model.getWidth()
returns the width of the character.getWimpy()
get the setting for when to flee the fight.void
int
hashCode()
void
increaseHealth
(Integer vitals) boolean
isActive()
Can tell you if a person is playing the game or not.boolean
isAfk()
boolean
isDead()
boolean
isIgnoring
(Person aSource) boolean
Indicates if this is a shopkeeper, a specialized bot.boolean
isUser()
Indicates if this is a common user.boolean
Indicates if an item is being worn,boolean
isWielding
(Item item) Indicates if an item is being wielded,protected void
boolean
removeAttribute
(String name) Removes an attribute by name.void
Make a person actively playing the game (or not).void
void
void
setAlignment
(Integer alignment) void
void
setAttribute
(String name, String value) Set the value of the attribute, creates the attribute if the attribute does not exist.void
setBandage
(Integer bandage) void
void
setBirth
(LocalDateTime birth) void
setComplexion
(String complexion) void
setConstitution
(Integer constitution) void
Do not use this method ...void
setCreation
(LocalDateTime creation) void
setDexterity
(Integer dexterity) void
setDrinkstats
(Integer drinkstats) void
setEatstats
(Integer eatstats) void
void
void
setFamilyname
(String familyname) Sets the family name, seegetFamilyname()
.void
setFightable
(Boolean fightable) void
setFightingwho
(String fightingwho) void
setFysically
(Integer fysically) void
void
void
setIntelligence
(Integer intelligence) void
setJumpmana
(Integer jumpmana) void
setJumpmove
(Integer jumpmove) void
setJumpvital
(Integer jumpvital) void
void
setManastats
(Integer manastats) void
setMaxmana
(Integer maxmana) void
setMaxmove
(Integer maxmove) void
setMaxvital
(Integer maxvital) void
setMentally
(Integer mentally) void
setMovementstats
(Integer movementstats) void
Sets the name of the person.void
void
Sets the owner, the administrator, of this object.void
setPractises
(Integer practises) void
void
sets the room of the character.void
void
sets the sleep status of the character.void
sets the state/condition of the character.void
setStrength
(Integer strength) void
sets the title of the character.void
setTraining
(Integer training) void
setTransform
(Transform transform) void
setVisible
(boolean visible) Empty implementation.void
setWebsocketSupport
(boolean websocketSupport) void
void
sets the wimpy of the character.void
toString()
void
transferMoney
(Integer newamount, Person target) Transfers money from one person (this one) to another.boolean
Determines if the item is being used or not.boolean
verifyAttribute
(String name, String value) Verify if the attribute exists, and has the proper value.void
Makes you wear an item at a specific positionReturns the item being worn at that position.void
Makes you wield an item at a specific positionReturns the item being wielded at that position.
-
Field Details
-
EMPTY_LOG
- See Also:
-
MAX_VITALS
public static final int MAX_VITALS- See Also:
-
-
Constructor Details
-
Person
public Person()
-
-
Method Details
-
getName
-
setName
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
Also known as a "surname" or last name.- Returns:
- the family name, can be NULL.
-
setFamilyname
Sets the family name, seegetFamilyname()
.- Parameters:
familyname
- the new familyname or NULL.
-
getTitle
-
setTitle
sets the title of the character.- Parameters:
title
- String containing the title
-
getRace
-
setRace
-
getSex
returns what gender the character is.- Returns:
- Sex containing either male or female.
-
setSex
-
getAge
-
setAge
-
getHeight
returns the length of the character.- Returns:
- String containing the length
-
setHeight
-
getWidth
-
setWidth
-
getComplexion
returns the complexion of the character.- Returns:
- String containing the complexion
-
setComplexion
-
getEyes
-
setEyes
-
getFace
-
setFace
-
getHair
-
setHair
-
getBeard
-
setBeard
-
getArm
-
setArm
-
getLeg
-
setLeg
-
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
- Returns:
- Integer with the amount of coppers
- See Also:
-
setCopper
Do not use this method ... ever! Used for testing and for inside this class itself.- Parameters:
copper
- amount of copper of a person
-
getRoom
returns in which Room the character is.- Returns:
- Room the room that the character is currently occupying
-
setRoom
sets the room of the character.- Parameters:
room
- the new current room of the character
-
getWimpy
get the setting for when to flee the fight.- Returns:
- integer containing the setting
-
setWimpy
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
-
setFightingwho
-
getSleep
public boolean getSleep()returns whether or not the character is asleep.- Returns:
- boolean, true if character is asleep.
-
isAfk
public boolean isAfk() -
getAfk
-
setAfk
-
setSleep
sets the sleep status of the character.- Parameters:
sleep
- boolean containing the sleep status
-
getFightable
Indicates if this person can be fought with by other persons/users/players.- Returns:
- true if can be fought with, false otherwise.
-
setFightable
- Parameters:
fightable
- Indicates if this person can be fought with by other persons/users/players.- See Also:
-
getVitals
-
increaseHealth
-
decreaseHealth
-
getHealth
-
isDead
public boolean isDead() -
getFysically
-
setFysically
-
getMentally
-
setMentally
-
getDrinkstats
-
setDrinkstats
-
getEatstats
-
setEatstats
-
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
Make a person actively playing the game (or not).- Parameters:
active
- boolean, true if he's playing, false otherwise.
-
getBirth
-
setBirth
-
getGod
-
getStrength
-
setStrength
-
getIntelligence
-
setIntelligence
-
getDexterity
-
setDexterity
-
getConstitution
-
setConstitution
-
getWisdom
-
setWisdom
-
getPractises
-
setPractises
-
getTraining
-
setTraining
-
getBandage
-
setBandage
-
getAlignment
-
setAlignment
-
getManastats
-
setManastats
-
getMovementstats
-
setMovementstats
-
getMaxmana
-
setMaxmana
-
getMaxmove
-
setMaxmove
-
getMaxvital
-
setMaxvital
-
getJumpmana
-
setJumpmana
-
getJumpmove
-
setJumpmove
-
getJumpvital
-
setJumpvital
-
getCreation
-
setCreation
-
getNotes
-
setNotes
-
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
sets the state/condition of the character.- Parameters:
state
- String containing the description of the current condition of the character.
-
getOwner
-
setOwner
Description copied from interface:Ownage
Sets the owner, the administrator, of this object. -
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
-
equals
-
toString
-
getStatistics
Display statistics .- Returns:
- String containing all the statistics in html format.
- Throws:
MudException
-
getLongDescription
returns the description of the character. All characteristics, if possible, are taken into account.- Returns:
- String containing the description
-
removeAttribute
Description copied from interface:AttributeWrangler
Removes an attribute by name.- Specified by:
removeAttribute
in interfaceAttributeWrangler
- Parameters:
name
- the name of the attribute, for example "guildwish".- Returns:
- false if not found, true if removed.
-
getAttribute
Description copied from interface:AttributeWrangler
Retrieves an attribute, returns null if not found.- Specified by:
getAttribute
in interfaceAttributeWrangler
- Parameters:
name
- the name of the attribute- Returns:
- an attribute
-
setAttribute
Description copied from interface:AttributeWrangler
Set the value of the attribute, creates the attribute if the attribute does not exist.- Specified by:
setAttribute
in interfaceAttributeWrangler
- Parameters:
name
- the name of the attributevalue
- the value of the attribute
-
verifyAttribute
Description copied from interface:AttributeWrangler
Verify if the attribute exists, and has the proper value.- Specified by:
verifyAttribute
in interfaceAttributeWrangler
- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- true if it exists, false otherwise.
-
getItems
Description copied from interface:ItemWrangler
Retrieves a set of items that this entity has.- Specified by:
getItems
in interfaceItemWrangler
- Returns:
- A set of items.
-
getMainTitle
Description copied from interface:DisplayInterface
The title as visible on the screen.- Specified by:
getMainTitle
in interfaceDisplayInterface
- Returns:
- Throws:
MudException
-
getImage
Description copied from interface:DisplayInterface
Returns an url pointing to an image.- Specified by:
getImage
in interfaceDisplayInterface
- Returns:
- Throws:
MudException
-
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 interfaceDisplayInterface
- Returns:
- Throws:
MudException
-
findItems
Returns items in the inventory of this character, based on description provided by the user.- Specified by:
findItems
in interfaceItemWrangler
- 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
Description copied from interface:ItemWrangler
Physically destroys an item instance.- Specified by:
destroyItem
in interfaceItemWrangler
- 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
-
isWearing
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
-
wields
-
isWielding
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
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
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
-
get
-
transferMoney
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
-
canReceive
public abstract boolean canReceive()Indicates whether or not this person can receive items or money from other players.- Returns:
-
give
-
receive
-
addItem
Adds anItem
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 interfaceItemWrangler
- 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
-
setTransform
-