com.planet_ink.coffee_mud.Behaviors
Class StdBehavior

java.lang.Object
  extended by com.planet_ink.coffee_mud.Behaviors.StdBehavior
All Implemented Interfaces:
Behavior, CMObject, Contingent, Modifiable, MsgListener, Tickable, java.lang.Cloneable, java.lang.Comparable<CMObject>
Direct Known Subclasses:
ActiveTicker, Aggressive, AlignHelper, Arrest, Beggar, BribeGateGuard, BrotherHelper, ClanHelper, CombatAbilities, CombatAssister, CommonSpeaker, Concierge, CorpseLooter, DoorwayGuardian, Drowness, EvilExecutioner, FaithHelper, FasterRecovery, GateGuard, GoldLooter, GoodExecutioner, GoodGuardian, Guard, Hireling, ItemIdentifier, ItemMender, ItemRefitter, LinkedWeather, MOBHelper, MoneyChanger, MudChat, Nanny, NoCombatAssist, ObjectGuardian, PlayerHelper, PokerDealer, PuddleMaker, RaceHelper, ResetWhole, ROMGangMember, ROMPatrolman, Sailor, Scriptable, ScriptableEverymob, Sounder, TaxCollector, Vagrant, Wimpy

public class StdBehavior
extends java.lang.Object
implements Behavior


Field Summary
protected static java.lang.String[] CODES
           
protected  boolean isSavableBehavior
           
protected  java.lang.String parms
           
 
Fields inherited from interface com.planet_ink.coffee_mud.Behaviors.interfaces.Behavior
CAN_AREAS, CAN_EXITS, CAN_ITEMS, CAN_MOBS, CAN_ROOMS, FLAG_LEGALBEHAVIOR, FLAG_MOBILITY, FLAG_POTENTIALLYAGGRESSIVE, FLAG_POTENTIALLYAUTODEATHING, FLAG_TROUBLEMAKING
 
Fields inherited from interface com.planet_ink.coffee_mud.core.interfaces.Tickable
STATUS_AFFECT, STATUS_ALIVE, STATUS_BEHAVIOR, STATUS_CLASS, STATUS_DEAD, STATUS_END, STATUS_FIGHT, STATUS_MISC, STATUS_MISC2, STATUS_MISC3, STATUS_MISC4, STATUS_MISC5, STATUS_MISC6, STATUS_MISC7, STATUS_NOT, STATUS_OTHER, STATUS_RACE, STATUS_REBIRTH, STATUS_SCRIPT, STATUS_START, STATUS_WEATHER, TICKID_AREA, TICKID_BEAMWEAPON, TICKID_CLAN, TICKID_CLANITEM, TICKID_DEADBODY_DECAY, TICKID_ELECTRONICS, TICKID_EMAIL, TICKID_EXIT_BEHAVIOR, TICKID_EXIT_REOPEN, TICKID_ITEM_BEHAVIOR, TICKID_ITEM_BOUNCEBACK, TICKID_LIGHT_FLICKERS, TICKID_LIVEAUCTION, TICKID_LONGERMASK, TICKID_MISCELLANEOUS, TICKID_MOB, TICKID_PROPERTY_SPECIAL, TICKID_QUEST, TICKID_READYTOSTOP, TICKID_ROOM_BEHAVIOR, TICKID_ROOM_ITEM_REJUV, TICKID_SOLITARYMASK, TICKID_SPECIALCOMBAT, TICKID_SPECIALMANEUVER, TICKID_SPELL_AFFECT, TICKID_SUPPORT, TICKID_TIMEAUCTION, TICKID_TRAP_DESTRUCTION, TICKID_TRAP_RESET
 
Constructor Summary
StdBehavior()
           
 
Method Summary
 java.lang.String accountForYourself()
          Returns a string describing what this behavior does.
 boolean amDestroyed()
          Whether the destroy() method has been previousy called on this object.
static boolean canActAtAll(Tickable affecting)
           
static boolean canFreelyBehaveNormal(Tickable affecting)
           
 boolean canImprove(int can_code)
          Returns whether this behavior is capable of enhancing the given type of object designated by the can_code.
 boolean canImprove(PhysicalAgent E)
          Returns whether this behavior is capable of enhancing the given type of object designated by E.
