wyvern.lib
Interface Player

All Superinterfaces:
Attackable, Broadcaster, Commandable, Damageable, GameObject, Hookable, MapLoaderListener, MethodHookable, Monster, PropertyList, RemoteAudio
All Known Implementing Classes:
PlayerImpl

public interface Player
extends Monster, MapLoaderListener

Represents a single character logged in to the game. It's one of the most important/commonly-used interfaces in the game, since most code deals with players, in one way or another.

The first thing you should know about Player objects is that you shouldn't store direct references to them, if you can avoid it. If you need to remember a Player in your code, you should store the player's name, and when you need to access the player later, use World.getPlayer(name). This is because players can, of course, log out, and if you keep a reference to their actual Player object around, you'll prevent it from being garbage-collected. Worse, you might be doing stuff to the wrong object: if they logged out and logged back in again, you'll be manipulating their old Player object. So store the name!

It's OK to use Player references inside a single function, of course, or pass them from function to function, as long as you don't store the reference in an instance variable or a list of some sort.

Lots of Player attributes are stored as properties on the player, so they can be saved. Normally, you can modify properties on game objects directly with setProperty(), setIntProperty(), and so on. For Players, however, you should first check to see if there's a special method for accessing the attribute. For instance, you don't want to call player.adjustIntProperty("hp", 10), because it won't update their HP display on their client. Use player.adjustHP(10) instead. Similarly, you don't want to use getProperty("title"), because there's a getTitle() that returns the correct title.

The Player interface gives you the ability to access, modify, and control lots of things about the player:

Plus all of the methods available to Monsters, Commandables, and GameObjects, all of which Players inherit from.

Like any other Wyvern object, some of the methods are there specifically for the game engine, and others are there for the Wizard API. We don't currently show, in this API documentation, which ones are which, but we'll add that soon. In the meantime, ask Rhialto if you're not sure whether you can use a particular method or not.

There are various pubsub Messages published by the Player class:

Note: you don't necessarily receive pubsub messages until long after the event actually occurred.

Version:
1.0, Mar 02, 1998
Author:
Steve Yegge

Field Summary
static int DEFAULT_PLAYER_SPEED
          If a player has no "move-speed" property, this is the default speed at which the monster moves.
static int DEFAULT_WAKE_MONSTER_RADIUS
          The range in which to wake up monsters if we fail sneaking.
static int END_COMBAT_DELAY
          Number of milliseconds that elapse after combat ends before the player is considered "not in combat" anymore.
static int MAX_VIEW_SIZE
          The maximum width or height for a normal player's view.
static int MAX_WIZ_VIEW_SIZE
          The maximum width or height for a wizard's view.
 
Fields inherited from interface wyvern.lib.Monster
DEFAULT_MONSTER_ATTACK_SPEED, DEFAULT_MONSTER_SPEED, DEFAULT_MONSTER_STRENGTH, MONSTER_XP_CAP
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Fields inherited from interface wyvern.common.net.RemoteAudio
DEFAULT_ALERT_GAIN, DEFAULT_ALERT_REPEAT_DELAY, DEFAULT_ALERT_REPEATS, DEFAULT_GAIN, DEFAULT_REPEAT_DELAY, DEFAULT_REPEATS
 
