wyvern.kernel.player
Class PlayerImpl

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.kernel.commands.AbstractCommandable
              extended bywyvern.kernel.monsters.MonsterImpl
                  extended bywyvern.kernel.player.PlayerImpl
All Implemented Interfaces:
Attackable, Broadcaster, Commandable, Damageable, GameObject, HeartbeatCallback, Hookable, MapLoaderListener, MethodHookable, MethodHookCallback, Monster, MouseInterest, Player, PropertyList, RemoteAudio, RPCConstants

public final class PlayerImpl
extends MonsterImpl
implements Player, RPCConstants

The default implementation of the Player interface.

Version:
1.0, Aug 17, 1997
Author:
Steve Yegge

Nested Class Summary
 
Nested classes inherited from class wyvern.kernel.monsters.MonsterImpl
MonsterImpl.WalkVisitor
 
Nested classes inherited from class wyvern.common.net.RPCConstants
RPCConstants.ImageAlign, RPCConstants.ImageFlags, RPCConstants.ImageFormat, RPCConstants.OutputView, RPCConstants.TextStyle
 
Field Summary
 
Fields inherited from class wyvern.kernel.monsters.MonsterImpl
beats_, python_, walkVisitor_
 
Fields inherited from class wyvern.kernel.commands.AbstractCommandable
hookList_, queue_, started_
 
Fields inherited from class wyvern.kernel.maps.MapObject
IN_MAP_EDITOR, listenerList_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.Player
DEFAULT_PLAYER_SPEED, DEFAULT_WAKE_MONSTER_RADIUS, END_COMBAT_DELAY, MAX_VIEW_SIZE, MAX_WIZ_VIEW_SIZE
 
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
 
Fields inherited from interface wyvern.common.net.RPCConstants
ALERT_EVENT, CHAR_BANISHED, CHAR_BANNED, CHARACTER_NOT_FOUND, CLIENT_END_MUSIC_COMMAND, CLIENT_END_SOUND_COMMAND, CONNECT_RESULT, FLUSH_GRAPHICS, GND_ADD, GND_MODIFY, GND_REMOVE, GND_RESEND, INV_ADD, INV_MODIFY, INV_REMOVE, INV_RESEND, INVALID_PASSWORD, IP_BANISHED, LOGIN_FAILURE, LOGIN_SUCCESS, LOGINS_DISABLED, MAX_IMAGE_SIZE, MUSIC_EVENT, OTHER_LOGIN_ERROR, PAUSE_SOUND, PLAY_ALERT, PLAY_MUSIC, PLAY_SOUND, PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR, QUIT, REGISTER_EXISTING_PLAYER, RESUME_SOUND, SAME_EMAIL_ONLINE, SEND_FILE, SEND_IMAGE, SEND_PICTURE, SEND_TILE, SEND_TILE_MAPPINGS, SERVER_TRANSFER, SET_GAIN, SOUND_EVENT, STAT_SEND_SPELLS, STAT_SET_FOOD, STAT_SET_GOLD, STAT_SET_HP, STAT_SET_LEVEL, STAT_SET_LOAD, STAT_SET_NAME, STAT_SET_RANGE, STAT_SET_SP, STAT_SET_XP, STAT_START_POISON, STAT_STOP_POISON, STAT_UPDATE_ALL, STOP_ALL_SOUNDS, STOP_MUSIC, STOP_SOUND, TEXT_OUT, TOO_MANY_PLAYERS, UNCACHE_IMAGE, XML_COMMAND, XML_COMMAND_WITH_COMPRESSED_DATA, XML_COMMAND_WITH_DATA, ZIP_PARTIAL_SCREEN, ZIP_SCREEN, ZIP_TEXT_OUT
 
Constructor Summary
PlayerImpl()
          Constructs a new PlayerImpl.
 
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 adjustHP(int adjust)
          Adjusts the object's hit points upwards or downwards.
 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 adjustSP(int adjust)
          Adjusts the monster's spell points upwards or downwards.
 void adjustWallet(long amount)
          Adjusts the amount of money the player is carrying by a positive or negative amount.
 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.
 void broadcastEntry(boolean entered)
          Tells certain lists that the player entered or left the game.
 void burial(GameObject attacker)
          Kills a player, for real.
 long combatTimeLeft()
          Returns time left before we change this API.
 void command(java.lang.String cmd, boolean user)
          Method called when a command is added to the command queue.
 void computeStartTime()
          Initializes idle timer and start date.
protected  java.lang.String computeTitle()
          Figures out what the player's title should be.
 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 createInventory()
          Creates the Inventory if not present, and sets the owner field.
 void destroy()
          Destroys the player object.
 void dropInventoryIfGuest()
           
 void enqueueCommand(java.lang.String command, boolean user)
          Puts a command in our command queue.
 void ensureAI()
          Don't give us an AI on construction.
protected  void ensureEventQueue()
          Creates an extra event queue for combat commands, so automatic combat happens in parallel with movement.
