wyvern.lib.classes.construct
Class Guild
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.lib.classes.construct.Guild
- All Implemented Interfaces:
- Broadcaster, Command, GameObject, MethodHookable, PropertyList
- public class Guild
- extends MapObject
- implements Command
A generic Guild class. You customize it by overriding
the methods. There are various things you need to handle,
so read the tutorial in the Wyvern Wiz Manual before making
your own guild.
- Version:
- 1.0, Aug 29, 2002
- Author:
- Steve Yegge
Constructor Summary |
Guild()
Constructs a new Guild |
Method Summary |
boolean |
chargeAdmission(Player agent)
Attempts to charge the player to join the guild. |
boolean |
checkJoin(Player agent)
Allows the subclass to do special checks to see if the
player is qualified to join, such as excluding certain races,
or disallowing entry based on alignment or other properties.
|
boolean |
checkQuest(Player agent)
Checks whether the player has solved the required quest
for this guild (if any). |
CommandEvent |
createEvent(CommandEvent event)
Creates the event. |
protected GuildSkills |
createGuildSkills()
Instantiates the GuildSkills object. |
boolean |
execute(CommandEvent event)
Executes the join/leave event. |
int |
getAdmissionFee()
Returns the cost to join the guild, in gold coins.
|
java.lang.String |
getFemaleImage()
Returns the path to the custom human-female image, if any. |
java.lang.String |
getGuildName()
Returns the name of the guild, such as "Mages" or "Paladins".
|
java.lang.String |
getGuildSkills()
Returns the GuildSkills subclass to use to handle the
special bonuses and penalties for this Guild.
|
java.lang.String |
getMaleImage()
Returns the path to the custom human-male image, if any. |
int |
getMinLevel()
Returns minimum level to join.
|
java.lang.String |
getQuestName()
Returns the name of the Quest needed to get into this guild, if any.
|
java.lang.String |
getRequiredQuest()
Returns the Quest needed to get into this guild, if any.
|
boolean |
handleJoin(Player agent)
Handles joining the guild. |
boolean |
hasCustomImage()
Returns true if there are custom images for humans in the guild. |
void |
initialize()
Initializes the object's default properties. |
void |
joinGuild(Player agent)
Puts the player in the guild. |
boolean |
knowsCommand(java.lang.String command)
Returns true if we know the command. |
boolean |
leaveGuild(Player agent)
Removes the player from the guild. |
boolean |
leaveGuild(Player agent,
boolean forced)
Forcibly expels the player from their guild. |
void |
revertCustomImage(Player agent)
Reverts the player back to their old image, if they had
a custom one for the guild. |
void |
setCustomImage(Player agent)
Sets the custom image for humans, and remembers the old
one they had. |
void |
setMap(GameMap map,
int x,
int y)
Puts the guild in the map. |
Methods inherited from class wyvern.kernel.maps.MapObject |
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMethodHook, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, destroy, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, 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, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMethodHook, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, runMethodHook, 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, toString, updateMapLocation |
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.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 |
DEFAULT_ADMISSION_FEE
public static final int DEFAULT_ADMISSION_FEE
- The default amount to join a guild is 100k gold. You can
override getAdmissionFee() to make it more or less than that.
- See Also:
- Constant Field Values
DEFAULT_MININUM_LEVEL
public static final int DEFAULT_MININUM_LEVEL
- Default minimum level to join the guild. You can override
this with getMinLevel();
- See Also:
- Constant Field Values
Guild
public Guild()
- Constructs a new Guild
initialize
public void initialize()
- Description copied from interface:
GameObject
- Initializes the object's default properties. Any GameObject
implementation that wishes to initialize itself should do so
here, rather than in the constructor. This is because nearly
all game objects inherit from an archetype, and the archetype
parent pointer isn't set until the object's constructor finishes.
This is a good place to add any class-default properties for
an object - properties that the object gets regardless of
which archetype it inherits from.
WARNING: don't forget to call the superclass' initialize()
method, or the object may not function properly. For instance,
it won't become animated even if it specifies animation parameters
in the archetype.
- Specified by:
initialize
in interface GameObject
- Overrides:
initialize
in class MapObject
setMap
public void setMap(GameMap map,
int x,
int y)
- Puts the guild in the map. Expands to fill the bounds specified
in the "width" and "height" properties, or failing that, the
entire bounds of the map.
- Specified by:
setMap
in interface GameObject
- Overrides:
setMap
in class MapObject
- Parameters:
map
- the map to put us inx
- the x-coordinate of our upper-left cornery
- the y-coordinate of our upper-left corner
knowsCommand
public boolean knowsCommand(java.lang.String command)
- Returns true if we know the command.
- Specified by:
knowsCommand
in interface Command
- Parameters:
command
- the entire command string, including arguments
- Returns:
- true if we want to handle the command
createEvent
public CommandEvent createEvent(CommandEvent event)
- Creates the event.
- Specified by:
createEvent
in interface Command
- Parameters:
event
- 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).
- Returns:
- a CommandEvent subclass encapsulating this command's
execution parameters and state. It should copy in the fields
from the passed-in event.
execute
public boolean execute(CommandEvent event)
- Executes the join/leave event.
- Specified by:
execute
in interface Command
- Parameters:
event
- the CommandEvent to execute
- Returns:
- true if the event completed successfully, else false.
handleJoin
public boolean handleJoin(Player agent)
- Handles joining the guild. Called when the player is
standing on the Guild object in a map, and types "join guild".
- Returns:
- true if they joined
joinGuild
public void joinGuild(Player agent)
- Puts the player in the guild. Called by handleJoin() if
they pass all the criteria for joining.
- Parameters:
agent
- the player to join the guild.
createGuildSkills
protected GuildSkills createGuildSkills()
- Instantiates the GuildSkills object. Calls getGuildSkills()
to get the class, and then does a Class.newInstance() on it.
getGuildSkills
public java.lang.String getGuildSkills()
- Returns the GuildSkills subclass to use to handle the
special bonuses and penalties for this Guild.
By default, returns a string property ("guild-skills")
on the guild object, which specifies the classname for
the GuildSkills that implements this guild.
- Returns:
- the classname of a GuildSkills object to instantiate.
It should be either a fully-qualified Java classname, such as
"wyvern.wiz.wyvern.archers.ArcherSkills", or it's a
relative python path, such as "wiz/rhialto/python/coders_guild.py".
getGuildName
public java.lang.String getGuildName()
- Returns the name of the guild, such as "Mages" or "Paladins".
By default, returns the value of the "guild-name" property
set on the guild.
checkQuest
public boolean checkQuest(Player agent)
- Checks whether the player has solved the required quest
for this guild (if any).
- Parameters:
agent
- the player trying to join the guild
- Returns:
- true if they've solved it, or no quest is required
checkJoin
public boolean checkJoin(Player agent)
- Allows the subclass to do special checks to see if the
player is qualified to join, such as excluding certain races,
or disallowing entry based on alignment or other properties.
GuildSkills.handleJoin does various checks as well, such as
making sure they're not in another exclusive guild.
- Parameters:
agent
- the player who wants to join
- Returns:
- true if they're allowed to join. false if not, and
if the method returns false, it should issue an appropriate
message to the agent, such as "We don't allow Mice in
the Elephants Guild".
getAdmissionFee
public int getAdmissionFee()
- Returns the cost to join the guild, in gold coins.
Can be set in an int "admission-fee" property on the guild,
or overridden by a subclass.
- Returns:
- the admission fee, in gold.
getMinLevel
public int getMinLevel()
- Returns minimum level to join.
If the guild has a "min-level" property, this method returns it.
Otherwise, returns the default minimum level for guilds.
hasCustomImage
public boolean hasCustomImage()
- Returns true if there are custom images for humans in the guild.
getMaleImage
public java.lang.String getMaleImage()
- Returns the path to the custom human-male image, if any.
- Returns:
- the path, or null if there's no custom male image
getFemaleImage
public java.lang.String getFemaleImage()
- Returns the path to the custom human-female image, if any.
- Returns:
- the path, or null if there's no custom female image
getRequiredQuest
public java.lang.String getRequiredQuest()
- Returns the Quest needed to get into this guild, if any.
Default behavior is to return the value of a "quest-tag"
String property on the guild.
- Returns:
- the quest-tag for the required quest, or null if no
quest is required.
getQuestName
public java.lang.String getQuestName()
- Returns the name of the Quest needed to get into this guild, if any.
Default behavior is to return the value of a "quest-name"
String property on the guild.
- Returns:
- the quest name for the required quest, such as "Mist Temple",
or null if no quest is required.
leaveGuild
public boolean leaveGuild(Player agent)
- Removes the player from the guild. Called when player stands
in the Guild and types "leave guild".
- Parameters:
agent
- the player trying to leave
- Returns:
- true if they succeeded, false if they didn't (which
is usually because the player wasn't in the guild to begin with.)
leaveGuild
public boolean leaveGuild(Player agent,
boolean forced)
- Forcibly expels the player from their guild. Only used
if they've committed the most severe transgression.
- Parameters:
agent
- the player leaving the guildforced
- true if they were forced; false if they
quit voluntarily
chargeAdmission
public boolean chargeAdmission(Player agent)
- Attempts to charge the player to join the guild. Calls
getAdmissionFee() and tries to deduct that much from the
agent's wallet. If they don't have enough, it tells them
they don't have enough to join, and returns false.
- Returns:
- true if we charged them the correct amount, false
if they didn't have enough (in which case we print a message
to them).
setCustomImage
public void setCustomImage(Player agent)
- Sets the custom image for humans, and remembers the old
one they had. Normally the default implementation is fine,
but you can override it in your Guild if you want.
- Parameters:
agent
- the player. If they're human, and the guild
has a custom image, it saves the player's old image under
the property "guild"-old-image", and sets their image to
getHumanFemaleImage() or getHumanMaleImage().
revertCustomImage
public void revertCustomImage(Player agent)
- Reverts the player back to their old image, if they had
a custom one for the guild. Done when player quits the guild.
- Parameters:
agent
- the player. Previous image should have been
stored in a property called "guild-old-image".