Method Summary
 void adjustAlign(int adjust)
          Adjusts the player's alignment upwards or downwards.
 void adjustFood(int adjust)
          Adjusts the player's food amount by the specified amount.
 void adjustShoutPoints(int adjust)
          Adjusts the player's shout points upwards or downwards.
 void adjustSkill(java.lang.String name, int adjust)
          Adjusts the transient value of a skill for the player.
 void adjustXP(int adjust)
          Adjusts the player's experience points upwards or downwards.
 boolean autosave()
          Saves the current state of the player to the player's file, without issuing any message to the player.
 long combatTimeLeft()
          Returns time left before we change this API.
 void controlCamera(boolean control)
          Tells the Player to control its own camera (if true) or notifies the Player that the camera will be controlled externally (if false).
 void enqueueCommand(java.lang.String command, boolean user)
          Puts a command in our command queue.
 int getAge()
          Returns the player's age in seconds.
 java.util.Map getAliases()
          Returns the aliases for this player.
 int getAlignment()
          Returns player's alignment
 RemoteClient getClient()
          Returns the RemoteClient implementation for this player.
 CommandList getCommandList()
          Returns the CommandList for this player.
 int getFood()
          Returns the player's current food level.
 java.lang.String getFullTitle()
          Returns a full title, such as "Rawk the Elven Adventurer".
 Camera getGroundCamera()
          Returns the camera that displays the ground beneath the player.
 GameObject getGroundObject(int index)
          This is a rather special-purpose method: it returns the game object that's currently being displayed in the client's ground display at the specified index.
 java.lang.String getHostAddress()
          Returns the IP address this player is connected from.
 int getIdleTime()
          Returns the number of seconds the player has been idle.
 Camera getMapCamera()
          Returns the camera that displays the map.
 int getMaxFood()
          Returns the max food the player can eat/drink.
 MusicState getMusicState()
          Returns the MusicState object keeping track of this player's running soundtrack.
 java.lang.String getPassword()
          Returns the player's encrypted password.
 Point getPositionInViewport()
          Returns the relative offets of the player within the player's map camera.
 java.lang.String getRace()
          Returns player's race.
 wyvern.server.IClientSession getSession()
          Returns the ClientSession for this player.
 java.lang.String getSex()
          Returns player's gender.
 int getShoutPoints()
          Returns the player's shout points.
 SpellList getSpellList()
          Returns the player's SpellList, or null if they don't know any spells (or are a Wizard who can cast anything.)
 java.util.Date getStartDate()
          Returns the time when the player logged in.
 long getStartTime()
          Returns System.currentTimeMillis() when the player logged in.
 java.lang.String getTitle()
          Returns the player's title, e.g.
 int getXP()
          Returns the player's experience.
 boolean inCombat()
          Returns true if the player has recently been in combat.
 void init(RemoteClient client, Dimension viewsize)
          Initializes the player instance and data structures using the specified RemoteClient.
 boolean isGuest()
          Returns true if the player is a guest.
 boolean isHandheld()
          Returns true if the player is connected via a handheld client.
 boolean isNetDead()
          Returns true if the player is currently net-dead.
 boolean isShutDown()
          Returns true if this Player object is defunct (the player has logged out).
 boolean isTelnet()
          Returns true if we're connected via a Telnet client.
 boolean isWizard()
          Returns true if the player is a Wizard (any level).
 long lastCombat()
          Returns the last time the player had an updateCombat() method called.
 boolean outranks(Commandable other)
          Returns true if this player outranks the passed player.
 void quit()
          Dumps the player out of the game, dropping all inventory before saving the player.
 void quitSafely()
          Player's quitting in an Inn or somewhere they can keep their inventory.
 void readAliases()
          Rebuilds the table of aliases for this player, by looking through all the player's properties that start with "alias-".
 void reconnect(RemoteClient client, Dimension d)
          Reconnects a net-dead player.
 void resetIdleTimer()
          Resets the number of seconds the player has been idle to zero.
 boolean save()
          Saves the player with notification.
 void sendFile(java.lang.String path, java.lang.String command)
          Downloads a file to the client.
 void sendFood()
          Updates player's food display on the client.
 void sendHP()
          Updates the player's hit-points display on the client.
 void sendLevel()
          Updates player's level display on the client.
 void sendLoad()
          Updates the player's encumbrance display on the client.
 void sendName()
          Updates the player's name on the client.
 void sendRange()
          Updates the player's range-weapon on the client.
 void sendSP()
          Updates the player's spell-points display on the client.
 void sendSpells()
          Resends the player's list of known spells to the client.
 void sendXP()
          Updates the player's experience display on the client.
 void serverTransfer(java.lang.String host)
          Tells the client to connect to a different server after a successful transfer.
 void setNetDead()
          Sets the net-dead flag.
 void setSession(wyvern.server.IClientSession s)
          Sets the ClientSession (the thread reading from the socket).
 void setTitle(java.lang.String title)
          Sets the player's title, e.g.
 void setViewSize(int width, int height)
          Sets new dimensions for the map camera.
 boolean solvedQuest(java.lang.String name)
          Returns true if the player has solved the specified quest.
 void startPoison()
          Turns the client HP indicator green.
 void stopPoison()
          Returns the client HP indicator red.
 void tellLater(java.lang.String msg, byte style)
          Puts a message in the player's event queue that will be displayed to the player after all current events in the queue are processed.
 void uncacheImage(java.lang.String path)
          Tells the client to uncache the specified image, and request it to be reloaded if it views it again.
 void updateClient()
          Sends all our visible stats to the client.
 void updateCombat()
          Marks the player as being in combat.
 void viewMap(GameMap map, int x, int y)
          Sets the player's viewport to the specified map and (x,y) location.
 
