com.planet_ink.coffee_mud.Libraries.interfaces
Interface CMMiscUtils

All Superinterfaces:
java.lang.Cloneable, CMLibrary, CMObject, java.lang.Comparable<CMObject>
All Known Implementing Classes:
CoffeeUtensils

public interface CMMiscUtils
extends CMLibrary

The MiscUtils (Miscellaneous Utilities) library should not exist. Its purpose is to expose universal functionality that doesn't seem to fit anywhere else. Usually, however, it does fit elsewhere just fine, but the elsewhere felt too crowded already to receive it. I'm sure this library will always exist, but the interface is definitely subject to change.


Method Summary
 boolean armorCheck(MOB mob, int allowedArmorLevel)
          Given the allowedArmorLevel code and the mob, this method returns whether the given mob is only wearing permitted items on the applicable armor slots.
 boolean armorCheck(MOB mob, Item I, int allowedArmorLevel)
          Given the allowedArmorLevel code and the mob, this method returns whether the given mob is permitted to wear the given item is applicable armor slots given the armor level code.
 java.lang.String builtPrompt(MOB mob, java.lang.String prompt)
          Checks the given player mob for the format of their prompt in their playerstats and generates a fully formed prompt, complete with all variables filled in.
 boolean canBePlayerDestroyed(MOB mob, Item I, boolean ignoreBodies, boolean ignoreWeight)
          Returns whether the given item can be destroyed by the given mob, probably magically.
 long[][] compileConditionalRange(java.util.List<java.lang.String> condV, int numDigits, int startOfRange, int endOfRange)
          This strange method takes a list of space-delimited expressions of the form [CONDITION]number number number number, etc.
 void confirmWearability(MOB mob)
          This method removes all equipment from the mob and quickly attempt to re-wear/hold/wield it all where it originally was by issueing wear messages which are previewed and executed.
 java.util.List<Item> deepCopyOf(Item theContainer)
          Returns a copy of the given item/container and a copy of every item in that container, recursively.
 int disenchantItem(Item target)
          Removes magical effects from wands, and other spell holders, deletes any effects after attempting to uninvoke.
 boolean disInvokeEffects(Environmental E)
          Calls unInvoke on all effects on the given environmental.
 void extinguish(MOB source, Physical target, boolean mundane)
          Recursively extinguishes everything from the given target on down.
 Trap fetchMyTrap(Physical myThang)
          Returns any trap found on the given thing, or null.
 java.util.List<Race> getConstituantRaces(java.lang.String raceID)
          Breaks apart a given generic mixed race ID to figure out which races were combined to make it up.
 java.util.List<DeadBody> getDeadBodies(Environmental container)
          Returns any corpses found in the given container, recursively.
 java.lang.String getFormattedDate(Environmental E)
          Returns the current mud-month-day-year for the object, depending on the timeclock where the environmental is located.
 Language getLanguageSpoken(Physical P)
          Returns the language being spoke by the given object (mob, usually).
 Race getMixedRace(java.lang.String race1, java.lang.String race2, boolean ignoreRules)
          Absolutely returns the correct race when mixing races of the two given IDs.
 MOB getMobPossessingAnother(MOB mob)
          If any mob (probably a player) is possessing the given mob, this will return that mob, or null
 PairList<Item,java.lang.Long> getSeenEquipment(MOB mob, long wornMask)
          Returns a list of worn equipment at the top layer, where it can be seen.
 java.lang.String getUnsubscribeURL(java.lang.String name)
          Does its best to come up with a specially encoded unsubscribe url for a particular user.
 Item isRuinedLoot(MOB mob, Item I)
          This method parses the item ruinning rules and possibly ruins the given item by returning the ruined version.
 Trap makeADeprecatedTrap(Physical unlockThis)
          Creates one of the deprecated traps depending on what sort of object is passed in, whether it has a lid or a lock, etc.
 double memoryUse(Environmental E, int number)
          Returns a rediculous best guess on the amount of memory used by the given environmental.
 java.lang.String niceCommaList(java.util.List<?> V, boolean andTOrF)
          Nice english comma-delimited list, with oxford commas and trailing "and" or "or" at the end.
 void outfit(MOB mob, java.util.List<Item> items)
          Outfits the given mob with the list of given items.
 int processVariableEquipment(MOB mob)
          Assumes that every inventory item, equipped item, and store inventory are for an NPC mob, where "rejuv" doesn't really matter.
 boolean reachableItem(MOB mob, Environmental E)
          Returns whether the given Item is reachable by the given mob.
 void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag)
          Drops all items from the given mob into the given room which are inside the given container (or are the given item).
 void reloadCharClasses(CharClass oldC)
          Iterates through every mob and player in the game, replacing the old char class object given with the new one of the same ID from CMClass.
 boolean resurrect(MOB tellMob, Room corpseRoom, DeadBody body, int XPLevel)
          Resurrects the given body according to all system rules.
 void roomAffectFully(CMMsg msg, Room room, int dirCode)
          Normally just sends the message to the room by calling Room.send.
 Item ruinItem(Item I)
          Always converts the given item into the Ruined version
 void setTrapped(Physical myThang)
          Creates and sets a deprecated trap on the given exit, room, container, or whatever.
 void setTrapped(Physical myThang, Trap theTrap)
          Sets the given deprecated trap on the given exit, room, container, or whatever.
 void swapRaces(Race newR, Race oldR)
          Iterates through every mob and player in the game, replacing the old race object with the new one.
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, ID, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

builtPrompt

java.lang.String builtPrompt(MOB mob,
                             java.lang.String prompt)
Checks the given player mob for the format of their prompt in their playerstats and generates a fully formed prompt, complete with all variables filled in.

Parameters:
mob - the mob to build a prompt for
prompt - TODO
Returns:
the fully filled in customized prompt string

getFormattedDate

java.lang.String getFormattedDate(Environmental E)
Returns the current mud-month-day-year for the object, depending on the timeclock where the environmental is located.

Parameters:
E - the object curious about the date
Returns:
the date string

memoryUse

double memoryUse(Environmental E,
                 int number)
Returns a rediculous best guess on the amount of memory used by the given environmental.

Parameters:
E - the object to check for a footprint of
number - the accuracy -- higher is better
Returns:
the amount of memory used, very approximately

niceCommaList

java.lang.String niceCommaList(java.util.List<?> V,
                               boolean andTOrF)
Nice english comma-delimited list, with oxford commas and trailing "and" or "or" at the end. If the list is of environmental, it will use the name, otherwise, it casts everything as a string and lists it.

Parameters:
V - the objects to list
andTOrF - true for trailing and, false for trailing or
Returns:
the readable comma list.

compileConditionalRange

long[][] compileConditionalRange(java.util.List<java.lang.String> condV,
                                 int numDigits,
                                 int startOfRange,
                                 int endOfRange)
This strange method takes a list of space-delimited expressions of the form [CONDITION]number number number number, etc. E.G.: >1 3 2 5 3 2. Each list must contain the given num of digits. If the condition falls within the given start of range and end of range, then the condition range of entries in the returned array is populated with the values on that row.

Parameters:
condV - the list of fully expressions
numDigits - the min number of digits in each expression
startOfRange - the starting range to return
endOfRange - the ending range to return > startOfRange
Returns:
the list of number lists

outfit

void outfit(MOB mob,
            java.util.List<Item> items)
Outfits the given mob with the list of given items. If the mob does not have an item with the same name as one on the list, it is given to them magically. If they can, they will then wear it.

Parameters:
mob - the mob to outfit
items - the items to outfit the mob with

getLanguageSpoken

Language getLanguageSpoken(Physical P)
Returns the language being spoke by the given object (mob, usually). A null return usually means Common.

Parameters:
P - the mob to check
Returns:
the language being spoken.

reachableItem

boolean reachableItem(MOB mob,
                      Environmental E)
Returns whether the given Item is reachable by the given mob. It may not be reachable if the mob is riding something, and the item is on the ground, etc. If the object given is not an item, or null, true is always returned.

Parameters:
mob - the mob who wants to reach
E - the Item to reach for
Returns:
true, or false if it's unreachable

extinguish

void extinguish(MOB source,
                Physical target,
                boolean mundane)
Recursively extinguishes everything from the given target on down. If a room is given, everything in the room, including the room, is extinguished. Ordinary fires and torches also go out. The mundane flag is to prevent extinguishing elementals and magic flame spells.

Parameters:
source - the mob doing the extinguishing
target - the thing to extinguish
mundane - true to skip magic and elemental targets

armorCheck

boolean armorCheck(MOB mob,
                   int allowedArmorLevel)
Given the allowedArmorLevel code and the mob, this method returns whether the given mob is only wearing permitted items on the applicable armor slots.

Parameters:
mob - the mob to check
allowedArmorLevel - the allowed armor level
Returns:
true if the mob is good to go, false otherwise
See Also:
CharClass.ARMOR_DESCS

armorCheck

boolean armorCheck(MOB mob,
                   Item I,
                   int allowedArmorLevel)
Given the allowedArmorLevel code and the mob, this method returns whether the given mob is permitted to wear the given item is applicable armor slots given the armor level code.

Parameters:
mob - the mob to check
I - the item to check
allowedArmorLevel - the allowed armor level
Returns:
true if the mob is good to go for that item, false otherwise
See Also:
CharClass.ARMOR_DESCS

recursiveDropMOB

void recursiveDropMOB(MOB mob,
                      Room room,
                      Item thisContainer,
                      boolean bodyFlag)
Drops all items from the given mob into the given room which are inside the given container (or are the given item). The bodyFlag ensures that the contents are not marked for cleanup. This method does the deed, but does not generate any new messages. It also does not recover the state of the mob.

Parameters:
mob - the mob who is dropping
room - the room where it's being dropped
thisContainer - the item or container where the items must be
bodyFlag - true if the container is a body, false otherwise

deepCopyOf

java.util.List<Item> deepCopyOf(Item theContainer)
Returns a copy of the given item/container and a copy of every item in that container, recursively.

Parameters:
theContainer - the container or item to copy
Returns:
a list of copies of all the contents

confirmWearability

void confirmWearability(MOB mob)
This method removes all equipment from the mob and quickly attempt to re-wear/hold/wield it all where it originally was by issueing wear messages which are previewed and executed. In the end, the mob will be wearing everything that the system will let them wear. Moreover, this is all done silently.

Parameters:
mob - the mob to confirm the equipment of

processVariableEquipment

int processVariableEquipment(MOB mob)
Assumes that every inventory item, equipped item, and store inventory are for an NPC mob, where "rejuv" doesn't really matter. In those cases, the "rejuv" stat is, for non-rivalrous items, a pct chance of it being retained on this mob. For rivalrous items (two wielded swords, for example), it is a weighted chance of being selected. Electronics items also have their random stats determined at this time.

Parameters:
mob - the npc mob to process variable equipment on
Returns:
0 for success, -1 if an admin is in the room, so nothing could be done.

makeADeprecatedTrap

Trap makeADeprecatedTrap(Physical unlockThis)
Creates one of the deprecated traps depending on what sort of object is passed in, whether it has a lid or a lock, etc.

Parameters:
unlockThis - the exit, container, room, whatever
Returns:
the trap to add to the physical thing, or null

setTrapped

void setTrapped(Physical myThang)
Creates and sets a deprecated trap on the given exit, room, container, or whatever.

Parameters:
myThang - the thing to set the trap on.
See Also:
makeADeprecatedTrap(Physical), setTrapped(Physical, Trap), fetchMyTrap(Physical)

setTrapped

void setTrapped(Physical myThang,
                Trap theTrap)
Sets the given deprecated trap on the given exit, room, container, or whatever.

Parameters:
myThang - the thing to set the trap on.
theTrap - the deprecated trap to set on it
See Also:
makeADeprecatedTrap(Physical), setTrapped(Physical)

fetchMyTrap

Trap fetchMyTrap(Physical myThang)
Returns any trap found on the given thing, or null.

Parameters:
myThang - the thing to check for a trap
Returns:
the trap found, or null
See Also:
makeADeprecatedTrap(Physical)

getMobPossessingAnother

MOB getMobPossessingAnother(MOB mob)
If any mob (probably a player) is possessing the given mob, this will return that mob, or null

Parameters:
mob - the mob to check for possession
Returns:
the mob possessing the given mob

roomAffectFully

void roomAffectFully(CMMsg msg,
                     Room room,
                     int dirCode)
Normally just sends the message to the room by calling Room.send. However, if the target of the message is an exit, then the several exits involved would also informed by having executeMsg called on them.

Parameters:
msg - the message to send
room - the room to send the message to
dirCode - if known, the direction of the target exit

