com.planet_ink.coffee_mud.Commands
Class StdCommand

java.lang.Object
  extended by com.planet_ink.coffee_mud.Commands.StdCommand
All Implemented Interfaces:
Command, CMObject, java.lang.Cloneable, java.lang.Comparable<CMObject>
Direct Known Subclasses:
Account, Achievements, Activate, Affect, AFK, After, AHelp, Alias, Announce, ANSI, Areas, As, At, ATopics, AutoAffects, AutoAssist, AutoDraw, AutoExits, Autoforward, AutoGold, AutoGuard, AutoImprovement, AutoInvoke, AutoLoot, AutoMap, AutoMelee, AutoNotify, AutoRun, AutoWeather, Ban, Beacon, Bid, Boot, Borrow, Brief, Buy, Catalog, Channel, Channels, ChanWho, CharGen, ClanAccept, ClanApply, ClanAssign, ClanCreate, ClanDeclare, ClanDetails, ClanDonateSet, ClanExile, ClanHomeSet, ClanKills, ClanList, ClanMorgueSet, ClanPremise, ClanPVPKills, ClanQual, ClanReject, ClanResign, ClanTax, ClanVote, Cloak, Close, ColorSet, CommandJournal, Commands, Compare, Compress, Config, Consider, Copy, Create, Credits, Deactivate, DeferCmd, Deities, Deposit, Description, Destroy, Deviations, Dig, Disembark, Dismount, Display, Dress, DrinkCmd, Drop, Duel, DumpFile, Eat, Email, Emote, Equipment, Every, Examine, Exits, Experience, Expertises, Expire, Export, FactionList, Feed, Fill, Fire, Follow, Formation, Friends, Gain, Gait, GConsider, Generate, Get, Give, GModify, Go, Group, GTell, Help, HelpList, Hire, Hold, I3Cmd, Ignore, IMC2, Import, Inventory, JConsole, JRun, Kill, Knock, Learn, Leave, LineWrap, ListCmd, Load, Lock, Logoff, Look, Merge, MetaMsgCommand, Modify, Mood, MOTD, Mount, MPRun, MXP, NoANSI, NoBattleSpam, NoChannel, NOMXP, NoPurge, NoSounds, NoTeach, Open, Order, OutFit, Package, PageBreak, Password, Pause, PlayerKill, PollCmd, Poof, Pose, Possess, Pour, Practice, PreviousCmd, Prompt, Purge, Put, Questwins, Quiet, Quit, Read, Rebuke, Remort, Remove, Replay, Reply, Reset, Restring, Retire, Rules, Save, Say, Sell, Serve, Sheath, Shell, Shutdown, Sit, Skills, Sleep, Sniff, Snoop, SocialsCmd, Sounds, Split, Stand, Switch, SysMsgs, Take, Teach, Tell, Test, Throw, TickTock, Time, Title, Top, TrailTo, Train, Undress, UnLink, Unload, Unlock, Value, Vassals, Ver, View, Visible, Wake, Wear, Weather, Where, Whisper, Who, Wield, Wimpy, Withdraw, WizEmote, WizInv, WizList, Xml, Yell

public class StdCommand
extends java.lang.Object
implements Command


Field Summary
protected  java.lang.String ID
           
protected static Filterer<Environmental> noCoinFilter
           
 
Constructor Summary
StdCommand()
           
 
Method Summary
 double actionsCost(MOB mob, java.util.List<java.lang.String> cmds)
          Returns the number of actions required to completely activate this command.
 boolean canBeOrdered()
          Whether the a group leader or charmer can order their followers to do this command.
 boolean checkArguments(java.lang.Class[][] fmt, java.lang.Object... args)
           
 double checkedActionsCost(MOB mob, java.util.List<java.lang.String> cmds)
          Returns the number of actions required to completely activate this command.
 double combatActionsCost(MOB mob, java.util.List<java.lang.String> cmds)
          Returns the number of actions required to completely activate this command.
 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.
 boolean execute(MOB mob, java.util.List<java.lang.String> commands, int metaFlags)
          This method actually performs the command, when the given parsed set of command-line words.
 java.lang.Object executeInternal(MOB mob, int metaFlags, java.lang.Object... args)
          This method is used for making "insider" calls to the command.
 java.lang.String[] getAccessWords()
          Returns the set of command words, with the most public one first, that are entered by the user to initiate this command.
static java.lang.String[] I(java.lang.String[] str)
           
 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.
 java.lang.String L(java.lang.String str, java.lang.String... xs)
           
 java.lang.String name()
          The displayable name of this object.
 CMObject newInstance()
          Returns a new instance of this class.
 boolean preExecute(MOB mob, java.util.List<java.lang.String> commands, int metaFlags, int secondsElapsed, double actionsRemaining)
          This method is only called when the mob invoking this command does not have enough actions to complete it immediately.
 boolean securityCheck(MOB mob)
          Whether this command is available to the given player
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

protected final java.lang.String ID

noCoinFilter

protected static final Filterer<Environmental> noCoinFilter
Constructor Detail

StdCommand

public StdCommand()
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: CMObject
The displayable name of this object. May be modified by phyStats() object. Is derived from the Name().

