|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.lib.properties.GuildSkills
The superclass of all bean property objects that implement Guild skills.
Field Summary | |
protected int |
guildXP_
How much guild XP the player currently has. |
static int[] |
XPCHART
We're going with 10 guild levels, so we use an exponential chart. |
Constructor Summary | |
GuildSkills()
|
Method Summary | |
void |
adjustGuildXP(int xp)
Awards some guild XP to the player, for killing a monster or doing some other task. |
int |
adjustXPForDeath(int percent)
Lose guild XP when you die. |
void |
advanceLevel(int level)
Does the stuff needed for advancing the agent a level. |
void |
announce(java.lang.String message)
Sends a message to all the guild members online. |
abstract boolean |
awardXP(DamageEvent event)
Returns true if the specified DamageEvent should result in the guild member getting guild XP. |
CommandEvent |
createEvent(CommandEvent initial)
Creates the command event. |
int |
crossedLevelBoundary(int oldxp,
int newxp)
Determines whether the player went up a level. |
boolean |
execute(CommandEvent event)
Executes the event. |
Player |
getAgent()
Reutrns the player we're modifying, if it's been set. |
int |
getGuildLevel()
Returns the guild level for our agent. |
static int |
getGuildLevel(int xp)
Returns the guild level for the given amount of XP. |
int |
getGuildLevel(Player agent)
Returns the level in the guild that this player has attained, based on settings in their guild skills object. |
abstract java.lang.String |
getGuildName()
Returns the official name for the guild, minus "Guild". |
abstract java.lang.String |
getGuildPluralName()
Returns the short, plural name for the guild, such as "Paladins" or "Axemen", used in phrases like "There are 20 Axemen online.". |
abstract java.lang.String |
getGuildShortName()
Returns the short name for the guild, such as "mage", "paladin", or "archer". |
abstract java.lang.String |
getGuildTag()
Returns the tag-property saying which guild this person is in, such as "paladin-guild" or "mages-guild". |
abstract java.lang.String |
getGuildTitle()
Returns the generic guild title to show in the high-score list, such as "Mage" or "Paladin". |
int |
getGuildXP()
Returns the guild XP associated with this GuildSkills object - i.e. the total amount of guild XP this player has received. |
abstract java.lang.String |
getTellCommand()
Returns the name of the command to use for guild-tell. |
abstract java.lang.String |
getTitle(Player p)
Returns the Guild Title to use for the player. |
abstract java.lang.String |
getWhoCommand()
Returns the name of the command to use for guild-who. |
boolean |
guildScore(CommandEvent event)
Shows current guild XP. |
boolean |
guildtell(Player agent,
java.lang.String verb,
java.lang.String message)
Tells a message to the other guild-members online. |
boolean |
guildwho(Commandable agent,
CommandEvent event)
Shows who's logged in. |
boolean |
isInGuild(Player p)
Returns true if the specified player is in this guild. |
boolean |
knowsCommand(java.lang.String command)
Returns true if we want to handle this command. |
void |
methodCalled(java.lang.String hookName,
MethodHookable target,
java.lang.Object data)
Notifies us that one of our method-hooks of interest was run. |
void |
notifyAdd(PropertyList obj)
The Guild object is being attached to the player - either from first joining the guild, or from logging in. |
void |
notifyRemove(PropertyList obj)
Notifies the property that it's being removed. |
void |
playerDoneLoading()
We've finished loading the player from the player file. |
void |
readData(org.w3c.dom.Node bean)
Tells the object to parse its externalized representation from a list of lines. |
void |
setGuildXP(int xp)
Sets the guild XP on this object - used when reading it from the map or player file. |
boolean |
shouldWrite()
Allows the object to determine whether it wants to be written out at all. |
abstract void |
shutdown()
Removes any guild abilities from the player. |
abstract void |
startup()
Sets up the guild abilities for the player. |
java.util.List |
writeData()
Tells the object to write its properties out to a text file. |
int |
xpForLevel(int level)
Returns XP required to reach the specified level. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int[] XPCHART
protected int guildXP_
Constructor Detail |
public GuildSkills()
Method Detail |
public abstract void startup()
This is where your GuildSkills subclass can register commands, add itself to hooks, adjust the player's stats and properties based on their guild level, and so on.
You should normally never adjust permanent properties on the player, and use transient ones instead. That way you won't accidentally wind up with bugs causing players to get 1000 hp or other accumulations. It also makes it much easier to tweak the guild abilities, since you don't have to go back and change all existing players.
In particular, you shouldn't store the player's guild level in the player's property list. You should get their level by calling getGuildLevel(), whenever you need to use it for calculations.
public abstract void shutdown()
public abstract java.lang.String getGuildName()
public abstract java.lang.String getGuildShortName()
public abstract java.lang.String getGuildPluralName()
public abstract java.lang.String getGuildTitle()
public abstract java.lang.String getGuildTag()
public abstract java.lang.String getTitle(Player p)
p
- the guild member
public abstract java.lang.String getWhoCommand()
public abstract java.lang.String getTellCommand()
public abstract boolean awardXP(DamageEvent event)
event
- a DamageEvent (may or may not have killed
the monster, but assume that it has). The passed event can be null in some (rare) cases, so check if it's null and don't award any guild XP in that case.
Properties set on the event include:
The event is reused to give XP to every group member, so don't modify the event - treat it as read-only.
The property can be null, so make sure to do null checks on the values after you extract them from the event.
public int adjustXPForDeath(int percent)
percent
- the percent of 10% that they lost from
regular XP. It's normally 100 (i.e. they lose 10%)
unless the player has a nonzero spirit-travelling skill.
public void notifyAdd(PropertyList obj)
notifyAdd
in interface AddRemoveNotify
obj
- the playerpublic void notifyRemove(PropertyList obj)
notifyRemove
in interface AddRemoveNotify
obj
- the GameObject whose property list we're being
removed from (in this case, the naga player)public void methodCalled(java.lang.String hookName, MethodHookable target, java.lang.Object data)
methodCalled
in interface MethodHookCallback
hookName
- the name of the hook being runtarget
- the object on which the method was invoked:
a GameMap or GameObject.data
- a method-specific data object; can be null.
Check the documentation for the method hook to see if
any data is passed to the callbacks.public void playerDoneLoading()
Be sure to call the superclass version in your version!
public Player getAgent()
public void setGuildXP(int xp)
public int getGuildXP()
public void adjustGuildXP(int xp)
xp
- the xp to add (can be negative)public void advanceLevel(int level)
level
- the level they're advancing topublic int crossedLevelBoundary(int oldxp, int newxp)
oldxp
- the old guild experience they hadnewxp
- the new guild experience they have, after
getting an adjustment.
public int getGuildLevel(Player agent)
public int getGuildLevel()
public static int getGuildLevel(int xp)
public boolean knowsCommand(java.lang.String command)
knowsCommand
in interface Command
command
- the command the player typed
public CommandEvent createEvent(CommandEvent initial)
createEvent
in interface Command
initial
- a "blank" CommandEvent containing only the
command text and the agent who's performing the command. This
initial event is created by the originator of the event (e.g.
the AI or player's command preprocessor).
public boolean execute(CommandEvent event)
execute
in interface Command
event
- the event
public boolean guildScore(CommandEvent event)
public boolean guildwho(Commandable agent, CommandEvent event)
public boolean guildtell(Player agent, java.lang.String verb, java.lang.String message)
public void announce(java.lang.String message)
public boolean isInGuild(Player p)
public int xpForLevel(int level)
level
- guild level (1-10)
public void readData(org.w3c.dom.Node bean) throws java.lang.Exception
readData
in interface SelfExternalizable
bean
- the XML DOM representation of the externalized
bean object. Its child could be a text node, in which case
the bean has to do all the parsing for the data. It could
also wrap a series of elements (e.g. archetypes), in which case
the bean may wish to leverage the XML parsing utilities that
the game provides in the ArchetypeManager.
java.lang.Exception
public java.util.List writeData() throws java.lang.Exception
writeData
in interface SelfExternalizable
java.lang.Exception
public boolean shouldWrite()
shouldWrite
in interface SelfExternalizable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |