com.planet_ink.coffee_mud.Libraries
Class Factions

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

public class Factions
extends StdLibrary
implements FactionManager

Portions Copyright (c) 2003 Jeremy Vyska Portions Copyright (c) 2004-2018 Bo Zimmerman Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Field Summary
 SHashtable<java.lang.String,Faction> factionSet
           
 SHashtable<java.lang.String,Faction.FRange> hashedFactionRanges
           
 
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
Factions()
           
 
Method Summary
 boolean addFaction(Faction F)
           
protected  void addOutsidersAndTimers(Faction F, java.util.Vector<Faction.FactionChangeEvent> outSiders, java.util.Vector<Faction.FactionChangeEvent> timers)
           
 java.lang.String AlignID()
           
 void clearFactions()
           
 java.util.Enumeration<Faction> factions()
           
 int getAbilityFlagType(java.lang.String strflag)
           
 Faction.Align getAlignEnum(java.lang.String str)
           
 int getAlignMedianFacValue(Faction.Align eq)
           
 int getAlignPurity(int faction, Faction.Align eq)
           
 Faction getFaction(java.lang.String factionID)
           
 Faction getFactionByName(java.lang.String factionNamed)
           
 Faction getFactionByNumber(int index)
           
 Faction getFactionByRangeCodeName(java.lang.String rangeCodeName)
           
 Faction.FRange getFactionRangeByCodeName(java.lang.String rangeCodeName)
           
 int getMaximum(java.lang.String factionID)
           
 int getMinimum(java.lang.String factionID)
           
 java.lang.String getName(java.lang.String factionID)
           
 int getPercent(java.lang.String factionID, int faction)
           
 int getPercentFromAvg(java.lang.String factionID, int faction)
           
 int getRandom(java.lang.String factionID)
           
 Faction.FRange getRange(java.lang.String factionID, int faction)
           
 double getRangePercent(java.lang.String factionID, int faction)
           
 java.util.Enumeration<Faction.FRange> getRanges(java.lang.String factionID)
           
 Faction[] getSpecialFactions(MOB mob, Room R)
           
 int getTickStatus()
          A coded status for this object during the period where its tick method is being called.
 int getTotal(java.lang.String factionID)
           
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 boolean isFactionedThisWay(MOB mob, Faction.FRange rangeCode)
           
 int isFactionTag(java.lang.String tag)
           
 boolean isRangeCodeName(java.lang.String key)
           
 java.lang.String listFactions()
           
 java.lang.String makeFactionFilename(java.lang.String factionID)
           
protected  Faction makeReactionFaction(java.lang.String prefix, java.lang.String classID, java.lang.String Name, java.lang.String code, java.lang.String baseTemplateFilename)
           
 void modifyFaction(MOB mob, Faction me)
           
 java.lang.String name()
          The displayable name of this object.
 int numFactions()
           
 boolean postChangeAllFactions(MOB mob, MOB victim, int amount, boolean quiet)
           
 boolean postFactionChange(MOB mob, Environmental tool, java.lang.String factionID, int amount)
           
 java.util.Map<java.lang.String,Faction.FRange> rangeCodeNames()
           
 java.lang.String rangeDescription(Faction.FRange FR, java.lang.String andOr)
           
 void reloadFactions(java.lang.String factionList)
           
 boolean removeFaction(java.lang.String factionID)
           
 java.lang.String resaveFaction(Faction F)
           
 void setAlignment(MOB mob, Faction.Align newAlignment)
           
 void setAlignmentOldRange(MOB mob, int oldRange)
           
 boolean tick(Tickable ticking, int tickID)
          this is the method which is called periodically by the threading engine.
 void updatePlayerFactions(MOB mob, Room R, boolean forceAutoCheck)
           
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
activate, checkDatabase, compareTo, copyOf, getServiceClient, initializeClass, L, newInstance, propertiesLoaded, setThreadStatus, shutdown
 
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
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

factionSet

public SHashtable<java.lang.String,Faction> factionSet

hashedFactionRanges

public SHashtable<java.lang.String,Faction.FRange> hashedFactionRanges
Constructor Detail

Factions

public Factions()
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

factions

public java.util.Enumeration<Faction> factions()
Specified by:
factions in interface FactionManager

numFactions

public int numFactions()
Specified by:
numFactions in interface FactionManager

clearFactions

public void clearFactions()
Specified by:
clearFactions in interface FactionManager

getFactionByNumber

public Faction getFactionByNumber(int index)
Specified by:
getFactionByNumber in interface FactionManager

reloadFactions

public void reloadFactions(java.lang.String factionList)
Specified by:
reloadFactions in interface FactionManager

rangeCodeNames

public java.util.Map<java.lang.String,Faction.FRange> rangeCodeNames()

isRangeCodeName

public boolean isRangeCodeName(java.lang.String key)
Specified by:
isRangeCodeName in interface FactionManager

getFactionRangeByCodeName

public Faction.FRange getFactionRangeByCodeName(java.lang.String rangeCodeName)
Specified by:
getFactionRangeByCodeName in interface FactionManager

isFactionedThisWay

public boolean isFactionedThisWay(MOB mob,
                                  Faction.FRange rangeCode)
