com.planet_ink.coffee_mud.Libraries
Class GroundWired

java.lang.Object
  extended by com.planet_ink.coffee_mud.Libraries.StdLibrary
      extended by com.planet_ink.coffee_mud.Libraries.GroundWired
All Implemented Interfaces:
CMObject, Tickable, CMLibrary, TechLibrary, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class GroundWired
extends StdLibrary
implements TechLibrary


Field Summary
protected static Converter<java.lang.ref.WeakReference<Electronics>,Computer> computerConverter
           
protected static Filterer<java.lang.ref.WeakReference<Electronics>> computerFilterer
           
protected static Converter<Computer,Room> computerRoomConverter
           
protected  java.util.Map<PowerGenerator,Pair<java.util.List<PowerSource>,java.util.List<Electronics>>> currents
           
protected  Manufacturer defaultManufacturer
           
protected static java.util.Iterator<Computer> emptyComputerIterator
           
protected static java.util.Iterator<Room> emptyComputerRoomIterator
           
protected static java.util.List<PowerGenerator> emptyGeneratorList
           
 int globalTechLevel
           
 long globalTechReachedOn
           
protected  java.util.Map<java.lang.String,Manufacturer> manufacturers
           
protected  java.util.concurrent.atomic.AtomicInteger nextKey
           
protected  CMMsg powerMsg
           
protected  java.util.Map<java.lang.String,java.util.LinkedList<java.lang.ref.WeakReference<Electronics>>> sets
           
 
Fields inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
isDebugging, name, serviceClient, tickStatus
 
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
GroundWired()
           
 
Method Summary
 boolean activate()
          Activates the library.
 void addManufacturer(Manufacturer manufacturer)
          Adds and saves a new manufacturer to the list.
protected  void bumpTechLevel()
           
 void delManufacturer(Manufacturer manufacturer)
          Removes a new manufacturer from the list.
protected  Area fillCurrentLists(java.lang.String key, java.util.List<PowerGenerator> generators, java.util.List<PowerSource> batteries, java.util.List<ElecPanel> panels)
           
 void fixItemTechLevel(Electronics I, int newTechLevel)
          "Fixes" the tech level of the given item by making sure it's manufacturer is non-random, and by assigning a random tech level within the valid range, and modifying its name and displaytext to reflect the new tech level
 java.util.Iterator<Room> getComputerRooms(java.lang.String key)
          Return all the rooms containing computers in the given circuit key.
 java.util.Iterator<Computer> getComputers(java.lang.String key)
          Return all the computers in the given circuit key.
 Manufacturer getDefaultManufacturer()
          Retrieves the default manufacturer for new products
 java.lang.String getElectronicsKey(CMObject o)
          Returns the appropriate electronics key for this electronic item, area, or room.
 int getGlobalTechLevel()
          Returns the global tech level
 double getGravityForce(SpaceObject S, SpaceObject cO)
          If the two given objects are within an appropriate distance from each other, this will return the correct amount of acceleration g-force applied by the second object to the first.
 java.util.List<Electronics> getMakeRegisteredElectronics(java.lang.String key)
          For the given key, return an eclusive list of all the electronics that belong to that key.
 java.util.List<java.lang.String> getMakeRegisteredKeys()
          Returns a new exclusive list of all the registered electronics keys being processed.
 Manufacturer getManufacturer(java.lang.String name)
          Retrieves the manufacturer of the given name, or null if it is not found.
 Manufacturer getManufacturerOf(Electronics E, java.lang.String name)
          Retrieves the manufacturer of the given name, or null if it is not found.
protected  java.lang.String getManufacturersFilename()
           
protected  CMMsg getPowerMsg(int powerAmt)
           
 int getRandomGlobalTechLevel()
          Returns a random gaussian-distributed tech level from the current low tech level bound to bound+10.
 TickClient getServiceClient()
          If this library has a service thread, this method returns the TickClient object associated with that service.
 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 isCurrentActive(java.lang.String key)
          Returns whether the currents at the given key are still active.