protected  void ensurePartsList()
          Makes a default (humanoid) body-parts list for the monster.
 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.
 EventQueue getCombatQueue()
          Returns the combat queue, in case you want to place attack commands into it directly.
 Command getCommand(CommandEvent event)
          Figures out who will handle a given command.
 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.
 Heart getHeart()
           
 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 getName()
          Returns the name of this commandable
 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.
 int getXPAward()
          Returns the experience award for killing this monster.
 void heartbeat()
          Heartbeat notification, called every 5 seconds on every player and (started) monster in the game.
 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 isHallOfFamer()
           
 boolean isHandheld()
          Returns true if the player is connected via a handheld client.
 boolean isMonster()
          Returns true if (and only if) this is a Monster (and not a Player).
 boolean isNetDead()
          Returns true if the player is currently net-dead.
 boolean isPlayer()
          Returns true if (and only if) this is a Player.
 boolean isRobot()
           
 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).
 void kill(GameObject attacker)
          Kills the player.
 long lastCombat()
          Returns the last time the player had an updateCombat() method called.
 void makeGravestone(GameObject attacker, int xpLost, int guildXpLost)
           
 void mapLoaded(GameMap map, java.lang.String name)
          If the player applies a teleporter for a map that hasn't been loaded yet, this method gets called when the map finishes loading.
 void mapLoadFailed(java.lang.String name)
          Called when the requested map couldn't be loaded.
 void message(java.lang.String msg)
          Outputs a message to this object.
 void message(java.lang.String[] strings, byte[] styles)
          Sends a message to the client as an array of strings and styles to use for each piece.
 void message(java.lang.String msg, byte style)
          Sends a message to the client using the specified style.
 void notifyAttacked(Commandable attacker)
          Notifies the object it's being attacked.
 boolean outranks(Commandable other)
          Returns true if this player outranks the passed player.
 void pauseSound(java.lang.String id)
          Pauses a particular sound.
 void playAlert(java.lang.String path)
          Plays the specified sound file on the client, one repeat, no delay, and the default gain.
 void playAlert(java.lang.String path, int repeats, int repeatDelay, double gain)
          Plays the specified alert with custom parameters.
 void playDefaultMusic()
          The player has switched maps, so figure out the default background music to be playing, and plays it.
 void playPriorityMusic(java.lang.String path)
          Sets the background music track to the specified file, with the default gain/volume.
 void playPriorityMusic(java.lang.String path, int repeats, int delay, double gain)
          Plays the specified music with custom parameters.
 void playSound(java.lang.String path, java.lang.String id)
          Plays a sound effect on the client with the default gain.
 void playSound(java.lang.String path, java.lang.String id, int repeats, int repeatDelay, double gain)
          Plays the specified sound effect with custom parameters.
protected  void processStartupCommands()
          Gets the list of startup commands from the "startcmds" StringList property, and puts each one in the agent's queue.
 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 viewsize)
          Reconnects a net-dead player.
 void registerCommand(java.lang.String command, Command handler)
          Registers a new command with the monster or player.
 void remove()
          Removes this object from its map.
 void resetIdleTimer()
          Resets the number of seconds the player has been idle to zero.
 void restart()
          Resets the player after dying.
 void resumeSound(java.lang.String id)
          Resumes a particular sound.
 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 sendImage(java.lang.String path)
           
 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 sendPicture(java.lang.String path, java.lang.String title)
          Sends a picture to the client.
 void sendPicture(java.lang.String path, java.lang.String title, byte format, byte align, byte view, int flags)
          Sends a picture to 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 sendTile(int tile, java.lang.String path, long timestamp)
           
 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 setEncumbrance(int load)
          Sets the encumbrance of the player.
 void setHeart(Heart heart)
           
 void setHP(int hp)
          Sets the current HP for the player, but keeps it within the valid range of (0, "max-hp")
 void setLevelProperties()
          Initializes default properties based on the monster's level.
 void setMap(GameMap map, int x, int y)
          Puts the player in a new map.
 void setMusicGain(double gain)
          Sets the volume of the background music.
 void setNetDead()
          Sets the net-dead flag.
 void setSession(wyvern.server.IClientSession session)
          Sets the ClientSession (the thread reading from the socket).
 void setSoundGain(java.lang.String id, double gain)
          Sets the volume of a particular sound playing on the client.
 void setSP(int sp)
          Sets the current SP for the player, but keeps it within the valid range of (0, "max-sp")
 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 stop()
          Stops the player permanently.
 void stopAllSounds()
          Stops all of the currently playing sounds on the client.
 void stopMusic()
          Stops the background music completely.
 void stopPoison()
          Returns the client HP indicator red.
 void stopSound(java.lang.String id)
          Stops the specified sound effect.
 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.
 java.lang.String toString()
          Prints information about the player.
 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 unregisterCommand(java.lang.String command, Command handler)
          Unregisters a command.
 void updateClient()
          Sends all our visible stats to the client.
 void updateCombat()
          Marks the player as being in combat.
protected  void updateMapLocation(java.util.List src, java.util.List dest)
          This method is called by move(), teleport() and setLocations() to remove the object from its old locations and place it in its new locations.
 void viewMap(GameMap map, int x, int y)
          This is used by the World object to show what's going on in the map while the player is logging in.
 void wakeMonsters()
          Maybe wakes up nearby monsters.
 
Methods inherited from class wyvern.kernel.monsters.MonsterImpl
addCustomAttacks, addToMap, adjustStat, checkDirection, createGenericAttacks, dropAll, dropAllForce, generateInventory, getDamagedDescription, getHP, getInventory, getLevel, getMaxHP, getMaxSP, getPartsList, getSP, getWallet, initialize, initInventory, isAlive, isAttackable, isHostile, isMonsterOrPlayer, isNeutral, isPeaceful, methodCalled, mouseClicked, setDefaultAttackSpeed, snuffActiveSpells, start
 
Methods inherited from class wyvern.kernel.commands.AbstractCommandable
addAttack, addHook, addMessageListener, addMethodHook, checkAnimated, command, commandNow, fireMessageReceived, getAI, getCapName, getEncumbrance, getFiringPoint, getHookList, getHooks, getQueue, isCommandable, isStarted, removeAttack, removeHook, removeMessageListener, removeMethodHook, runFailedPostHook, runMethodHook, runPostHook, runPreHook, setAI, setName
 
Methods inherited from class wyvern.kernel.maps.MapObject
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, 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, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isBlessed, isCursed, isDamned, isGroupable, isIdentified, isTerrain, isUncursed, isUnpaid, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDefaultBitmap, setDefaultCategory, setDefaultDesc, setDefaultImage, setDefaultIntProperty, setDefaultLayer, setDefaultMaterial, setDefaultProperty, setDefaultShortDesc, setDirection, setImage, setImage, setLayer, setLocations, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport
 
Methods inherited from class wyvern.kernel.properties.PList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wyvern.lib.Monster
adjustStat, dropAll, dropAllForce, getLevel, getMaxSP, getPartsList, getSP, getWallet, isAlive
 
Methods inherited from interface wyvern.lib.Commandable
addAttack, addMessageListener, command, commandNow, getAI, getCapName, getEncumbrance, getFiringPoint, getInventory, getQueue, isStarted, removeAttack, removeMessageListener, setAI, setName, start
 
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, 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, isMonsterOrPlayer, isTerrain, isUncursed, isUnpaid, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, removeContainerChangeListener, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, 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.lib.properties.Damageable
getHP, getMaxHP
 

Constructor Detail

PlayerImpl

public PlayerImpl()
Constructs a new PlayerImpl. Creates the CommandList here, so when AddRemoveNotify properties are added, and want to register commands on startup, the list won't be null.

Method Detail

computeStartTime

public void computeStartTime()
Initializes idle timer and start date.


init

public void init(RemoteClient client,
                 Dimension viewsize)
Description copied from interface: Player
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.

Specified by:
init in interface Player
Parameters:
client - the RemoteClient used for sending information.
viewsize - the size of the client's map viewport

reconnect

public void reconnect(RemoteClient client,
                      Dimension viewsize)
Description copied from interface: Player
Reconnects a net-dead player. Don't call it.

Specified by:
reconnect in interface Player
Parameters:
client - the new RemoteClient handling server output
viewsize - the client view width and height

readAliases

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

Specified by:
readAliases in interface Player

processStartupCommands

protected void processStartupCommands()
Gets the list of startup commands from the "startcmds" StringList property, and puts each one in the agent's queue.


getAliases

public java.util.Map getAliases()
Description copied from interface: Player
Returns the aliases for this player.

Specified by:
getAliases in interface Player
Returns:
a Map of the aliases (the keys for the map) and their expansions (the values).

setLevelProperties

public void setLevelProperties()
Description copied from class: MonsterImpl
Initializes default properties based on the monster's level.

Overrides:
setLevelProperties in class MonsterImpl

broadcastEntry

public void broadcastEntry(boolean entered)
Tells certain lists that the player entered or left the game.

Parameters:
entered - true if the player is entering; false if leaving

isNetDead

public boolean isNetDead()
Description copied from interface: Player
Returns true if the player is currently net-dead.

Specified by:
isNetDead in interface Player

getHostAddress

public java.lang.String getHostAddress()
Description copied from interface: Player
Returns the IP address this player is connected from.

Specified by:
getHostAddress in interface Player

getPassword

public java.lang.String getPassword()
Description copied from interface: Player
Returns the player's encrypted password.

Specified by:
getPassword in interface Player

serverTransfer

public void serverTransfer(java.lang.String host)
Description copied from interface: Player
Tells the client to connect to a different server after a successful transfer.

Specified by:
serverTransfer in interface Player
Parameters:
host - the host of the server the player is now visiting

sendFile

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

Specified by:
sendFile in interface Player
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.

getName

public java.lang.String getName()
Description copied from interface: Commandable
Returns the name of this commandable

Specified by:
getName in interface Commandable
Overrides:
getName in class AbstractCommandable

getTitle

public java.lang.String getTitle()
Description copied from interface: Player
Returns the player's title, e.g. "Adventurer".

Specified by:
getTitle in interface Player

computeTitle

protected java.lang.String computeTitle()
Figures out what the player's title should be.


isHallOfFamer

