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 anItemto the inventory of this person.abstract booleanIndicates whether or not this person can receive items or money from other players.voiddecreaseHealth(Integer vitals) booleandestroyItem(Item item) Physically destroys an item instance.voidbooleanReturns items in the inventory of this character, based on description provided by the user.voidPicked 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.intReturns 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.intgetLevel()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.booleangetSleep()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.booleanA user is always visible, will return always true.booleanThe 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.voidinthashCode()voidincreaseHealth(Integer vitals) booleanisActive()Can tell you if a person is playing the game or not.booleanisAfk()booleanisDead()booleanisIgnoring(Person aSource) booleanIndicates if this is a shopkeeper, a specialized bot.booleanisUser()Indicates if this is a common user.booleanIndicates if an item is being worn,booleanisWielding(Item item) Indicates if an item is being wielded,protected voidbooleanremoveAttribute(String name) Removes an attribute by name.voidMake a person actively playing the game (or not).voidvoidvoidsetAlignment(Integer alignment) voidvoidsetAttribute(String name, String value) Set the value of the attribute, creates the attribute if the attribute does not exist.voidsetBandage(Integer bandage) voidvoidsetBirth(LocalDateTime birth) voidsetComplexion(String complexion) voidsetConstitution(Integer constitution) voidDo not use this method ...voidsetCreation(LocalDateTime creation) voidsetDexterity(Integer dexterity) voidsetDrinkstats(Integer drinkstats) voidsetEatstats(Integer eatstats) voidvoidvoidsetFamilyname(String familyname) Sets the family name, seegetFamilyname().voidsetFightable(Boolean fightable) voidsetFightingwho(String fightingwho) voidsetFysically(Integer fysically) voidvoidvoidsetIntelligence(Integer intelligence) voidsetJumpmana(Integer jumpmana) voidsetJumpmove(Integer jumpmove) voidsetJumpvital(Integer jumpvital) voidvoidsetManastats(Integer manastats) voidsetMaxmana(Integer maxmana) voidsetMaxmove(Integer maxmove) voidsetMaxvital(Integer maxvital) voidsetMentally(Integer mentally) voidsetMovementstats(Integer movementstats) voidSets the name of the person.voidvoidSets the owner, the administrator, of this object.voidsetPractises(Integer practises) voidvoidsets the room of the character.voidvoidsets the sleep status of the character.voidsets the state/condition of the character.voidsetStrength(Integer strength) voidsets the title of the character.voidsetTraining(Integer training) voidsetTransform(Transform transform) voidsetVisible(boolean visible) Empty implementation.voidsetWebsocketSupport(boolean websocketSupport) voidvoidsets the wimpy of the character.voidtoString()voidtransferMoney(Integer newamount, Person target) Transfers money from one person (this one) to another.booleanDetermines if the item is being used or not.booleanverifyAttribute(String name, String value) Verify if the attribute exists, and has the proper value.voidMakes you wear an item at a specific positionReturns the item being worn at that position.voidMakes 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:OwnageSets 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:AttributeWranglerRemoves an attribute by name.- Specified by:
removeAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attribute, for example "guildwish".- Returns:
- false if not found, true if removed.
-
getAttribute
Description copied from interface:AttributeWranglerRetrieves an attribute, returns null if not found.- Specified by:
getAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attribute- Returns:
- an attribute
-
setAttribute
Description copied from interface:AttributeWranglerSet the value of the attribute, creates the attribute if the attribute does not exist.- Specified by:
setAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attributevalue- the value of the attribute
-
verifyAttribute
Description copied from interface:AttributeWranglerVerify if the attribute exists, and has the proper value.- Specified by:
verifyAttributein 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:ItemWranglerRetrieves a set of items that this entity has.- Specified by:
getItemsin interfaceItemWrangler- Returns:
- A set of items.
-
getMainTitle
Description copied from interface:DisplayInterfaceThe title as visible on the screen.- Specified by:
getMainTitlein interfaceDisplayInterface- Returns:
- Throws:
MudException
-
getImage
Description copied from interface:DisplayInterfaceReturns an url pointing to an image.- Specified by:
getImagein interfaceDisplayInterface- Returns:
- Throws:
MudException
-
getBody
Description copied from interface:DisplayInterfaceThe 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:
getBodyin interfaceDisplayInterface- Returns:
- Throws:
MudException
-
findItems
Returns items in the inventory of this character, based on description provided by the user.- Specified by:
findItemsin 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:ItemWranglerPhysically destroys an item instance.- Specified by:
destroyItemin 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 anItemto 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:
addItemin 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
-