protected  int canImproveCode()
           
 int compareTo(CMObject o)
           
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
 void destroy()
          Utterly and permanently destroy this object, not only removing it from the map, but causing this object to be collected as garbage by Java.
 void executeMsg(Environmental host, CMMsg msg)
          The general message event handler for the object.
 java.util.List<java.lang.String> externalFiles()
          Returns a string list of any external files which may be required to make this ability work.
 long flags()
          Returns a bitmap made of up Behavior.FLAG_* constant masks which designates certain aspects about this behavior the rest of the system may need to know.
protected  MOB getBehaversMOB(Tickable ticking)
           
protected  Room getBehaversRoom(Tickable ticking)
           
protected  int getCodeNum(java.lang.String code)
           
 java.lang.String getParms()
          Returns the raw parameter string for this behavior.
 int getSaveStatIndex()
          Returns the index into the stat codes array where extra savable fields begins.
 java.lang.String getStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 java.lang.String[] getStatCodes()
          Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.
 int getTickStatus()
          A coded status for this object during the period where its tick method is being called.
 boolean grantsAggressivenessTo(MOB M)
          Returns the result of a very specific test, namely whether this behavior would be the direct cause of a malicious act against the given MOB object.
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 boolean isSavable()
          Whether, if this object is in a room, whether it is appropriate to save this object to the database as a permanent feature of its container.
 boolean isStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 java.lang.String L(java.lang.String str, java.lang.String... xs)
          Localize an internal string -- shortcut.
 java.lang.String name()
          The nice displayable name of this instance of this object
 CMObject newInstance()
          return a new instance of the object
 boolean okMessage(Environmental host, CMMsg msg)
          The general message event previewer for the object.
 java.lang.String parmsFormat()
          Unimplemented as of yet, but will hold a string telling the system what the proper format of any parms data.
 void registerDefaultQuest(java.lang.String questName)
          Called after a behavior is added to an Environmental object.
 boolean sameAs(Behavior E)
           
 void setParms(java.lang.String parameters)
          Sets the raw parameter string for this behavior.
 void setSavable(boolean truefalse)
          Sets whether this behavior can be saved as a permanent aspect of its host.
 void setStat(java.lang.String code, java.lang.String val)
          An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders.
 void startBehavior(PhysicalAgent forMe)
          Called after a behavior is added to a Behavable object.
 boolean tick(Tickable ticking, int tickID)
          this is the method which is called periodically by the threading engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parms

protected java.lang.String parms

isSavableBehavior

protected boolean isSavableBehavior

CODES

protected static final java.lang.String[] CODES
Constructor Detail

StdBehavior

public StdBehavior()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

name

public java.lang.String name()
Description copied from interface: Tickable
The nice displayable name of this instance of this object

Specified by:
name in interface CMObject
Specified by:
name in interface Tickable
Returns:
the displayable name of this object instance
See Also:
Environmental.Name()

canImproveCode

protected int canImproveCode()

flags

public long flags()
Description copied from interface: Behavior
Returns a bitmap made of up Behavior.FLAG_* constant masks which designates certain aspects about this behavior the rest of the system may need to know.

Specified by:
flags in interface Behavior
Returns:
a bitmap made up of Behavior.FLAG_* constants

grantsAggressivenessTo

public boolean grantsAggressivenessTo(MOB M)
Description copied from interface: Behavior
Returns the result of a very specific test, namely whether this behavior would be the direct cause of a malicious act against the given MOB object.

Specified by:
grantsAggressivenessTo in interface Behavior
Parameters:
M - the target to test for maliciousness to
Returns:
whether this behavior would harm the mob

getTickStatus

public int getTickStatus()
Description copied from interface: Tickable
A coded status for this object during the period where its tick method is being called. The statis is defined, at least in part, by constants in this interface STATUS_*. STATUS_NOT should be returned when the objects tick method is not currently in execution. It should never return STATUS_NOT when the objects tick method is in execution.

Specified by:
getTickStatus in interface Tickable
Returns:
the numeric status of this object
See Also:
Tickable.tick(Tickable, int)

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

accountForYourself

public java.lang.String accountForYourself()
Description copied from interface: Behavior
Returns a string describing what this behavior does. Mostly for thought and behavior reading systems.

