com.planet_ink.coffee_mud.Libraries.interfaces
Interface AreaGenerationLibrary

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

public interface AreaGenerationLibrary
extends CMLibrary

The AreaGenerationLibrary is the random generator, which takes a special flavor of xml as input to randomly generate anything from strings, to mobs and items, whole populated rooms, or entire areas. Most of the methods in this library provide a finer control to the generation process.


Nested Class Summary
static class AreaGenerationLibrary.LayoutFlags
          Enum of the type of room layoutnode
static interface AreaGenerationLibrary.LayoutManager
          Area generators work by first laying out a set of rooms into a configuration called a Layout.
static interface AreaGenerationLibrary.LayoutNode
          A layout node represents a single room in a layout manager.
static class AreaGenerationLibrary.LayoutRuns
          If this room layoutnode is a street type, what direction does it run?
static class AreaGenerationLibrary.LayoutTags
          Enum of the types of tags that room layoutnodes can be flagged with.
static class AreaGenerationLibrary.LayoutTypes
          Enum of the type of room layoutnode.
 
Method Summary
 void buildDefinedIDSet(java.util.List<XMLLibrary.XMLTag> xmlRoot, java.util.Map<java.lang.String,java.lang.Object> defined)
          Given an area-generation xml file, this method will return all the defined tag ids.
 Room buildRoom(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined, Exit[] exits, int direction)
          Given a specific ROOM generation tag, this method will return the room selected by that tag piece, with the entrace to it being in the given direction
 void checkRequirements(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          Does nothing but check the requirements to build the given xml tag piece, and compares it with the variables in the given id definition map, to see if all requirements are met.
 void defineReward(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          If an xml tag is selected manually, by something outside the library, then certain post-selection processes are not properly done, making generation based on the tag potentially impossible.
 boolean fillInArea(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined, Area A, int direction)
          Given a specific AREA generation tag, and an empty area, this method will populate the area with rooms from the given tag piece, with the entrance to it being in the given direction.
 Area findArea(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined, int directions)
          Given a specific AREA generation tag, this method will return the area selected by that tag piece, with the entrance to it being in the given direction
 java.util.List<Item> findItems(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          Given a specific ITEM generation tag, this method will return the items selected by that tag piece.
 java.util.List<MOB> findMobs(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          Given a specific MOB generation tag, this method will return the MOBs selected by that tag piece.
 java.lang.String findString(java.lang.String tagName, XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          Returns a string of the given tag name type, from the given top-level xml tag piece that resolves to a string, and with the given pre-defined id set.
 java.util.List<XMLLibrary.XMLTag> getAllChoices(java.lang.String tagName, XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          Given a root xml tag and a tag name, this method will return all matching xml tag pieces.
 AreaGenerationLibrary.LayoutManager getLayoutManager(java.lang.String named)
          Returns the layout manager of the given name.
 java.util.Map<java.lang.String,java.lang.String> getUnfilledRequirements(java.util.Map<java.lang.String,java.lang.Object> defined, XMLLibrary.XMLTag piece)
          Check the requirements to build the given xml tag piece, and compares it with the variables in the given id definition map, to see if all requirements are met.
 void postProcess(java.util.Map<java.lang.String,java.lang.Object> defined)
          Sometimes an object cannot be generated at a given time because some tag which will be defined later has not yet been defined, and cannot be resolved at generation time.
 void preDefineReward(XMLLibrary.XMLTag piece, java.util.Map<java.lang.String,java.lang.Object> defined)
          If an xml tag is selected manually, by something outside the library, then certain pre-selection processes are not properly done, making generation based on the tag potentially impossible.
 boolean relevelRoom(Room room, int oldMin, int oldMax, int newMin, int newMax)
          Adjusts the levels of all mobs, items, and mob-items in the room by adjusting them from their place in an existing range to a new range.Does not save -- that's up to you.
 
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

buildDefinedIDSet

void buildDefinedIDSet(java.util.List<XMLLibrary.XMLTag> xmlRoot,
                       java.util.Map<java.lang.String,java.lang.Object> defined)
Given an area-generation xml file, this method will return all the defined tag ids. This allows the caller to specifically select one of them for generation.

Parameters:
xmlRoot - the root of the area-generation xml file
defined - a map of ids to objects, whether strings or tags.

findItems

java.util.List<Item> findItems(XMLLibrary.XMLTag piece,
                               java.util.Map<java.lang.String,java.lang.Object> defined)
                               throws CMException
Given a specific ITEM generation tag, this method will return the items selected by that tag piece.

Parameters:
piece - the identified tag that can return items
defined - the defined id set from the entire xml document
Returns:
the list of items generated from the tag.
Throws:
CMException - any parsing or generation errors
See Also:
buildDefinedIDSet(List, Map)

findMobs

java.util.List<MOB> findMobs(XMLLibrary.XMLTag piece,
                             java.util.Map<java.lang.String,java.lang.Object> defined)
                             throws CMException
Given a specific MOB generation tag, this method will return the MOBs selected by that tag piece.

Parameters:
piece - the identified tag that can return MOBs
defined - the defined id set from the entire xml document
Returns:
the list of MOBs generated from the tag.
Throws:
CMException - any parsing or generation errors
See Also:
buildDefinedIDSet(List, Map)

findString

java.lang.String findString(java.lang.String tagName,
                            XMLLibrary.XMLTag piece,
                            java.util.Map<java.lang.String,java.lang.Object> defined)
                            throws CMException
Returns a string of the given tag name type, from the given top-level xml tag piece that resolves to a string, and with the given pre-defined id set.

Parameters:
tagName - the name of the string tag
piece - the top level piece, probably of type tagname
defined - the pre-defined id set from the entire xml document
Returns:
the string this resolves to
Throws:
CMException - any parsing or generation errors
See Also:
buildDefinedIDSet(List, Map)

buildRoom

Room buildRoom(XMLLibrary.XMLTag piece,
               java.util.Map<java.lang.String,java.lang.Object> defined,
               Exit[] exits,
               int direction)
               throws CMException
Given a specific ROOM generation tag, this method will return the room selected by that tag piece, with the entrace to it being in the given direction

Parameters:
piece - the identified tag that can return a room
defined - the defined id set from the entire xml document
exits - pre-defined exits from this room, if any
direction - the direction of entrance to this room
Returns:
the room generated from the tag.
Throws:
CMException - any parsing or generation errors
See Also:
buildDefinedIDSet(List, Map)

checkRequirements

void checkRequirements(XMLLibrary.XMLTag piece,
                       java.util.Map<java.lang.String,java.lang.Object> defined)
                       throws CMException
Does nothing but check the requirements to build the given xml tag piece, and compares it with the variables in the given id definition map, to see if all requirements are met. If not, it throws an exception.

Parameters:
piece - the xml tag piece you want to build
defined - the defined id set from the entire xml document, and the user
Throws:
CMException - any parsing or generation errors

getUnfilledRequirements

java.util.Map<java.lang.String,java.lang.String> getUnfilledRequirements(java.util.Map<java.lang.String,java.lang.Object> defined,
                                                                         XMLLibrary.XMLTag piece)
Check the requirements to build the given xml tag piece, and compares it with the variables in the given id definition map, to see if all requirements are met. If not, it returns a map of the undefined or mis-defined ids as keys, mapped to the data type name.

Parameters:
defined - the defined id set from the entire xml document, and the user
piece - the xml tag piece you want to build
Returns:
a map of the undefined or mis-defined ids as keys, mapped to the data type name

findArea

Area findArea(XMLLibrary.XMLTag piece,
              java.util.Map<java.lang.String,java.lang.Object> defined,
              int directions)
              throws CMException
Given a specific AREA generation tag, this method will return the area selected by that tag piece, with the entrance to it being in the given direction

Parameters:
piece - the identified tag that can return a room
defined - the defined id set from the entire xml document
directions - the direction of entrance to this room
Returns:
the area generated from the tag.
Throws:
CMException - any parsing or generation errors
See Also:
buildDefinedIDSet(List, Map)

fillInArea

boolean fillInArea(XMLLibrary.XMLTag piece,
                   java.util.Map<java.lang.String,java.lang.Object> defined,
                   Area A,
                   int direction)
                   throws CMException
Given a specific AREA generation tag, and an empty area, this method will populate the area with rooms from the given tag piece, with the entrance to it being in the given direction.

Parameters:
piece - the identified tag that can return a room
defined - the defined id set from the entire xml document
A - the area to put the rooms into
direction - the direction of entrance to this room
Returns:
true if everything went well, an exception otherwise
Throws:
CMException - any parsing or generation errors
See Also:
buildDefinedIDSet(List, Map)

getLayoutManager

AreaGenerationLibrary.LayoutManager getLayoutManager(java.lang.String named)
Returns the layout manager of the given name.

Parameters:
named - the name of the layout manager
Returns:
the layout manager of the given name.

postProcess

void postProcess(java.util.Map<java.lang.String,java.lang.Object> defined)
                 throws CMException
Sometimes an object cannot be generated at a given time because some tag which will be defined later has not yet been defined, and cannot be resolved at generation time. In those cases, this method is called with the defined id list as it was returned during primary area, room, item, mob, or string generation. The post-processes will be extracted from the defined ids, and then processed on those objects.

Parameters:
defined - the defined ids after they've gone through generating an object
Throws:
CMException - any parsing or generation errors

defineReward

void defineReward(XMLLibrary.XMLTag piece,
                  java.util.Map<java.lang.String,java.lang.Object> defined)
                  throws CMException
If an xml tag is selected manually, by something outside the library, then certain post-selection processes are not properly done, making generation based on the tag potentially impossible. In those cases, before generation of the object from the selected xml tag piece, this method is called to handle post-selection processing (called rewarding, as in a reward for being picked).

Parameters:
piece - the selected xml tag piece
defined - the defined id set from the entire xml document
Throws:
CMException - any parsing or generation errors

preDefineReward

void preDefineReward(XMLLibrary.XMLTag piece,
                     java.util.Map<java.lang.String,java.lang.Object> defined)
                     throws CMException
If an xml tag is selected manually, by something outside the library, then certain pre-selection processes are not properly done, making generation based on the tag potentially impossible. In those cases, before generation of the object from the selected xml tag piece, this method is called to handle pre-selection processing (called rewarding, as in a reward for being picked).

Parameters:
piece - the selected xml tag piece
defined - the defined id set from the entire xml document
Throws:
CMException - any parsing or generation errors

getAllChoices

java.util.List<XMLLibrary.XMLTag> getAllChoices(java.lang.String tagName,
                                                XMLLibrary.XMLTag piece,
                                                java.util.Map<java.lang.String,java.lang.Object> defined)
                                                throws CMException
Given a root xml tag and a tag name, this method will return all matching xml tag pieces.

Parameters:
tagName - the name of the tag to search for
piece - the root xml tag piece
defined - the defined id set from the entire xml document
Returns:
the list of found xml tags that match the tag name
Throws:
CMException - any parsing or generation errors

relevelRoom

boolean relevelRoom(Room room,
                    int oldMin,
                    int oldMax,
                    int newMin,
                    int newMax)
Adjusts the levels of all mobs, items, and mob-items in the room by adjusting them from their place in an existing range to a new range.Does not save -- that's up to you.

Parameters:
room - the room to adjust
oldMin - current minimum level range for the rooms area
oldMax - current maximum level range for the rooms area
newMin - new minimum level range for the rooms area
newMax - new maximum level range for the rooms area
Returns:
true if the room was modified, false otherwise.