com.planet_ink.coffee_mud.Libraries
Class Clans

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

public class Clans
extends StdLibrary
implements ClanManager

Portions Copyright (c) 2003 Jeremy Vyska

Portions Copyright (c) 2004-2011 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,Clan> all
           
 long lastGovernmentLoad
           
 
Constructor Summary
Clans()
           
 
Method Summary
 void addClan(Clan C)
          Adds the given clan to the games list
 boolean authCheck(java.lang.String clanID, int roleID, Clan.Function function)
          If the clan exists, it will check to see if the given role is allowed (or at least not disallowed) from the given clan function
 void clanAnnounce(MOB mob, java.lang.String msg)
          Makes an announcement to the clan announcement channel from the given mob.
 void clanAnnounceAll(java.lang.String msg)
          Sends a message to the games official CLAN chat channel.
 java.util.Enumeration<Clan> clans()
          Returns an enumeration of all the Clans in the game
 java.util.Enumeration<java.lang.String> clansNames()
          Returns a list of all available clans names in the game, as Clan objects.
 ClanGovernment createGovernment(java.lang.String name)
          Creates the new stock government
 ClanGovernment createSampleGovernment()
          Creates, but does not add, a sample government object
 Clan findClan(java.lang.String id)
          Returns the Clan object associated with the given clan name, or if the name is not found, the name that most closely matches it.
 Clan getClan(java.lang.String id)
          Returns the Clan object associated with the given clan name
 int getClanRelations(java.lang.String clanName1, java.lang.String clanName2)
          This method is used to determine the basic relationship between two clans.
 ClanGovernment getDefaultGovernment()
          Returns the default government definition object.
 java.lang.String getGovernmentHelp(MOB mob, java.lang.String named, boolean exact)
          Returns help on the government type named, if it is available
 long getLastGovernmentLoad()
          Get last time governments were loaded/updated
 ClanGovernment getStockGovernment(int typeid)
          Returns a government definition object of the given internal stock clangovernments.xml id.
 ClanGovernment[] getStockGovernments()
          Returns all government definition objects from internal stock clangovernments.xml file.
 boolean goForward(MOB mob, Clan C, java.util.Vector commands, Clan.Function function, boolean voteIfNecessary)
          Examines the given command string, which is based on the given clan function code.
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
protected  java.lang.String indt(int x)
           
 boolean isCommonClanRelations(java.lang.String clanName1, java.lang.String clanName2, int relation)
          This method is used to determine the basic relationship between two clans.
 boolean isFamilyOfMembership(MOB M, java.util.List<Clan.MemberRecord> members)
          Returns whether the given MOB is a member of any of the families represented by the given list of clan members.
 java.lang.String makeGovernmentXML(ClanGovernment gvt)
          Converts a given clan government object into xml.
 java.lang.String makeGovernmentXML(ClanGovernment[] gvts)
          Converts a given clan government objects into xml.
 int numClans()
          Returns the number of clans in the game.
 ClanGovernment[] parseGovernmentXML(java.lang.StringBuffer xml)
          Converts xml into clan government objects.
 void removeClan(Clan C)
          Removes the given clan from the games list
 boolean removeGovernment(ClanGovernment government)
          Deletes the stock government..
 void reSaveGovernmentsXML()
          Forces the stock governments to be re-saved to clangovernments.xml.
 boolean shutdown()
           
 void tickAllClans()
          Forces all clans to go through their maintenance process, which normally only occurs infrequently.
 java.lang.String translatePrize(int trophy)
          Returns a descriptive name for the given trophy code number.
 boolean trophySystemActive()
          Returns whether this mud has activated its trophy system for clans.
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
activate, compareTo, copyOf, getSupportThread, initializeClass, newInstance, propertiesLoaded
 
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, getSupportThread, propertiesLoaded
 
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

all

public SHashtable<java.lang.String,Clan> all

lastGovernmentLoad

public long lastGovernmentLoad
Constructor Detail

Clans

public Clans()
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, MiscTech. 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

shutdown

public boolean shutdown()
Specified by:
shutdown in interface CMLibrary
Overrides:
shutdown in class StdLibrary

isCommonClanRelations

public boolean isCommonClanRelations(java.lang.String clanName1,
                                     java.lang.String clanName2,
                                     int relation)
Description copied from interface: ClanManager
This method is used to determine the basic relationship between two clans. The two clans are evaluated, based on their declared relationship to each other, and the relations they inherit from allys. It is then compared with the passed in relationship constant. If they match, true is returned, and false otherwise.

Specified by:
isCommonClanRelations in interface ClanManager
Parameters:
clanName1 - the first clan to evaluate
clanName2 - the second clan to evaluate
relation - the clan relation to compare to
Returns:
true if the common relationship matches the given relation, and false otherwise
See Also:
Clan.REL_DESCS

getClanRelations