Specified by:
accountForYourself in interface Behavior
Returns:
a string describing what this behavior does.

newInstance

public CMObject newInstance()
return a new instance of the object

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

registerDefaultQuest

public void registerDefaultQuest(java.lang.String questName)
Description copied from interface: Behavior
Called after a behavior is added to an Environmental object. The point is to register a quest objet, should it be needed or be useful to the quest.

Specified by:
registerDefaultQuest in interface Behavior
Parameters:
questName - the Quest name
See Also:
Quest

startBehavior

public void startBehavior(PhysicalAgent forMe)
Description copied from interface: Behavior
Called after a behavior is added to a Behavable object. The point is to do any initializing. This method assumes setParms() has already been called as well.

Specified by:
startBehavior in interface Behavior
Parameters:
forMe - the object to which this behavior has been added
See Also:
Behavable.addBehavior(Behavior), Behavior.setParms(String)

setSavable

public void setSavable(boolean truefalse)
Description copied from interface: Behavior
Sets whether this behavior can be saved as a permanent aspect of its host.

Specified by:
setSavable in interface Behavior
Specified by:
setSavable in interface Contingent
Parameters:
truefalse - whether this behavior can be saved as part of its host.
See Also:
Contingent.isSavable()

isSavable

public boolean isSavable()
Description copied from interface: Contingent
Whether, if this object is in a room, whether it is appropriate to save this object to the database as a permanent feature of its container. It always returns true except under unique circumstances.

Specified by:
isSavable in interface Contingent
Returns:
true, usually.

amDestroyed

public boolean amDestroyed()
Description copied from interface: Contingent
Whether the destroy() method has been previousy called on this object.

Specified by:
amDestroyed in interface Contingent
Returns:
whether the object is destroy()ed.

destroy

public void destroy()
Description copied from interface: Contingent
Utterly and permanently destroy this object, not only removing it from the map, but causing this object to be collected as garbage by Java. Containers, rooms. and mobs who have their destroy() method called will also call the destroy() methods on all items and other objects listed as content, recursively.

Specified by:
destroy in interface Contingent

getBehaversMOB

protected MOB getBehaversMOB(Tickable ticking)

getBehaversRoom

protected Room getBehaversRoom(Tickable ticking)

getParms

public java.lang.String getParms()
Description copied from interface: Behavior
Returns the raw parameter string for this behavior. Parameters are meant to modify or specify specific behavior of this Behavior.

Specified by:
getParms in interface Behavior
Returns:
the parameter string for this behavior
See Also:
Behavior.setParms(String)

setParms

public void setParms(java.lang.String parameters)
Description copied from interface: Behavior
Sets the raw parameter string for this behavior. Parameters are meant to modify or specify specific behavior of this Behavior.

Specified by:
setParms in interface Behavior
Parameters:
parameters - the parameter string for this behavior
See Also:
Behavior.getParms()

parmsFormat

public java.lang.String parmsFormat()
Description copied from interface: Behavior
Unimplemented as of yet, but will hold a string telling the system what the proper format of any parms data. Will use the CMParms.MTFORMAT_* constants for definition.

Specified by:
parmsFormat in interface Behavior
Returns:
the format expected for the parms field
See Also:
CMParms, Behavior.getParms(), Behavior.setParms(String)

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>

externalFiles

public java.util.List<java.lang.String> externalFiles()
Description copied from interface: Behavior
Returns a string list of any external files which may be required to make this ability work. Usually derived from the parameters. Files returned by this method should not be base distrib files!

Specified by:
externalFiles in interface Behavior
Returns:
a list of the path/names of files used by this behavior
See Also:
Behavior.setParms(String)

executeMsg

public void executeMsg(Environmental host,
                       CMMsg msg)
Description copied from interface: MsgListener
The general message event handler for the object. Messages passed herein may not necessarily be FOR this object, or from it, but will almost always represent events happening in the same room. The messages have already been through an approval process, so this method is called only to affect the final execution of the meaning of the message. Every game event goes through these methods.

Specified by:
executeMsg in interface MsgListener
Parameters:
host - either the initiator of the event, or the host of this object
msg - the CMMsg that needs to be executed
See Also:
CMMsg

okMessage

public boolean okMessage(Environmental host,
                         CMMsg msg)