Specified by:
name in interface CMObject
Returns:
the modified final name of this object on the map.
See Also:
Environmental.Name()

getAccessWords

public java.lang.String[] getAccessWords()
Description copied from interface: Command
Returns the set of command words, with the most public one first, that are entered by the user to initiate this command.

Specified by:
getAccessWords in interface Command
Returns:
the set of command words that the user enters

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

L

public java.lang.String L(java.lang.String str,
                          java.lang.String... xs)

I

public static java.lang.String[] I(java.lang.String[] str)

execute

public boolean execute(MOB mob,
                       java.util.List<java.lang.String> commands,
                       int metaFlags)
                throws java.io.IOException
Description copied from interface: Command
This method actually performs the command, when the given parsed set of command-line words. The commands list is almost always the set of strings, starting with the access word that triggered the command. Some commands have custom APIs however, that allow almost anything to be in the commands list, or even for the commands to be null. This method is not allowed to be called until the player or mob has satisfied the actionsCost requirements and the securityCheck

Specified by:
execute in interface Command
Parameters:
mob - the mob or player issueing the command
commands - usually the command words and parameters; a set of strings
metaFlags - flags denoting how the command is being executed
Returns:
whether the command was successfully executed. Is almost meaningless.
Throws:
java.io.IOException - usually means the player has dropped carrier
See Also:
Command.actionsCost(MOB, List), Command.securityCheck(MOB)

preExecute

public boolean preExecute(MOB mob,
                          java.util.List<java.lang.String> commands,
                          int metaFlags,
                          int secondsElapsed,
                          double actionsRemaining)
                   throws java.io.IOException
Description copied from interface: Command
This method is only called when the mob invoking this command does not have enough actions to complete it immediately. The method is called when the command is entered, and every second afterwards until the invoker has enough actions to complete it. At completion time, execute is called.

Specified by:
preExecute in interface Command
Parameters:
mob - the player or mob invoking the command
commands - the parameters entered for the command (including the trigger word)
metaFlags - flags denoting how the command is being executed
secondsElapsed - 0 at first, and increments every second
actionsRemaining - number of free actions the player is defficient.
Returns:
whether the command should be allowed to go forward. false cancels altogether.
Throws:
java.io.IOException - usually means the player has dropped carrier
See Also:
Command.execute(MOB, List, int)

executeInternal

public java.lang.Object executeInternal(MOB mob,
                                        int metaFlags,
                                        java.lang.Object... args)
                                 throws java.io.IOException
Description copied from interface: Command
This method is used for making "insider" calls to the command. It's parameters and implementation can follow any rules you like. The engine will sometimes use these to make direct calls to the command implementations.

Specified by:
executeInternal in interface Command
Parameters:
mob - the mob or player issueing the command
metaFlags - flags denoting how the command is being executed
args - a set of object parameters
Returns:
a object response
Throws:
java.io.IOException - usually means the player has dropped carrier

checkArguments

public boolean checkArguments(java.lang.Class[][] fmt,
                              java.lang.Object... args)

actionsCost

public double actionsCost(MOB mob,
                          java.util.List<java.lang.String> cmds)
Description copied from interface: Command
Returns the number of actions required to completely activate this command. A value of 0.0 means perform instantly. This method only applies when the user is not in combat.

Specified by:
actionsCost in interface Command
Parameters:
mob - the mob executing the command, if any
cmds - the parameters to be passed to the command, if any
Returns:
the number of player free actions required to do this
See Also:
Command.combatActionsCost(MOB, List), Command.checkedActionsCost(MOB, List)

combatActionsCost

public double combatActionsCost(MOB mob,
                                java.util.List<java.lang.String> cmds)
Description copied from interface: Command
Returns the number of actions required to completely activate this command. A value of 0.0 means perform instantly. This method only applies when the user is fighting in combat.

Specified by:
combatActionsCost in interface Command
Parameters:
mob - the mob executing the command, if any
cmds - the parameters to be passed to the command, if any
Returns:
the number of player free actions required to do this
See Also:
Command.actionsCost(MOB, List), Command.checkedActionsCost(MOB, List)

checkedActionsCost

public double checkedActionsCost(MOB mob,
                                 java.util.List<java.lang.String> cmds)
Description copied from interface: Command
Returns the number of actions required to completely activate this command. A value of 0.0 means perform instantly. This method only should check whether the user is in combat and return a proper value.

Specified by:
checkedActionsCost in interface Command
Parameters:
mob - the mob executing the command, if any
cmds - the parameters to be passed to the command, if any
Returns:
the number of player free actions required to do this
See Also:
Command.combatActionsCost(MOB, List), Command.actionsCost(MOB, List)

canBeOrdered

public boolean canBeOrdered()
Description copied from interface: Command
Whether the a group leader or charmer can order their followers to do this command.

Specified by:
canBeOrdered in interface Command
Returns:
whether this command can be ordered.

securityCheck

public boolean securityCheck(MOB mob)
Description copied from interface: Command
Whether this command is available to the given player

Specified by:
securityCheck in interface Command
Parameters:
mob - the player mob who might not even know about this command
Returns:
true if the command is available, and false if it is unknown

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

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

compareTo

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