public int getClanRelations(java.lang.String clanName1,
                            java.lang.String clanName2)
Description copied from interface: ClanManager
This method is used to determine the basic relationship between two clans. The two clans are evaluated, based on their declared relationship to each other, and the relations they inherit from allys. This relationship is then returned as a relation constant number.

Specified by:
getClanRelations in interface ClanManager
Parameters:
clanName1 - the first clan to evaluate
clanName2 - the second clan to evaluate
Returns:
the relation code integer
See Also:
Clan.REL_DESCS

getClan

public Clan getClan(java.lang.String id)
Description copied from interface: ClanManager
Returns the Clan object associated with the given clan name

Specified by:
getClan in interface ClanManager
Parameters:
id - the clan name
Returns:
the Clan object associated with the given clan name
See Also:
Clan

findClan

public Clan findClan(java.lang.String id)
Description copied from interface: ClanManager
Returns the Clan object associated with the given clan name, or if the name is not found, the name that most closely matches it.

Specified by:
findClan in interface ClanManager
Returns:
the Clan object associated with the given clan name
See Also:
Clan

isFamilyOfMembership

public boolean isFamilyOfMembership(MOB M,
                                    java.util.List<Clan.MemberRecord> members)
Description copied from interface: ClanManager
Returns whether the given MOB is a member of any of the families represented by the given list of clan members.

Specified by:
isFamilyOfMembership in interface ClanManager
Parameters:
M - the mob to evaluate
members - the members of a clan
Returns:
true if the mob is a family member, and false otherwise

clans

public java.util.Enumeration<Clan> clans()
Description copied from interface: ClanManager
Returns an enumeration of all the Clans in the game

Specified by:
clans in interface ClanManager
Returns:
an enumeration of all the Clans in the game

numClans

public int numClans()
Description copied from interface: ClanManager
Returns the number of clans in the game.

Specified by:
numClans in interface ClanManager
Returns:
the number of clans in the game.

addClan

public void addClan(Clan C)
Description copied from interface: ClanManager
Adds the given clan to the games list

Specified by:
addClan in interface ClanManager
Parameters:
C - the clan to add

removeClan

public void removeClan(Clan C)
Description copied from interface: ClanManager
Removes the given clan from the games list

Specified by:
removeClan in interface ClanManager
Parameters:
C - the clan to remove

tickAllClans

public void tickAllClans()
Description copied from interface: ClanManager
Forces all clans to go through their maintenance process, which normally only occurs infrequently. This does things like handle automatic promotions, manage votes, and clean out inactive clans.

Specified by:
tickAllClans in interface ClanManager

clanAnnounceAll

public void clanAnnounceAll(java.lang.String msg)
Description copied from interface: ClanManager
Sends a message to the games official CLAN chat channel. This is normally for messages that may interest all clans.

Specified by:
clanAnnounceAll in interface ClanManager
Parameters:
msg - the message to send

clansNames

public java.util.Enumeration<java.lang.String> clansNames()
Description copied from interface: ClanManager
Returns a list of all available clans names in the game, as Clan objects.

Specified by:
clansNames in interface ClanManager
Returns:
a list of all available clans names in the game,
See Also:
Clan

translatePrize

public java.lang.String translatePrize(int trophy)
Description copied from interface: ClanManager
Returns a descriptive name for the given trophy code number.

Specified by:
translatePrize in interface ClanManager
Parameters:
trophy - the trophy code number
Returns:
the descriptive name
See Also:
Clan.TROPHY_DESCS

trophySystemActive

public boolean trophySystemActive()
Description copied from interface: ClanManager
Returns whether this mud has activated its trophy system for clans.

Specified by:
trophySystemActive in interface ClanManager
Returns:
whether this mud has activated its trophy system for clans.

goForward

public boolean goForward(MOB mob,
                         Clan C,
                         java.util.Vector commands,
                         Clan.Function function,
                         boolean voteIfNecessary)
Description copied from interface: ClanManager
Examines the given command string, which is based on the given clan function code. If the given Clan requires a vote to accomplish it, the vote will be created. If the given clan forbids the given mob from performing the given function, or from even starting a vote on it, the method will return false. If the mob is allowed to perform

Specified by:
goForward in interface ClanManager
Parameters:
mob - the player who wants to perform the function
C - the clan that the player belongs to
commands - the command list describing the function that wants to be executed
function - the function code described by the commands list
voteIfNecessary - true to start a vote if one is needed, false to just return true.
Returns:
true to execute the given command, and false not to.
See Also:
Clan.Function.ACCEPT

indt

protected java.lang.String indt(int x)

getLastGovernmentLoad

public long getLastGovernmentLoad()
Description copied from interface: ClanManager
Get last time governments were loaded/updated

Specified by:
getLastGovernmentLoad in interface ClanManager
Returns:
time in ms

getGovernmentHelp