protected  void loadAllManufacturers()
           
 java.util.Iterator<Manufacturer> manufacterers()
          Returns an iterator of manufacturers
protected  void processElectricCurrents(java.lang.String key, java.util.List<PowerGenerator> generators, java.util.List<PowerSource> batteries, java.util.List<ElecPanel> panels)
           
 java.lang.String registerElectrics(Electronics E, java.lang.String oldKey)
          Registers an electronic component that belongs in a complex circuitry, like a panel or a generator
protected  void runElectricCurrent(java.lang.String key)
           
protected  void runElectricCurrents()
           
 void runSpace()
           
protected  void saveAllManufacturers()
           
 boolean seekBatteryPower(ElecPanel E, java.lang.String key)
          Certain Key Systems may automatically force batteries in their circuit to activate in order to provide that system with power.
 boolean shutdown()
          Shuts down the library.
 boolean tick(Tickable ticking, int tickID)
          this is the method which is called periodically by the threading engine.
 void unregisterAllElectronics(java.lang.String oldKey)
          Unregisters all electronic components that belonged in a complex circuitry, like a panel or a generator, of the given key.
 void unregisterElectronics(Electronics E, java.lang.String oldKey)
          Unregisters an electronic component that belonged in a complex circuitry, like a panel or a generator.
 void updateManufacturer(Manufacturer manufacturer)
          Updates a new manufacturer in the list.
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
checkDatabase, compareTo, copyOf, getTickStatus, L, name, newInstance, propertiesLoaded, setThreadStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
L, propertiesLoaded
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

defaultManufacturer

protected Manufacturer defaultManufacturer

manufacturers

protected final java.util.Map<java.lang.String,Manufacturer> manufacturers

sets

protected final java.util.Map<java.lang.String,java.util.LinkedList<java.lang.ref.WeakReference<Electronics>>> sets

currents

protected final java.util.Map<PowerGenerator,Pair<java.util.List<PowerSource>,java.util.List<Electronics>>> currents

emptyGeneratorList

protected static final java.util.List<PowerGenerator> emptyGeneratorList

nextKey

protected final java.util.concurrent.atomic.AtomicInteger nextKey

globalTechLevel

public int globalTechLevel

globalTechReachedOn

public long globalTechReachedOn

powerMsg

protected CMMsg powerMsg

emptyComputerIterator

protected static final java.util.Iterator<Computer> emptyComputerIterator

emptyComputerRoomIterator

protected static final java.util.Iterator<Room> emptyComputerRoomIterator

computerFilterer

protected static final Filterer<java.lang.ref.WeakReference<Electronics>> computerFilterer

computerConverter

protected static final Converter<java.lang.ref.WeakReference<Electronics>,Computer> computerConverter

computerRoomConverter

protected static final Converter<Computer,Room> computerRoomConverter
Constructor Detail

GroundWired

public GroundWired()
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
Overrides:
ID in class StdLibrary
Returns:
the name of this class

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
Overrides:
initializeClass in class StdLibrary

getGlobalTechLevel

public int getGlobalTechLevel()
Description copied from interface: TechLibrary
Returns the global tech level

Specified by:
getGlobalTechLevel in interface TechLibrary
Returns:
the global tech level

getRandomGlobalTechLevel

public int getRandomGlobalTechLevel()
Description copied from interface: TechLibrary
Returns a random gaussian-distributed tech level from the current low tech level bound to bound+10.

Specified by:
getRandomGlobalTechLevel in interface TechLibrary
Returns:
a random valid tech level;

bumpTechLevel

protected void bumpTechLevel()

fixItemTechLevel

public void fixItemTechLevel(Electronics I,
                             int newTechLevel)
Description copied from interface: TechLibrary
"Fixes" the tech level of the given item by making sure it's manufacturer is non-random, and by assigning a random tech level within the valid range, and modifying its name and displaytext to reflect the new tech level

Specified by:
fixItemTechLevel in interface TechLibrary
Parameters:
I - An electronics item that needs fixing
newTechLevel - the new tech level

getElectronicsKey

public java.lang.String getElectronicsKey(CMObject o)
Description copied from interface: TechLibrary
Returns the appropriate electronics key for this electronic item, area, or room. It represents the electronical currents that tie technology together.

Specified by:
getElectronicsKey in interface TechLibrary
Parameters:
o - the object to inspect
Returns:
the key to use, or null if none can be found

registerElectrics

public java.lang.String registerElectrics(Electronics E,
                                          java.lang.String oldKey)
Description copied from interface: TechLibrary
Registers an electronic component that belongs in a complex circuitry, like a panel or a generator

Specified by:
registerElectrics in interface TechLibrary
Parameters:
E - the electronic component to register
oldKey - the last key registered to this device
Returns:
the new key assigned to this item (or old key)

getMakeRegisteredElectronics

public java.util.List<Electronics> getMakeRegisteredElectronics(java.lang.String key)
Description copied from interface: TechLibrary
For the given key, return an eclusive list of all the electronics that belong to that key.

Specified by:
getMakeRegisteredElectronics in interface TechLibrary
Parameters:
key - the key to return electronics for
Returns:
the list of electronic object of that key

getMakeRegisteredKeys

public java.util.List<java.lang.String> getMakeRegisteredKeys()
Description copied from interface: TechLibrary
Returns a new exclusive list of all the registered electronics keys being processed.

Specified by:
getMakeRegisteredKeys in interface TechLibrary
Returns:
the list of keys

unregisterElectronics

public void unregisterElectronics(Electronics E,
                                  java.lang.String oldKey)
Description copied from interface: TechLibrary
Unregisters an electronic component that belonged in a complex circuitry, like a panel or a generator.

Specified by:
unregisterElectronics in interface TechLibrary
Parameters:
E - the electronic component to unregister
oldKey - the last key registered to this device

unregisterAllElectronics

public void unregisterAllElectronics(java.lang.String oldKey)
Description copied from interface: TechLibrary
Unregisters all electronic components that belonged in a complex circuitry, like a panel or a generator, of the given key.

Specified by:
unregisterAllElectronics in interface TechLibrary
Parameters:
oldKey - the last key registered to this device

getServiceClient

public TickClient getServiceClient()
Description copied from interface: CMLibrary
If this library has a service thread, this method returns the TickClient object associated with that service. Normally returns null, since most libraries don't set themselves up to receive thread time.

Specified by:
getServiceClient in interface CMLibrary
Overrides:
getServiceClient in class StdLibrary
Returns:
null, or the TickClient for the service
See Also:
TickClient

getComputers

public java.util.Iterator<Computer> getComputers(java.lang.String key)
Description copied from interface: TechLibrary
Return all the computers in the given circuit key.

Specified by:
getComputers in interface TechLibrary
Parameters:
key - the circuit key
Returns:
an iterator of computers

getComputerRooms

public java.util.Iterator<Room> getComputerRooms(java.lang.String key)
Description copied from interface: TechLibrary
Return all the rooms containing computers in the given circuit key.

Specified by:
getComputerRooms in interface TechLibrary
Parameters:
key - the circuit key
Returns:
an iterator of rooms

getPowerMsg

protected CMMsg getPowerMsg(int powerAmt)

activate

public boolean activate()
Description copied from interface: CMLibrary
Activates the library. This is called after the mud is booted, but before connections are accepted.

Specified by:
activate in interface CMLibrary
Overrides:
activate in class StdLibrary
Returns:
true if activation was successful, false if you're screwed
See Also:
CMLibrary.shutdown()

getGravityForce

public double getGravityForce(SpaceObject S,
                              SpaceObject cO)
Description copied from interface: TechLibrary
If the two given objects are within an appropriate distance from each other, this will return the correct amount of acceleration g-force applied by the second object to the first. typically <= 1G

Specified by:
getGravityForce in interface TechLibrary
Parameters:
S - the object being pulled
cO - the object pulling
Returns:
the amount of gravity force, or 0

runSpace

public void runSpace()

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
Overrides:
tick in class StdLibrary
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

shutdown