public boolean isHallOfFamer()

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: Player
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.

Specified by:
setTitle in interface Player
Parameters:
title - the new title for the player

getAge

public int getAge()
Description copied from interface: Player
Returns the player's age in seconds.

Specified by:
getAge in interface Player

getCommand

public Command getCommand(CommandEvent event)
Description copied from interface: Commandable
Figures out who will handle a given command.

Asks the Commandable to look in its table of registered commands to find a Command to handle the specified command.

Specified by:
getCommand in interface Commandable
Overrides:
getCommand in class AbstractCommandable

message

public void message(java.lang.String msg)
Description copied from interface: Commandable
Outputs a message to this object.

Mostly used by Player and subclasses; monsters ignore messages by default (but they can intercept them if they like). Spells could conceivably be voice-activated too.

Specified by:
message in interface Commandable
Overrides:
message in class AbstractCommandable

message

public void message(java.lang.String msg,
                    byte style)
Description copied from interface: Commandable
Sends a message to the client using the specified style.

Specified by:
message in interface Commandable
Overrides:
message in class MonsterImpl

message

public void message(java.lang.String[] strings,
                    byte[] styles)
Description copied from interface: Commandable
Sends a message to the client as an array of strings and styles to use for each piece. This way you can send a message with mixed styles.

Specified by:
message in interface Commandable
Overrides:
message in class MonsterImpl

sendPicture

public void sendPicture(java.lang.String path,
                        java.lang.String title,
                        byte format,
                        byte align,
                        byte view,
                        int flags)
Description copied from interface: Commandable
Sends a picture to the client. The picture must be on the server, either in a wiz directory or under the main game artwork directory. This is only implemented for players, but exists in the Commandable interface to cut down on class casting.

Specified by:
sendPicture in interface Commandable
Overrides:
sendPicture in class AbstractCommandable

sendPicture

public void sendPicture(java.lang.String path,
                        java.lang.String title)
Description copied from interface: Commandable
Sends a picture to the client. The picture must be on the server, either in a wiz directory or under the main game artwork directory. This is only implemented for players, but exists in the Commandable interface to cut down on class casting.

The image is sent to the server-output window on the client, and it's left aligned by default. You can use the overloaded version of sendPicture to control the alignment and/or view that you want for the image. The image is assumed to be a GIF.

Specified by:
sendPicture in interface Commandable
Overrides:
sendPicture in class AbstractCommandable

tellLater

public void tellLater(java.lang.String msg,
                      byte style)
Description copied from interface: Player
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.

Specified by:
tellLater in interface Player
Parameters:
msg - the message to send
style - the RPCConstants.TextStyle

command

public void command(java.lang.String cmd,
                    boolean user)
Method called when a command is added to the command queue. The PlayerImpl version contains some support for the "again" command - if the passed command isn't "again", we set the command text in a "@last-command" property used by the handler for the "again" command.

Specified by:
command in interface Commandable
Overrides:
command in class AbstractCommandable
Parameters:
cmd - the command that was entered
user - true if player-originated

enqueueCommand

public void enqueueCommand(java.lang.String command,
                           boolean user)
Description copied from interface: Player
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.

Specified by:
enqueueCommand in interface Player
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).

registerCommand

public void registerCommand(java.lang.String command,
                            Command handler)
Description copied from interface: Commandable
Registers a new command with the monster or player.

When the monster or player enters the command, the passed callback object will be notified so it can execute the command.

Specified by:
registerCommand in interface Commandable
Overrides:
registerCommand in class AbstractCommandable

unregisterCommand

public void unregisterCommand(java.lang.String command,
                              Command handler)
Description copied from interface: Commandable
Unregisters a command. The specified handler object will no longer be notified if the user types the command.

Specified by:
unregisterCommand in interface Commandable
Overrides:
unregisterCommand in class AbstractCommandable

viewMap

public void viewMap(GameMap map,
                    int x,
                    int y)
This is used by the World object to show what's going on in the map while the player is logging in.

Specified by:
viewMap in interface Player
Parameters:
map - the map to view
x - the map x coordinate
y - the map y coordinate

createInventory

public void createInventory()
Creates the Inventory if not present, and sets the owner field. You shouldn't call this unless you're loading a player directly with PlayerManager.loadPlayer(), and you need to do something with the inventory.

Specified by:
createInventory in interface Monster
Overrides:
createInventory in class MonsterImpl

ensureAI

public void ensureAI()
Don't give us an AI on construction.

Overrides:
ensureAI in class MonsterImpl

kill

public void kill(GameObject attacker)
Kills the player.

Specified by:
kill in interface Damageable
Overrides:
kill in class MonsterImpl
Parameters:
attacker - the thing that killed the player

burial

public void burial(GameObject attacker)
Kills a player, for real. Makes a gravestone, deducts XP, and runs a method-hook called "died" where the parameter is the attacker.

Specified by:
burial in interface Monster
Overrides:
burial in class MonsterImpl
Parameters:
attacker - the agent who killed us (can be null)

makeGravestone

public void makeGravestone(GameObject attacker,
                           int xpLost,
                           int guildXpLost)