public java.lang.String getGovernmentHelp(MOB mob,
                                          java.lang.String named,
                                          boolean exact)
Description copied from interface: ClanManager
Returns help on the government type named, if it is available

Specified by:
getGovernmentHelp in interface ClanManager
Parameters:
mob - the viewer of the government type
named - the possible name of the government
exact - true to only match exact, or false otherwise
Returns:
null, or the help for the government named

createSampleGovernment

public ClanGovernment createSampleGovernment()
Description copied from interface: ClanManager
Creates, but does not add, a sample government object

Specified by:
createSampleGovernment in interface ClanManager
Returns:
a sample government object

reSaveGovernmentsXML

public void reSaveGovernmentsXML()
Description copied from interface: ClanManager
Forces the stock governments to be re-saved to clangovernments.xml.

Specified by:
reSaveGovernmentsXML in interface ClanManager

createGovernment

public ClanGovernment createGovernment(java.lang.String name)
Description copied from interface: ClanManager
Creates the new stock government

Specified by:
createGovernment in interface ClanManager
Parameters:
name - governmentname
Returns:
new stock government

removeGovernment

public boolean removeGovernment(ClanGovernment government)
Description copied from interface: ClanManager
Deletes the stock government.. confusing all the clans that currently use it.

Specified by:
removeGovernment in interface ClanManager
Parameters:
government - the government to delete

getStockGovernments

public ClanGovernment[] getStockGovernments()
Description copied from interface: ClanManager
Returns all government definition objects from internal stock clangovernments.xml file. See /resources/clangovernments.xml Also:

Specified by:
getStockGovernments in interface ClanManager
Returns:
the clan government object
See Also:
ClanGovernment

getDefaultGovernment

public ClanGovernment getDefaultGovernment()
Description copied from interface: ClanManager
Returns the default government definition object. See /resources/clangovernments.xml Also:

Specified by:
getDefaultGovernment in interface ClanManager
Returns:
the clan government object
See Also:
ClanGovernment

getStockGovernment

public ClanGovernment getStockGovernment(int typeid)
Description copied from interface: ClanManager
Returns a government definition object of the given internal stock clangovernments.xml id. See /resources/clangovernments.xml Also:

Specified by:
getStockGovernment in interface ClanManager
Parameters:
typeid - the internal typeid
Returns:
the clan government object
See Also:
ClanGovernment

makeGovernmentXML

public java.lang.String makeGovernmentXML(ClanGovernment gvt)
Description copied from interface: ClanManager
Converts a given clan government object into xml.

Specified by:
makeGovernmentXML in interface ClanManager
Parameters:
gvt - the clan government object
Returns:
the xml
See Also:
ClanGovernment, ClanManager.makeGovernmentXML(com.planet_ink.coffee_mud.Common.interfaces.ClanGovernment[]), ClanManager.parseGovernmentXML(StringBuffer)

makeGovernmentXML

public java.lang.String makeGovernmentXML(ClanGovernment[] gvts)
Description copied from interface: ClanManager
Converts a given clan government objects into xml.

Specified by:
makeGovernmentXML in interface ClanManager
Parameters:
gvts - the clan government objects
Returns:
the xml
See Also:
ClanGovernment, ClanManager.makeGovernmentXML(com.planet_ink.coffee_mud.Common.interfaces.ClanGovernment), ClanManager.parseGovernmentXML(StringBuffer)

parseGovernmentXML

public ClanGovernment[] parseGovernmentXML(java.lang.StringBuffer xml)
Description copied from interface: ClanManager
Converts xml into clan government objects.

Specified by:
parseGovernmentXML in interface ClanManager
Parameters:
xml - the xml
Returns:
the clan government objects
See Also:
ClanGovernment, ClanManager.makeGovernmentXML(com.planet_ink.coffee_mud.Common.interfaces.ClanGovernment), ClanManager.makeGovernmentXML(com.planet_ink.coffee_mud.Common.interfaces.ClanGovernment[])

clanAnnounce

public void clanAnnounce(MOB mob,
                         java.lang.String msg)
Description copied from interface: ClanManager
Makes an announcement to the clan announcement channel from the given mob. These are channels marked in the coffeemud.ini file as receiving clan info messages. These messages are only seen by the authors clan members.

Specified by:
clanAnnounce in interface ClanManager
Parameters:
mob - the mob who is announcing the message
msg - string message to send to the clan info channels

authCheck

public boolean authCheck(java.lang.String clanID,
                         int roleID,
                         Clan.Function function)
Description copied from interface: ClanManager
If the clan exists, it will check to see if the given role is allowed (or at least not disallowed) from the given clan function

Specified by:
authCheck in interface ClanManager
Parameters:
clanID - the clan name
roleID - the clan roleID
function - the clan function
Returns:
true if they aren't disallowed, false otherwise
See Also:
Clan