Methods inherited from interface wyvern.lib.Monster
adjustSP, adjustStat, adjustWallet, burial, createInventory, dropAll, dropAllForce, getLevel, getMaxSP, getPartsList, getSP, getWallet, isAlive, setHP, setSP
 
Methods inherited from interface wyvern.lib.Commandable
addAttack, addMessageListener, command, command, commandNow, getAI, getCapName, getCombatQueue, getCommand, getEncumbrance, getFiringPoint, getInventory, getName, getQueue, isStarted, message, message, message, registerCommand, removeAttack, removeMessageListener, sendPicture, sendPicture, setAI, setEncumbrance, setName, start, stop, unregisterCommand
 
Methods inherited from interface wyvern.lib.Hookable
addHook, getHookList, getHooks, removeHook, runFailedPostHook, runPostHook, runPreHook
 
Methods inherited from interface wyvern.lib.MethodHookable
addMethodHook, removeMethodHook, runMethodHook
 
Methods inherited from interface wyvern.lib.GameObject
addContainerChangeListener, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, destroy, externalize, getAlpha, getAppearance, getArchetype, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, getValue, getWeight, inContainer, initialize, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, setMap, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport
 
Methods inherited from interface wyvern.lib.PropertyList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from interface wyvern.lib.Broadcaster
broadcast, broadcast, broadcast, broadcast, broadcast
 
Methods inherited from interface wyvern.common.net.RemoteAudio
pauseSound, playAlert, playAlert, playDefaultMusic, playPriorityMusic, playPriorityMusic, playSound, playSound, resumeSound, setMusicGain, setSoundGain, stopAllSounds, stopMusic, stopSound
 
Methods inherited from interface wyvern.lib.properties.Attackable
getXPAward, notifyAttacked
 
Methods inherited from interface wyvern.lib.properties.Damageable
adjustHP, getHP, getMaxHP, kill
 
Methods inherited from interface wyvern.world.MapLoaderListener
mapLoaded, mapLoadFailed
 

Field Detail

DEFAULT_WAKE_MONSTER_RADIUS

public static final int DEFAULT_WAKE_MONSTER_RADIUS
The range in which to wake up monsters if we fail sneaking.

See Also:
Constant Field Values

DEFAULT_PLAYER_SPEED

public static final int DEFAULT_PLAYER_SPEED
If a player has no "move-speed" property, this is the default speed at which the monster moves. Players should always have a move-speed property, however, so this is just a sanity check.

See Also:
Constant Field Values

MAX_VIEW_SIZE

public static final int MAX_VIEW_SIZE
The maximum width or height for a normal player's view.

See Also:
Constant Field Values

MAX_WIZ_VIEW_SIZE

public static final int MAX_WIZ_VIEW_SIZE
The maximum width or height for a wizard's view.

See Also:
Constant Field Values

END_COMBAT_DELAY

public static final int END_COMBAT_DELAY
Number of milliseconds that elapse after combat ends before the player is considered "not in combat" anymore. Used by the background music system, but could also be used by any code that needs to treat the player specially during combat.

See Also:
Constant Field Values
Method Detail

viewMap

public void viewMap(GameMap map,
                    int x,
                    int y)