restart

public void restart()
Resets the player after dying.


toString

public java.lang.String toString()
Prints information about the player. NOTE: don't change this without good reason, since every time you see a player in the game, this is the text string you see.

Overrides:
toString in class MapObject
Returns:
a short String describing this object. If the object represents a group of items, such as coins, the returned description will be a modified version of the description that includes quantity information.

setMap

public void setMap(GameMap map,
                   int x,
                   int y)
Puts the player in a new map. Sets the camera to view where we've been placed. Also wakes up any sleeping monsters, and generates a MapPlayerEvent for listeners in the map.

Specified by:
setMap in interface GameObject
Overrides:
setMap in class MonsterImpl
Parameters:
map - the GameMap we're moving to.
x - map x coordinate
y - map y coordinate

remove

public void remove()
Description copied from interface: GameObject
Removes this object from its map. This is the correct way take an object out of a map - you shouldn't invoke the map's remove() method on the object.

Specified by:
remove in interface GameObject
Overrides:
remove in class MonsterImpl

updateMapLocation

protected void updateMapLocation(java.util.List src,
                                 java.util.List dest)
Description copied from class: MapObject
This method is called by move(), teleport() and setLocations() to remove the object from its old locations and place it in its new locations.

Overrides:
updateMapLocation in class MapObject
Parameters:
src - the location list that the object occupied.
dest - the new positions to use

wakeMonsters

public void wakeMonsters()
Maybe wakes up nearby monsters. Called when player moves.


save

public boolean save()
Description copied from interface: Player
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.

Specified by:
save in interface Player

autosave

public boolean autosave()
Description copied from interface: Player
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.

Specified by:
autosave in interface Player
Returns:
true if successful, false if didn't save

quitSafely

public void quitSafely()
Description copied from interface: Player
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.

Specified by:
quitSafely in interface Player

stop

public void stop()
Stops the player permanently. You can't restart a player after calling this.

Specified by:
stop in interface Commandable
Overrides:
stop in class MonsterImpl

destroy

public void destroy()
Destroys the player object. You *really* don't want to call this externally. Command the player to "quit" and it will happen automatically.

Specified by:
destroy in interface GameObject
Overrides:
destroy in class AbstractCommandable

quit

public void quit()
Description copied from interface: Player
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.

Specified by:
quit in interface Player

dropInventoryIfGuest

public void dropInventoryIfGuest()

setSession

public void setSession(wyvern.server.IClientSession session)
Description copied from interface: Player
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.

Specified by:
setSession in interface Player
Parameters:
session - the thread reading from the client socket

getSession

public wyvern.server.IClientSession getSession()
Description copied from interface: Player
Returns the ClientSession for this player. Don't use it.

Specified by:
getSession in interface Player

isShutDown

public boolean isShutDown()
Description copied from interface: Player
Returns true if this Player object is defunct (the player has logged out).

Specified by:
isShutDown in interface Player

updateClient

public void updateClient()
Description copied from interface: Player
Sends all our visible stats to the client.

Specified by:
updateClient in interface Player

getFullTitle

public java.lang.String getFullTitle()
Description copied from interface: Player
Returns a full title, such as "Rawk the Elven Adventurer".

Specified by:
getFullTitle in interface Player

sendHP

public void sendHP()
Description copied from interface: Player
Updates the player's hit-points display on the client.

Specified by:
sendHP in interface Player

sendSP

public void sendSP()
Description copied from interface: Player
Updates the player's spell-points display on the client.

Specified by:
sendSP in interface Player

sendXP

public void sendXP()
Description copied from interface: Player
Updates the player's experience display on the client.

Specified by:
sendXP in interface Player

sendLevel

public void sendLevel()
Description copied from interface: Player
Updates player's level display on the client.

Specified by:
sendLevel in interface Player

sendFood

public void sendFood()
Description copied from interface: Player
Updates player's food display on the client.

Specified by:
sendFood in interface Player

sendName

public void sendName()
Description copied from interface: Player
Updates the player's name on the client.

Specified by:
sendName in interface Player

sendRange

public void sendRange()
Description copied from interface: Player
Updates the player's range-weapon on the client.

Specified by:
sendRange in interface Player

sendLoad

public void sendLoad()
Description copied from interface: Player
Updates the player's encumbrance display on the client. Called automatically by setEncumbrance().

Specified by:
sendLoad in interface Player

sendSpells

public void sendSpells()
Description copied from interface: Player
Resends the player's list of known spells to the client.

Specified by:
sendSpells in interface Player

ensurePartsList

protected void ensurePartsList()
Description copied from class: MonsterImpl
Makes a default (humanoid) body-parts list for the monster.

Overrides:
ensurePartsList in class MonsterImpl

getSpellList

public SpellList getSpellList()
Description copied from interface: Player
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 Player
Overrides:
getSpellList in class MonsterImpl

sendTile

public void sendTile(int tile,
                     java.lang.String path,
                     long timestamp)

sendImage

public void sendImage(java.lang.String path)

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.

Specified by:
uncacheImage in interface Player
Parameters:
path - the relative path to the image, such as wiz/rhialto/images/big_rock (note: no extension).