Description copied from interface: MsgListener
The general message event previewer for the object. Messages passed herein are in a pending state, and may be safely modified or rejected without fear that they might be in the middle of being executed. Messages passed herein may not necessarily be FOR or FROM this object, but will almost always represent events which want to happen in the same rom. This method should always always return true UNLESS this message needs to be canceled, in which case it is necessary to tell the mob initiating the event (CMMsg.source()) why it is being cancelled. Every game event goes through these methods.

Specified by:
okMessage in interface MsgListener
Parameters:
host - either the initiator of the event, or the host of this object
msg - the CMMsg that wants to be executed
Returns:
whether this message is allowed to execute
See Also:
CMMsg, CMMsg.source()

canImprove

public boolean canImprove(int can_code)
Description copied from interface: Behavior
Returns whether this behavior is capable of enhancing the given type of object designated by the can_code. It derives from the protected Behavior.canImproveCode() method and uses the Behavior.CAN_* constants.

Specified by:
canImprove in interface Behavior
Parameters:
can_code - the Behavior.CAN_* mask to evaluate for this behavior
Returns:
whether the given type can be enhanced by this behavior
See Also:
canImproveCode(), Behavior

canImprove

public boolean canImprove(PhysicalAgent E)
Description copied from interface: Behavior
Returns whether this behavior is capable of enhancing the given type of object designated by E. It derives from the protected Behavior.canImproveCode() method.

Specified by:
canImprove in interface Behavior
Parameters:
E - the object to evaluate for this behavior
Returns:
whether the given object can be enhanced by this behavior
See Also:
canImproveCode()

canActAtAll

public static boolean canActAtAll(Tickable affecting)

canFreelyBehaveNormal

public static boolean canFreelyBehaveNormal(Tickable affecting)

tick

public boolean tick(Tickable ticking,
                    int tickID)
Description copied from interface: Tickable
this is the method which is called periodically by the threading engine. How often it is called depends on the parameters passed to the threadding engine when it is submitted for thread access. Typically the period is once per TIME_TICK period, but that is determined when the object is submitted to the thread engine.

Specified by:
tick in interface Tickable
Parameters:
ticking - a reference to this Tickable object
tickID - the TICKID_ constant describing this periodic call, as defined in Tickable
Returns:
true always, unless this object no longer wishes to ever tick again, in which case false
See Also:
Tickable, ServiceEngine, TickableGroup

L

public java.lang.String L(java.lang.String str,
                          java.lang.String... xs)
Localize an internal string -- shortcut. Same as calling:

Parameters:
str - the string to translate
xs - the array of variables to replace
Returns:
the translated string, with all variables in place
See Also:
Call with the string to translate, which may contain variables of the form @x1, @x2, etc. The array in xs is then used to replace the variables AFTER the string is translated.

getStatCodes

public java.lang.String[] getStatCodes()
Description copied from interface: Modifiable
Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.

Specified by:
getStatCodes in interface Modifiable
Returns:
list of the fields which may be set.
See Also:
Modifiable.getStat(String), Modifiable.setStat(String, String)

getCodeNum

protected int getCodeNum(java.lang.String code)

getStat

public java.lang.String getStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
getStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
the value of the field read
See Also:
Modifiable.getStatCodes()

setStat

public void setStat(java.lang.String code,
                    java.lang.String val)
Description copied from interface: Modifiable
An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. The value passed in is always a string, even if the field itself is numeric or a list.

Specified by:
setStat in interface Modifiable
Parameters:
code - the name of the field to set
val - the value to set the field to
See Also:
Modifiable.getStatCodes()

getSaveStatIndex

public int getSaveStatIndex()
Description copied from interface: Modifiable
Returns the index into the stat codes array where extra savable fields begins. This number is always the same as getStatCodes().length unless there are extra fields which need to be saved in xml for generic objects. This method is used by editors for post-build user-defined fields.

Specified by:
getSaveStatIndex in interface Modifiable
Returns:
the index into getStatCodes()
See Also:
Modifiable.getStatCodes(), Modifiable.getStat(String), Modifiable.setStat(String, String)

isStat

public boolean isStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
isStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
true if the code is a real value, false otherwise
See Also:
Modifiable.getStatCodes()

sameAs

public boolean sameAs(Behavior E)