Sets the player's viewport to the specified map and (x,y) location. It will remain there until the player moves or something else happens to put the player's view back to "normal".

Parameters:
map - the GameMap to view
x - the map x-coordinate to center the view on
y - the map y-coordinate the center the view on

init

public void init(RemoteClient client,
                 Dimension viewsize)
Initializes the player instance and data structures using the specified RemoteClient. This method should be called only once, by the kernel, when creating the player.

Parameters:
client - the RemoteClient used for sending information.
viewsize - the size of the client's map viewport

sendName

public void sendName()
Updates the player's name on the client.


sendHP

public void sendHP()
Updates the player's hit-points display on the client.


sendSP

public void sendSP()
Updates the player's spell-points display on the client.


sendXP

public void sendXP()
Updates the player's experience display on the client.


sendLevel

public void sendLevel()
Updates player's level display on the client.


sendFood

public void sendFood()
Updates player's food display on the client.


sendRange

public void sendRange()
Updates the player's range-weapon on the client.


sendSpells

public void sendSpells()
Resends the player's list of known spells to the client.


sendLoad

public void sendLoad()
Updates the player's encumbrance display on the client. Called automatically by setEncumbrance().


updateClient

public void updateClient()
Sends all our visible stats to the client.


serverTransfer

public void serverTransfer(java.lang.String host)
Tells the client to connect to a different server after a successful transfer.

Parameters:
host - the host of the server the player is now visiting

sendFile

public void sendFile(java.lang.String path,
                     java.lang.String command)
Downloads a file to the client. Called in response to the #download command, sent (e.g.) by the audio system.

Parameters:
path - the relative path to the file. There are restrictions on what file extensions are allowed - call wyvern.server.request.SendFile.getApprovedExtensions() to see which ones it will send. There are also limits on max file size: SendFile.MAX_DATA_FILE_LENGTH is the current limit.
command - the original "#download " command sent by the client to initiate this file download. May contain routing information from the client.

getXP

public int getXP()
Returns the player's experience.


adjustXP

public void adjustXP(int adjust)
Adjusts the player's experience points upwards or downwards.

Parameters:
adjust - a number (possibly negative) to add to the player's xp

getShoutPoints

public int getShoutPoints()
Returns the player's shout points.


adjustShoutPoints

public void adjustShoutPoints(int adjust)
Adjusts the player's shout points upwards or downwards.

Parameters:
adjust - a number (possibly negative) to add to the player's shp

getAlignment

public int getAlignment()
Returns player's alignment

Returns:
the alignment value (-1000 to 1000)

adjustAlign

public void adjustAlign(int adjust)
Adjusts the player's alignment upwards or downwards.

Parameters:
adjust - a number (possibly negative) to add to the player's "align" property. Runs a method-hook called "align", where the data parameter is an Integer containing the adjustment. It's run after the adjustment is applied, so subtract the adjustment to see what the old alignment was.

getTitle

public java.lang.String getTitle()
Returns the player's title, e.g. "Adventurer".


setTitle

public void setTitle(java.lang.String title)
Sets the player's title, e.g. "Adventurer", "Hall of Famer". This is a persistent change. Make sure if you use a title that's gender-specific, you check the player's sex and use correct one.

Parameters:
title - the new title for the player

getFullTitle

public java.lang.String getFullTitle()
Returns a full title, such as "Rawk the Elven Adventurer".


adjustFood

public void adjustFood(int adjust)
Adjusts the player's food amount by the specified amount. Won't go over capacity, i.e. "max-food" value. If negative, takes appropriate steps (starts starvation damage).


getFood

public int getFood()
Returns the player's current food level. Contrast this with their hunger level, which determines the rate at which they burn food.


getMaxFood

public int getMaxFood()
Returns the max food the player can eat/drink.


getAge

public int getAge()
Returns the player's age in seconds.


getRace

public java.lang.String getRace()
Returns player's race.

Returns:
"human", "high elf", etc.

getSex

public java.lang.String getSex()
Returns player's gender.

Returns:
"male" or "female"

getMapCamera

public Camera getMapCamera()
Returns the camera that displays the map.