getXP

public int getXP()
Description copied from interface: Player
Returns the player's experience.

Specified by:
getXP in interface Player

getXPAward

public int getXPAward()
Description copied from interface: Attackable
Returns the experience award for killing this monster.

Specified by:
getXPAward in interface Attackable
Overrides:
getXPAward in class MonsterImpl

adjustXP

public void adjustXP(int adjust)
Description copied from interface: Player
Adjusts the player's experience points upwards or downwards.

Specified by:
adjustXP in interface Player
Parameters:
adjust - a number (possibly negative) to add to the player's xp

setHP

public void setHP(int hp)
Description copied from interface: Monster
Sets the current HP for the player, but keeps it within the valid range of (0, "max-hp")

Specified by:
setHP in interface Monster
Overrides:
setHP in class MonsterImpl

setSP

public void setSP(int sp)
Description copied from interface: Monster
Sets the current SP for the player, but keeps it within the valid range of (0, "max-sp")

Specified by:
setSP in interface Monster
Overrides:
setSP in class MonsterImpl

adjustHP

public void adjustHP(int adjust)
Description copied from interface: Damageable
Adjusts the object's hit points upwards or downwards.

Specified by:
adjustHP in interface Damageable
Overrides:
adjustHP in class MonsterImpl

adjustSP

public void adjustSP(int adjust)
Description copied from interface: Monster
Adjusts the monster's spell points upwards or downwards.

Specified by:
adjustSP in interface Monster
Overrides:
adjustSP in class MonsterImpl

getAlignment

public int getAlignment()
Returns player's alignment

Specified by:
getAlignment in interface Player
Returns:
the alignment value (-1000 to 1000)

adjustAlign

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

Specified by:
adjustAlign in interface Player
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.

adjustSkill

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

Specified by:
adjustSkill in interface Player
Parameters:
name - the skill name, such as "sk-incantation"
adjust - the adjustment (can be negative)

getRace

public java.lang.String getRace()
Description copied from interface: Player
Returns player's race.

Specified by:
getRace in interface Player
Returns:
"human", "high elf", etc.

getSex

public java.lang.String getSex()
Description copied from interface: Player
Returns player's gender.

Specified by:
getSex in interface Player
Returns:
"male" or "female"

getFood

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

Specified by:
getFood in interface Player

getMaxFood

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

Specified by:
getMaxFood in interface Player
Returns:
the max food the player can hold

getGroundCamera

public Camera getGroundCamera()
Description copied from interface: Player
Returns the camera that displays the ground beneath the player.

Specified by:
getGroundCamera in interface Player
Returns:
a wyvern.kernel.player.GroundCamera

getGroundObject

public GameObject getGroundObject(int index)
Description copied from interface: Player
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.

Specified by:
getGroundObject in interface Player
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.

Specified by:
getPositionInViewport in interface Player
Returns:
the player's position in the viewport.

getMapCamera

public Camera getMapCamera()
Description copied from interface: Player
Returns the camera that displays the map.

Specified by:
getMapCamera in interface Player
Returns:
a wyvern.kernel.player.MapCamera

controlCamera

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

Specified by:
controlCamera in interface Player
Parameters:
control - false to grab control of the camera, true to return control to the Player.

setViewSize

public void setViewSize(int width,
                        int height)
Description copied from interface: Player
Sets new dimensions for the map camera.

Specified by:
setViewSize in interface Player
Parameters:
width - the new camera view width (in tiles)
height - the new camera view height (in tiles)

adjustWallet

public void adjustWallet(long amount)
Description copied from interface: Monster
Adjusts the amount of money the player is carrying by a positive or negative amount.

Specified by:
adjustWallet in interface Monster
Overrides:
adjustWallet in class MonsterImpl

heartbeat

public void heartbeat()
Heartbeat notification, called every 5 seconds on every player and (started) monster in the game. Runs a method-hook called "heartbeat" before the rest of the code is run. Handles regeneration of various properties, and also autosaving the player every few minutes,

Specified by:
heartbeat in interface HeartbeatCallback
Overrides:
heartbeat in class MonsterImpl

getHeart

public Heart getHeart()

setHeart

public void setHeart(Heart heart)

getShoutPoints

public int getShoutPoints()
Description copied from interface: Player
Returns the player's shout points.

Specified by:
getShoutPoints in interface Player

adjustShoutPoints

public void adjustShoutPoints(int adjust)
Description copied from interface: Player
Adjusts the player's shout points upwards or downwards.

Specified by:
adjustShoutPoints in interface Player
Parameters:
adjust - a number (possibly negative) to add to the player's shp

adjustFood

public void adjustFood(int adjust)
Description copied from interface: Player
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).

Specified by:
adjustFood in interface Player

getCombatQueue

public EventQueue getCombatQueue()
Returns the combat queue, in case you want to place attack commands into it directly.

Specified by:
getCombatQueue in interface Commandable
Overrides:
getCombatQueue in class AbstractCommandable
Returns:
the EventQueue used for attack commands

ensureEventQueue