getDeadBodies

java.util.List<DeadBody> getDeadBodies(Environmental container)
Returns any corpses found in the given container, recursively.

Parameters:
container - the container that possibly has corpses
Returns:
a list of any corpses found, or an empty list

resurrect

boolean resurrect(MOB tellMob,
                  Room corpseRoom,
                  DeadBody body,
                  int XPLevel)
Resurrects the given body according to all system rules.

Parameters:
tellMob - if the corpse could not be resurrected, tell this mob.
corpseRoom - room to bring the mob to after resurrection, probably same as body's location
body - the corpse to resurrect
XPLevel - if > 0, and rules allow, bonus xp restored
Returns:
true if the resurrection happened, false otherwise

isRuinedLoot

Item isRuinedLoot(MOB mob,
                  Item I)
This method parses the item ruinning rules and possibly ruins the given item by returning the ruined version. Or it might do nothing and just return the item.

Parameters:
mob - the mob to get ruin policies for
I - the item to potentially ruin
Returns:
the ruined item, or the original item, depending

ruinItem

Item ruinItem(Item I)
Always converts the given item into the Ruined version

Parameters:
I - the item to ruin
Returns:
the new, ruined version
See Also:
isRuinedLoot(MOB, Item)

swapRaces

void swapRaces(Race newR,
               Race oldR)
Iterates through every mob and player in the game, replacing the old race object with the new one.

Parameters:
newR - the new race object
oldR - the old race object
See Also:
reloadCharClasses(CharClass)

reloadCharClasses

void reloadCharClasses(CharClass oldC)
Iterates through every mob and player in the game, replacing the old char class object given with the new one of the same ID from CMClass.

Parameters:
oldC - the old charclass object
See Also:
swapRaces(Race, Race)

canBePlayerDestroyed

boolean canBePlayerDestroyed(MOB mob,
                             Item I,
                             boolean ignoreBodies,
                             boolean ignoreWeight)
Returns whether the given item can be destroyed by the given mob, probably magically. This is a recursive check if the item is a container.

Parameters:
mob - the mob who wants to destroy the item
I - the item to destroy
ignoreBodies - true to ignore corpse checks, false otherwise
ignoreWeight - TODO
Returns:
true if the item can be destroyed, false otherwise

disInvokeEffects

boolean disInvokeEffects(Environmental E)
Calls unInvoke on all effects on the given environmental. This may not cause the effects to disappear, depending on the behavior of each effect.

Parameters:
E - the object to diseffect
Returns:
true if the item still exists, false if it was destroyed

disenchantItem

int disenchantItem(Item target)
Removes magical effects from wands, and other spell holders, deletes any effects after attempting to uninvoke. This method probably needs more thought, since not all effects are magic (though they usually are) The return value is a very strange number: 0 if the item is destroyed, -999 if nothing done, or the item level minus the magic value of what was done to it.

Parameters:
target - the object to disenchant.
Returns:
a bizarre number

getMixedRace

Race getMixedRace(java.lang.String race1,
                  java.lang.String race2,
                  boolean ignoreRules)
Absolutely returns the correct race when mixing races of the two given IDs. Applies system rules to the generation.

Parameters:
race1 - the mother race
race2 - the father race
ignoreRules - TODO
Returns:
the mixed race

getConstituantRaces

java.util.List<Race> getConstituantRaces(java.lang.String raceID)
Breaks apart a given generic mixed race ID to figure out which races were combined to make it up.

Parameters:
raceID - the raceID to break apart
Returns:
a list of constituant races, or empty.

getSeenEquipment

PairList<Item,java.lang.Long> getSeenEquipment(MOB mob,
                                               long wornMask)
Returns a list of worn equipment at the top layer, where it can be seen. An optional wornMask can narrow the locations allowed. The require list is the item, plus the worn location.

Parameters:
mob - the mob to get equipment from
wornMask - 0, or a bitmap of allowed wear locations
Returns:
the list of items and wear locations

getUnsubscribeURL

java.lang.String getUnsubscribeURL(java.lang.String name)
Does its best to come up with a specially encoded unsubscribe url for a particular user. The url will be unique to the user, but is man-in-the- middle attackable, as it is a simple hash.

Parameters:
name - the account or player name
Returns:
the full web url with http and everything