Returns:
a wyvern.kernel.player.MapCamera

getGroundCamera

public Camera getGroundCamera()
Returns the camera that displays the ground beneath the player.

Returns:
a wyvern.kernel.player.GroundCamera

controlCamera

public void controlCamera(boolean control)
Tells the Player to control its own camera (if true) or notifies the Player that the camera will be controlled externally (if false).

Parameters:
control - false to grab control of the camera, true to return control to the Player.

getGroundObject

public GameObject getGroundObject(int index)
This is a rather special-purpose method: it returns the game object that's currently being displayed in the client's ground display at the specified index. It's here for the benefit of the mouse-selection code; you probably shouldn't use it.

Parameters:
index - the 0-based index of the selected item
Returns:
the corresponding GameObject, if we can find it. It's possible that the frame has been discarded already, in which case we return null.

getPositionInViewport

public Point getPositionInViewport()
Returns the relative offets of the player within the player's map camera. The offsets are relative to the viewport, so if the player is in the center, it's viewWidth/2, viewHeight/2.

Returns:
the player's position in the viewport. Returns null if the player doesn't currently have a camera.

save

public boolean save()
Saves the player with notification. Runs a method-hook called "savePreHook" with no extra data before starting the save, and runs another one called "savePostHook" after the save completes. If you want to do something just before or just after saving, listen for one of those two method hooks.


autosave

public boolean autosave()
Saves the current state of the player to the player's file, without issuing any message to the player. Runs the same method-hooks as the save() method.

Returns:
true if successful, false if didn't save

quit

public void quit()
Dumps the player out of the game, dropping all inventory before saving the player. Don't call this method directly unless you're on the kernel thread, since it removes a player from the map, which can result in a deadlock.


quitSafely

public void quitSafely()
Player's quitting in an Inn or somewhere they can keep their inventory. See comments in quit() for when you can call this method safely.

Lots of things happen in this method:

When a player quits, a pubsub message is published. The Message sent out has the following attributes:

Registering for this PubSub message is easier and more reliable than using the quitPostHook. The quitPostHook is only run if the player types "quit". If the player applies a bed, or is booted off the game, then you won't get the hook callback. The PubSub message goes out no matter how the player leaves the game.


getIdleTime

public int getIdleTime()
Returns the number of seconds the player has been idle.


resetIdleTimer