Specified by:
isFactionedThisWay in interface FactionManager

rangeDescription

public java.lang.String rangeDescription(Faction.FRange FR,
                                         java.lang.String andOr)
Specified by:
rangeDescription in interface FactionManager

addFaction

public boolean addFaction(Faction F)
Specified by:
addFaction in interface FactionManager

makeFactionFilename

public java.lang.String makeFactionFilename(java.lang.String factionID)
Specified by:
makeFactionFilename in interface FactionManager

getFaction

public Faction getFaction(java.lang.String factionID)
Specified by:
getFaction in interface FactionManager

getFactionByRangeCodeName

public Faction getFactionByRangeCodeName(java.lang.String rangeCodeName)
Specified by:
getFactionByRangeCodeName in interface FactionManager

getFactionByName

public Faction getFactionByName(java.lang.String factionNamed)
Specified by:
getFactionByName in interface FactionManager

removeFaction

public boolean removeFaction(java.lang.String factionID)
Specified by:
removeFaction in interface FactionManager

listFactions

public java.lang.String listFactions()
Specified by:
listFactions in interface FactionManager

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
Specified by:
name in interface Tickable
Overrides:
name in class StdLibrary
Returns:
the modified final name of this object on the map.
See Also:
Environmental.Name()

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
Overrides:
getTickStatus in class StdLibrary
Returns:
the numeric status of this object
See Also:
Tickable.tick(Tickable, int)

getName

public java.lang.String getName(java.lang.String factionID)
Specified by:
getName in interface FactionManager

getMinimum

public int getMinimum(java.lang.String factionID)
Specified by:
getMinimum in interface FactionManager

getMaximum

public int getMaximum(java.lang.String factionID)
Specified by:
getMaximum in interface FactionManager

getPercent

public int getPercent(java.lang.String factionID,
                      int faction)
Specified by:
getPercent in interface FactionManager

getPercentFromAvg

public int getPercentFromAvg(java.lang.String factionID,
                             int faction)
Specified by:
getPercentFromAvg in interface FactionManager

getRange

public Faction.FRange getRange(java.lang.String factionID,
                               int faction)
Specified by:
getRange in interface FactionManager

getRanges

public java.util.Enumeration<Faction.FRange> getRanges(java.lang.String factionID)
Specified by:
getRanges in interface FactionManager

getRangePercent

public double getRangePercent(java.lang.String factionID,
                              int faction)
Specified by:
getRangePercent in interface FactionManager

getTotal

public int getTotal(java.lang.String factionID)
Specified by:
getTotal in interface FactionManager

getRandom

public int getRandom(java.lang.String factionID)
Specified by:
getRandom in interface FactionManager

AlignID

public java.lang.String AlignID()
Specified by:
AlignID in interface FactionManager

setAlignment

public void setAlignment(MOB mob,
                         Faction.Align newAlignment)
Specified by:
setAlignment in interface FactionManager

setAlignmentOldRange

public void setAlignmentOldRange(MOB mob,
                                 int oldRange)
Specified by:
setAlignmentOldRange in interface FactionManager

postChangeAllFactions

public boolean postChangeAllFactions(MOB mob,
                                     MOB victim,
                                     int amount,
                                     boolean quiet)
Specified by:
postChangeAllFactions in interface FactionManager

postFactionChange

public boolean postFactionChange(MOB mob,
                                 Environmental tool,
                                 java.lang.String factionID,
                                 int amount)
Specified by:
postFactionChange in interface FactionManager

makeReactionFaction

protected Faction makeReactionFaction(java.lang.String prefix,
                                      java.lang.String classID,
                                      java.lang.String Name,
                                      java.lang.String code,
                                      java.lang.String baseTemplateFilename)

getSpecialFactions

public Faction[] getSpecialFactions(MOB mob,
                                    Room R)

updatePlayerFactions

public void updatePlayerFactions(MOB mob,
                                 Room R,
                                 boolean forceAutoCheck)
Specified by:
updatePlayerFactions in interface FactionManager

addOutsidersAndTimers

protected void addOutsidersAndTimers(Faction F,
                                     java.util.Vector<Faction.FactionChangeEvent> outSiders,
                                     java.util.Vector<Faction.FactionChangeEvent> timers)

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

getAlignPurity

public int getAlignPurity(int faction,
                          Faction.Align eq)
Specified by:
getAlignPurity in interface FactionManager

getAlignMedianFacValue

public int getAlignMedianFacValue(Faction.Align eq)
Specified by:
getAlignMedianFacValue in interface FactionManager

isFactionTag

public int isFactionTag(java.lang.String tag)
Specified by:
isFactionTag in interface FactionManager

getAlignEnum

public Faction.Align getAlignEnum(java.lang.String str)
Specified by:
getAlignEnum in interface FactionManager

modifyFaction

public void modifyFaction(MOB mob,
                          Faction me)
                   throws java.io.IOException
Specified by:
modifyFaction in interface FactionManager
Throws:
java.io.IOException

resaveFaction

public java.lang.String resaveFaction(Faction F)
Specified by:
resaveFaction in interface FactionManager

getAbilityFlagType

public int getAbilityFlagType(java.lang.String strflag)
Specified by:
getAbilityFlagType in interface FactionManager