public boolean shutdown()
Description copied from interface: CMLibrary
Shuts down the library. Called at system shutdown time obviously, but is sometimes called just to reset the library.

Specified by:
shutdown in interface CMLibrary
Overrides:
shutdown in class StdLibrary
Returns:
true if shutdown was successful, false if there's nothing you can do about it
See Also:
CMLibrary.activate()

processElectricCurrents

protected void processElectricCurrents(java.lang.String key,
                                       java.util.List<PowerGenerator> generators,
                                       java.util.List<PowerSource> batteries,
                                       java.util.List<ElecPanel> panels)
                                throws java.lang.Exception
Throws:
java.lang.Exception

fillCurrentLists

protected Area fillCurrentLists(java.lang.String key,
                                java.util.List<PowerGenerator> generators,
                                java.util.List<PowerSource> batteries,
                                java.util.List<ElecPanel> panels)

isCurrentActive

public boolean isCurrentActive(java.lang.String key)
Description copied from interface: TechLibrary
Returns whether the currents at the given key are still active. Some currents go inactive when players leave the game, or their areas may be suspended by the system.

Specified by:
isCurrentActive in interface TechLibrary
Parameters:
key - the current key
Returns:
true if the area is active

runElectricCurrent

protected void runElectricCurrent(java.lang.String key)

seekBatteryPower

public boolean seekBatteryPower(ElecPanel E,
                                java.lang.String key)
Description copied from interface: TechLibrary
Certain Key Systems may automatically force batteries in their circuit to activate in order to provide that system with power. This will make that attempt.

Specified by:
seekBatteryPower in interface TechLibrary
Parameters:
E - the key device to seek power
key - this devices key
Returns:
true if an attempt to give power was made, false otherwise.

runElectricCurrents

protected void runElectricCurrents()

getDefaultManufacturer

public Manufacturer getDefaultManufacturer()
Description copied from interface: TechLibrary
Retrieves the default manufacturer for new products

Specified by:
getDefaultManufacturer in interface TechLibrary
Returns:
the default manufacturer for new products

addManufacturer

public void addManufacturer(Manufacturer manufacturer)
Description copied from interface: TechLibrary
Adds and saves a new manufacturer to the list.

Specified by:
addManufacturer in interface TechLibrary
Parameters:
manufacturer - the one to add

delManufacturer

public void delManufacturer(Manufacturer manufacturer)
Description copied from interface: TechLibrary
Removes a new manufacturer from the list.

Specified by:
delManufacturer in interface TechLibrary
Parameters:
manufacturer - the one to remove

updateManufacturer

public void updateManufacturer(Manufacturer manufacturer)
Description copied from interface: TechLibrary
Updates a new manufacturer in the list.

Specified by:
updateManufacturer in interface TechLibrary
Parameters:
manufacturer - the one to update

getManufacturer

public Manufacturer getManufacturer(java.lang.String name)
Description copied from interface: TechLibrary
Retrieves the manufacturer of the given name, or null if it is not found. Can not handle RANDOM!!

Specified by:
getManufacturer in interface TechLibrary
Parameters:
name - the manufacturer to fetch
Returns:
the manufacturer found, or null

getManufacturerOf

public Manufacturer getManufacturerOf(Electronics E,
                                      java.lang.String name)
Description copied from interface: TechLibrary
Retrieves the manufacturer of the given name, or null if it is not found. If random is sent, it will find a random manufacturer for the given item.

Specified by:
getManufacturerOf in interface TechLibrary
Parameters:
E - for random manufacturers, the item to check
name - the manufacturer to fetch
Returns:
the manufacturer found, or null

manufacterers

public java.util.Iterator<Manufacturer> manufacterers()
Description copied from interface: TechLibrary
Returns an iterator of manufacturers

Specified by:
manufacterers in interface TechLibrary
Returns:
the set to return

getManufacturersFilename

protected java.lang.String getManufacturersFilename()

saveAllManufacturers

protected void saveAllManufacturers()

loadAllManufacturers

protected void loadAllManufacturers()