public void resetIdleTimer()
Resets the number of seconds the player has been idle to zero. You normally don't want to call this, but in cases where you want to make sure the player isn't booted off the game (even if they're idle), you can call it every few minutes to prevent booting.


getStartDate

public java.util.Date getStartDate()
Returns the time when the player logged in.


getStartTime

public long getStartTime()
Returns System.currentTimeMillis() when the player logged in.


readAliases

public void readAliases()
Rebuilds the table of aliases for this player, by looking through all the player's properties that start with "alias-".


getAliases

public java.util.Map getAliases()
Returns the aliases for this player.

Returns:
a Map of the aliases (the keys for the map) and their expansions (the values).

isNetDead

public boolean isNetDead()
Returns true if the player is currently net-dead.


setNetDead

public void setNetDead()
Sets the net-dead flag. Should only be called by the networking code (don't call it yourself).


isTelnet

public boolean isTelnet()
Returns true if we're connected via a Telnet client.

Specified by:
isTelnet in interface Commandable

getClient

public RemoteClient getClient()
Returns the RemoteClient implementation for this player.


startPoison

public void startPoison()
Turns the client HP indicator green.


stopPoison

public void stopPoison()
Returns the client HP indicator red.


getPassword

public java.lang.String getPassword()
Returns the player's encrypted password.


getHostAddress

public java.lang.String getHostAddress()
Returns the IP address this player is connected from.


setViewSize

public void setViewSize(int width,
                        int height)
Sets new dimensions for the map camera.

Parameters:
width - the new camera view width (in tiles)
height - the new camera view height (in tiles)

solvedQuest

public boolean solvedQuest(java.lang.String name)
Returns true if the player has solved the specified quest.

Parameters:
name - the quest name, e.g. "moonquest"
Returns:
true if we found a property on the player saying they solved this particular uqest

isWizard

public boolean isWizard()
Returns true if the player is a Wizard (any level).

Specified by:
isWizard in interface GameObject
Returns:
true if player is a wiz

isGuest

public boolean isGuest()
Returns true if the player is a guest.

Returns:
true if this is a guest player (no registered account)

adjustSkill

public void adjustSkill(java.lang.String name,
                        int adjust)
Adjusts the transient value of a skill for the player. Adjusts the skillname property, as well as skillname + "-base".

Parameters:
name - the skill name, such as "sk-incantation"
adjust - the adjustment (can be negative)

outranks

public boolean outranks(Commandable other)
Returns true if this player outranks the passed player. The only way (currently) for this to be true is if the passed player is a higher-level wizard. If this player is a regular player, always returns false. Regular players have the same rank.

Parameters:
other - the other player
Returns:
true if we outrank the other player (meaning that player is a regular player, or we're a higher-level wizard than that player)

isHandheld

public boolean isHandheld()
Returns true if the player is connected via a handheld client.

Returns:
true if using a PDA

getCommandList

public CommandList getCommandList()
Returns the CommandList for this player.


tellLater

public void tellLater(java.lang.String msg,
                      byte style)
Puts a message in the player's event queue that will be displayed to the player after all current events in the queue are processed. Useful for sending them a message that's guaranteed to be shown after a bunch of other output happens.

Parameters:
msg - the message to send
style - the RPCConstants.TextStyle

uncacheImage

public void uncacheImage(java.lang.String path)
Tells the client to uncache the specified image, and request it to be reloaded if it views it again.

Parameters:
path - the relative path to the image, such as wiz/rhialto/images/big_rock (note: no extension).

enqueueCommand

public void enqueueCommand(java.lang.String command,
                           boolean user)
Puts a command in our command queue. Called by the player's CommandParser after doing preprocessing on it, such as alias expansion, multi-command macro expansion, history expansion, updating the idle timer, and so on. This method simply wraps the command string with a CommandEvent and puts it at the end of the player's queue.

Parameters:
command - the command string
user - true if the command was initiated by the player, false if it came from an object on the server (such as a charm-monster spell).

getMusicState

public MusicState getMusicState()
Returns the MusicState object keeping track of this player's running soundtrack.

Returns:
a MusicState for the player - always non-null, although they may not have a client with music enabled.

inCombat

public boolean inCombat()
Returns true if the player has recently been in combat. "Recently" means in the past 5 to 15 seconds or so. Used by the background-music system to figure out if combat music should be playing.

Returns:
true if the player's most recent combat update happened within the last COMBAT_DELAY seconds.

lastCombat

public long lastCombat()
Returns the last time the player had an updateCombat() method called.

Returns:
the System.currentTimeMillis() timestamp from the last updateCombat() message.

combatTimeLeft

public long combatTimeLeft()
Returns time left before we change this API.

Returns:
the System.currentTimeMillis() timestamp from the last updateCombat() message.

updateCombat

public void updateCombat()
Marks the player as being in combat. Called during combat, this sets a (long) timestamp that's read by lastCombat() and inCombat().


isShutDown

public boolean isShutDown()
Returns true if this Player object is defunct (the player has logged out).


setSession

public void setSession(wyvern.server.IClientSession s)
Sets the ClientSession (the thread reading from the socket). Required so that we can shut the session down when we quit. Don't call this method.

Parameters:
s - the thread reading from the client socket

getSession

public wyvern.server.IClientSession getSession()
Returns the ClientSession for this player. Don't use it.


reconnect

public void reconnect(RemoteClient client,
                      Dimension d)
Reconnects a net-dead player. Don't call it.

Parameters:
client - the new RemoteClient handling server output
d - the client view width and height

getSpellList

public SpellList getSpellList()
Returns the player's SpellList, or null if they don't know any spells (or are a Wizard who can cast anything.)

Specified by:
getSpellList in interface Monster
Returns:
a SpellList object, or null if the monster or player knows no spells.