protected void ensureEventQueue()
Creates an extra event queue for combat commands, so automatic combat happens in parallel with movement. This is so you don't get "paralyzed" every time you attack.

Overrides:
ensureEventQueue in class AbstractCommandable

notifyAttacked

public void notifyAttacked(Commandable attacker)
Description copied from interface: Attackable
Notifies the object it's being attacked. Happens during the successful execution of the AttackEvent, before the damage is computed.

Specified by:
notifyAttacked in interface Attackable
Overrides:
notifyAttacked in class MonsterImpl
Parameters:
attacker - the thing attacking us

getCommandList

public CommandList getCommandList()
Description copied from interface: Player
Returns the CommandList for this player.

Specified by:
getCommandList in interface Player

startPoison

public void startPoison()
Description copied from interface: Player
Turns the client HP indicator green.

Specified by:
startPoison in interface Player

stopPoison

public void stopPoison()
Description copied from interface: Player
Returns the client HP indicator red.

Specified by:
stopPoison in interface Player

mapLoaded

public void mapLoaded(GameMap map,
                      java.lang.String name)
If the player applies a teleporter for a map that hasn't been loaded yet, this method gets called when the map finishes loading. If the player has a "force-map" property containing the location of the map, the player is commanded to teleport into the map. Otherwise, the player just gets a message saying the map is now available.

Specified by:
mapLoaded in interface MapLoaderListener
Parameters:
map - the map reference
name - the name of the map

mapLoadFailed

public void mapLoadFailed(java.lang.String name)
Called when the requested map couldn't be loaded.

Specified by:
mapLoadFailed in interface MapLoaderListener
Parameters:
name - the name of the map that failed.

isTelnet

public boolean isTelnet()
Description copied from interface: Player
Returns true if we're connected via a Telnet client.

Specified by:
isTelnet in interface Player
Overrides:
isTelnet in class AbstractCommandable

getClient

public RemoteClient getClient()
Description copied from interface: Player
Returns the RemoteClient implementation for this player.

Specified by:
getClient in interface Player

setNetDead

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

Specified by:
setNetDead in interface Player

solvedQuest

public boolean solvedQuest(java.lang.String name)
Description copied from interface: Player
Returns true if the player has solved the specified quest.

Specified by:
solvedQuest in interface Player
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 final boolean isWizard()
Description copied from interface: Player
Returns true if the player is a Wizard (any level).

Specified by:
isWizard in interface Player
Overrides:
isWizard in class MapObject

isGuest

public final boolean isGuest()
Description copied from interface: Player
Returns true if the player is a guest.

Specified by:
isGuest in interface Player
Returns:
true if this is a guest player (no registered account)

isPlayer

public final boolean isPlayer()
Description copied from interface: GameObject
Returns true if (and only if) this is a Player.

Specified by:
isPlayer in interface GameObject
Overrides:
isPlayer in class MonsterImpl

isMonster

public final boolean isMonster()
Description copied from interface: GameObject
Returns true if (and only if) this is a Monster (and not a Player).

Specified by:
isMonster in interface GameObject
Overrides:
isMonster in class MonsterImpl

outranks

public boolean outranks(Commandable other)
Description copied from interface: Player
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.

Specified by:
outranks in interface Player
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()
Description copied from interface: Player
Returns true if the player is connected via a handheld client.

Specified by:
isHandheld in interface Player
Returns:
true if using a PDA

setEncumbrance

public void setEncumbrance(int load)
Sets the encumbrance of the player.

Specified by:
setEncumbrance in interface Commandable
Overrides:
setEncumbrance in class AbstractCommandable
Parameters:
load - the encumbrance from 0-4

getIdleTime

public int getIdleTime()
Description copied from interface: Player
Returns the number of seconds the player has been idle.

Specified by:
getIdleTime in interface Player

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.

Specified by:
resetIdleTimer in interface Player

getStartTime

public long getStartTime()
Description copied from interface: Player
Returns System.currentTimeMillis() when the player logged in.

Specified by:
getStartTime in interface Player

getStartDate

public java.util.Date getStartDate()
Description copied from interface: Player
Returns the time when the player logged in.

Specified by:
getStartDate in interface Player

inCombat

public boolean inCombat()
Description copied from interface: Player
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.

Specified by:
inCombat in interface Player
Returns:
true if the player's most recent combat update happened within the last COMBAT_DELAY seconds.

combatTimeLeft

public long combatTimeLeft()
Description copied from interface: Player
Returns time left before we change this API.

Specified by:
combatTimeLeft in interface Player
Returns:
the System.currentTimeMillis() timestamp from the last updateCombat() message.

lastCombat

public long lastCombat()
Description copied from interface: Player
Returns the last time the player had an updateCombat() method called.

Specified by:
lastCombat in interface Player
Returns:
the System.currentTimeMillis() timestamp from the last updateCombat() message.

updateCombat

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

Specified by:
updateCombat in interface Player

getMusicState

public MusicState getMusicState()
Description copied from interface: Player
Returns the MusicState object keeping track of this player's running soundtrack.

Specified by:
getMusicState in interface Player
Returns:
a MusicState for the player - always non-null, although they may not have a client with music enabled.

playAlert

public void playAlert(java.lang.String path)
Description copied from interface: RemoteAudio
Plays the specified sound file on the client, one repeat, no delay, and the default gain.

Can't be stopped, so use with care.

Specified by:
playAlert in interface RemoteAudio
Overrides:
playAlert in class AbstractCommandable

playAlert

public void playAlert(java.lang.String path,
                      int repeats,
                      int repeatDelay,
                      double gain)
Description copied from interface: RemoteAudio
Plays the specified alert with custom parameters. Can't be stopped, so use with care.

Parameters are file path, number of repeats, delay between repeats, and gain (volume). The alert won't play if the path is null or not found on the server. All other params are adjusted to be within the valid range for the parameter, if necessary.

Specified by:
playAlert in interface RemoteAudio
Overrides:
playAlert in class AbstractCommandable

playDefaultMusic

public void playDefaultMusic()
Description copied from interface: RemoteAudio
The player has switched maps, so figure out the default background music to be playing, and plays it.

Specified by:
playDefaultMusic in interface RemoteAudio
Overrides:
playDefaultMusic in class AbstractCommandable

playPriorityMusic

public void playPriorityMusic(java.lang.String path)
Description copied from interface: RemoteAudio
Sets the background music track to the specified file, with the default gain/volume. Always defaults to zero repeats in this version. If you want repeats or looping, call the overloaded version that lets you specify other parameters.

Client sends an "#endmusic" directive back to the server when it's finished playing all the repeats.

When this playMusic() is called, the specified music overrides the current background music. The player is considered to be playing the soundtrack in "priority" mode, meaning that switching maps or combat states won't revert it back to the normal map or combat music.

Specified by:
playPriorityMusic in interface RemoteAudio
Overrides:
playPriorityMusic in class AbstractCommandable

playPriorityMusic

public void playPriorityMusic(java.lang.String path,
                              int repeats,
                              int delay,
                              double gain)
Description copied from interface: RemoteAudio
Plays the specified music with custom parameters.

Specified by:
playPriorityMusic in interface RemoteAudio
Overrides:
playPriorityMusic in class AbstractCommandable

stopMusic

public void stopMusic()
Description copied from interface: RemoteAudio
Stops the background music completely. Client does not send a notification back to the server.

Specified by:
stopMusic in interface RemoteAudio
Overrides:
stopMusic in class AbstractCommandable

setMusicGain

public void setMusicGain(double gain)
Description copied from interface: RemoteAudio
Sets the volume of the background music.

Specified by:
setMusicGain in interface RemoteAudio
Overrides:
setMusicGain in class AbstractCommandable

playSound

public void playSound(java.lang.String path,
                      java.lang.String id)
Description copied from interface: RemoteAudio
Plays a sound effect on the client with the default gain. Plays the sound exactly once, with no delay.

Client sends a "#endsound id" directive back to the server when the sound finishes playing, unless it was interrupted with stopSound() or stopAllSounds().

Specified by:
playSound in interface RemoteAudio
Overrides:
playSound in class AbstractCommandable

playSound

public void playSound(java.lang.String path,
                      java.lang.String id,
                      int repeats,
                      int repeatDelay,
                      double gain)
Description copied from interface: RemoteAudio
Plays the specified sound effect with custom parameters. Client sends a "#endsound id" directive back to the server when the sound finishes playing, unless it was interrupted with stopSound() or stopAllSounds().

Specified by:
playSound in interface RemoteAudio
Overrides:
playSound in class AbstractCommandable

stopSound

public void stopSound(java.lang.String id)
Description copied from interface: RemoteAudio
Stops the specified sound effect.

Specified by:
stopSound in interface RemoteAudio
Overrides:
stopSound in class AbstractCommandable

stopAllSounds

public void stopAllSounds()
Description copied from interface: RemoteAudio
Stops all of the currently playing sounds on the client. Does not stop the background music or any currently-playing alerts. No notifications are sent back from theclient.

Specified by:
stopAllSounds in interface RemoteAudio
Overrides:
stopAllSounds in class AbstractCommandable

setSoundGain

public void setSoundGain(java.lang.String id,
                         double gain)
Description copied from interface: RemoteAudio
Sets the volume of a particular sound playing on the client.

Specified by:
setSoundGain in interface RemoteAudio
Overrides:
setSoundGain in class AbstractCommandable

pauseSound

public void pauseSound(java.lang.String id)
Description copied from interface: RemoteAudio
Pauses a particular sound. The sound will stop playing on the client, and resume when we call resumeSound() with this track id. If the sound is stopped with stop() after pausing it, then it cannot be resumed, and will ignore the resumeSound() request.

Specified by:
pauseSound in interface RemoteAudio
Overrides:
pauseSound in class AbstractCommandable

resumeSound

public void resumeSound(java.lang.String id)
Description copied from interface: RemoteAudio
Resumes a particular sound. The sound will resume on the client, unless it was stopped after it was paused.

Specified by:
resumeSound in interface RemoteAudio
Overrides:
resumeSound in class AbstractCommandable

isRobot

public boolean isRobot()