com.planet_ink.coffee_mud.Libraries
Class Achievements

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

public class Achievements
extends StdLibrary
implements AchievementLibrary


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.AchievementLibrary
AchievementLibrary.AbilityAward, AchievementLibrary.Achievement, AchievementLibrary.AchievementLoadFlag, AchievementLibrary.AmountAward, AchievementLibrary.Award, AchievementLibrary.AwardType, AchievementLibrary.CurrencyAward, AchievementLibrary.Event, AchievementLibrary.ExpertiseAward, AchievementLibrary.StatAward, AchievementLibrary.TitleAward, AchievementLibrary.Tracker
 
Field Summary
 
Fields inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
isDebugging, name, serviceClient, tickStatus
 
Fields inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.AchievementLibrary
BASE_ACHIEVEMENT_PARAMETERS
 
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
Achievements()
           
 
Method Summary
 java.util.Enumeration<AchievementLibrary.Achievement> achievements(AccountStats.Agent agent)
          Allows iterating through all the achievements of the given agent group.
 boolean addModifyAchievement(MOB mob, AccountStats.Agent agent, java.lang.String tattoo, AchievementLibrary.Achievement A)
          Allows a new achievement to be added or removed, with a user interface editor presented for the given mob.
 java.lang.String buildRow(AchievementLibrary.Event E, java.util.Map<java.lang.String,java.lang.String> parmTree)
           
 AchievementLibrary.Achievement deleteAchievement(java.lang.String tattoo)
          Finds and deleted the achievement with teh given tattoo key.
 java.lang.String evaluateAchievement(AccountStats.Agent agent, java.lang.String row, boolean addIfPossible)
          This method is how an achievement definition row is evaluated and added to the permanent list of achievements.
 boolean evaluateAchievements(MOB mob)
          Iterates through all the achievements to see if the given mob has completed any new ones, granting them and the awards if they have.
protected  java.util.List<AchievementLibrary.Achievement> fakeBumpAccountAchievement(MOB mob, AchievementLibrary.Achievement A, PlayerAccount account, AchievementLibrary.Event E, int bumpNum, java.lang.Object... parms)
           
 java.util.List<AchievementLibrary.Achievement> fakeBumpAchievement(MOB mob, AchievementLibrary.Event E, int bumpNum, java.lang.Object... parms)
          When an event occurs that might possible cause a player to have one of their achievements bumped, this method is called with event specific parameters which might possibly cause the achievement to be bumped in the tracker, which might cause it to be completed as well.
protected  java.util.List<AchievementLibrary.Achievement> fakeBumpPlayerAchievement(MOB mob, AchievementLibrary.Achievement A, PlayerStats pStats, AchievementLibrary.Event E, int bumpNum, java.lang.Object... parms)
           
 AchievementLibrary.Achievement getAchievement(java.lang.String tattoo)
          Returns the achievement with the given tattoo key.
 java.lang.String getAchievementsHelp(java.lang.String ID, boolean exact)
          Searches for an Achievement of the given tattoo name or display name, and returns a help entry for the achievement.
 java.lang.String getAchievementsHelpFromMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> helpMap, AchievementLibrary.Event E, java.lang.String parmName)
          Given the comments/help entried from the achievement definition file, and an event, and the name of the parameter inside the event, this returns the help entry for that parameter
 java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getAchievementsHelpMap()
          Returns all the comment/help entries from the achievement definition file The map is of the form event ID, then parameter->help map.
 java.lang.String getAwardString(AchievementLibrary.Award[] awards)
          Converts a parsed awards list back into an unparsed parameter/value string.
protected  boolean giveAwards(AchievementLibrary.Achievement A, Tattooable holder, MOB mob, AchievementLibrary.AchievementLoadFlag flag)
           
protected  void giveAwards(MOB mob, AchievementLibrary.Award[] awardSet, AchievementLibrary.AchievementLoadFlag flag)
           
 void grantAbilitiesAndExpertises(MOB mob)
          Typically called when a mob gains a level, to allow the achievements on the mob to assign any new skills or expertises.
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void loadAccountAchievements(MOB mob, AchievementLibrary.AchievementLoadFlag flag)
          When a new player is created, this method inspects their account tattoos for any that need to be passed down to this new player.
 void loadPlayerSkillAwards(Tattooable mob, PlayerStats stats)
          When a player is loaded, this method inspects their tattoos for any past achievements and, if found, loads the playerstats with trackable skill and expertises mappings, allowing them to receive those awards when the time is right.
protected  java.lang.String makeAchievmentHelp(AchievementLibrary.Achievement A)
           
protected  void possiblyBumpAccountAchievement(MOB mob, AchievementLibrary.Achievement A, PlayerAccount account, AchievementLibrary.Event E, int bumpNum, java.lang.Object... parms)
           
 void possiblyBumpAchievement(MOB mob, AchievementLibrary.Event E, int bumpNum, java.lang.Object... parms)
          When an event occurs that might possible cause a player to have one of their achievements bumped, this method is called with event specific parameters which might possibly cause the achievement to be bumped in the tracker, which might cause it to be completed as well.
protected  void possiblyBumpPlayerAchievement(MOB mob, AchievementLibrary.Achievement A, PlayerStats pStats, AchievementLibrary.Event E, int bumpNum, java.lang.Object... parms)
           
 void reloadAchievements()
          Forces all achievements to be reloaded from the definition file.
 void reloadPlayerAwards(MOB mob, AchievementLibrary.AchievementLoadFlag flag)
          When a player remorts, they keep their player achievements, but the rewards are removed.
 java.lang.String removeAwards(MOB mob, AchievementLibrary.Award[] awardSet, AchievementLibrary.AchievementLoadFlag flag)
          When a player remorts, they lost their account achievement awards, which are restored later.
 void resaveAchievements(java.lang.String modifyTattoo)
          Forces any changed or deleted achievements to re-saved to the definition file.
 boolean shutdown()
          Shuts down the library.
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
activate, checkDatabase, compareTo, copyOf, getServiceClient, getTickStatus, initializeClass, L, name, newInstance, propertiesLoaded, setThreadStatus, tick
 
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
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

Achievements

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

evaluateAchievement

public java.lang.String evaluateAchievement(AccountStats.Agent agent,
                                            java.lang.String row,
                                            boolean addIfPossible)
Description copied from interface: AchievementLibrary
This method is how an achievement definition row is evaluated and added to the permanent list of achievements. It accepts the coded row with key=value pairs for all the achievement arguments. If all is well, "" is returned, otherwise an error message is returned.

Specified by:
evaluateAchievement in interface AchievementLibrary
Parameters:
agent - whether this is a player or account
row - the coded key=value pairs row.
addIfPossible - true if, on success, the new achievment is added, false otherwise
Returns:
the error message, or "" for success

achievements

public java.util.Enumeration<AchievementLibrary.Achievement> achievements(AccountStats.Agent agent)
Description copied from interface: AchievementLibrary
Allows iterating through all the achievements of the given agent group. If the agent is null, then ALL achievements from all groups are iterated through.

Specified by:
achievements in interface AchievementLibrary
Parameters:
agent - the player, or account, or null for all
Returns:
the enumeration of all achievements that apply

possiblyBumpPlayerAchievement

protected void possiblyBumpPlayerAchievement(MOB mob,
                                             AchievementLibrary.Achievement A,
                                             PlayerStats pStats,
                                             AchievementLibrary.Event E,
                                             int bumpNum,
                                             java.lang.Object... parms)

possiblyBumpAccountAchievement

protected void possiblyBumpAccountAchievement(MOB mob,
                                              AchievementLibrary.Achievement A,
                                              PlayerAccount account,
                                              AchievementLibrary.Event E,
                                              int bumpNum,
                                              java.lang.Object... parms)

possiblyBumpAchievement

public void possiblyBumpAchievement(MOB mob,
                                    AchievementLibrary.Event E,
                                    int bumpNum,
                                    java.lang.Object... parms)
Description copied from interface: AchievementLibrary
When an event occurs that might possible cause a player to have one of their achievements bumped, this method is called with event specific parameters which might possibly cause the achievement to be bumped in the tracker, which might cause it to be completed as well.

Specified by:
possiblyBumpAchievement in interface AchievementLibrary
Parameters:
mob - the player whose achievement needs to be checked
E - the event that occurred
bumpNum - the amount to bump the achievement by
parms - any event-specific argument that help determine whether a bump is warranted.

fakeBumpPlayerAchievement

protected java.util.List<AchievementLibrary.Achievement> fakeBumpPlayerAchievement(MOB mob,
                                                                                   AchievementLibrary.Achievement A,
                                                                                   PlayerStats pStats,
                                                                                   AchievementLibrary.Event E,
                                                                                   int bumpNum,
                                                                                   java.lang.Object... parms)

fakeBumpAccountAchievement

protected java.util.List<AchievementLibrary.Achievement> fakeBumpAccountAchievement(MOB mob,
                                                                                    AchievementLibrary.Achievement A,
                                                                                    PlayerAccount account,
                                                                                    AchievementLibrary.Event E,
                                                                                    int bumpNum,
                                                                                    java.lang.Object... parms)

fakeBumpAchievement

public java.util.List<AchievementLibrary.Achievement> fakeBumpAchievement(MOB mob,
                                                                          AchievementLibrary.Event E,
                                                                          int bumpNum,
                                                                          java.lang.Object... parms)
Description copied from interface: AchievementLibrary
When an event occurs that might possible cause a player to have one of their achievements bumped, this method is called with event specific parameters which might possibly cause the achievement to be bumped in the tracker, which might cause it to be completed as well. This method does not actually affect the players trackers, but only pretends to, and then returns the list of Achievements that would be gained by the effort.

Specified by:
fakeBumpAchievement in interface AchievementLibrary
Parameters:
mob - the player whose achievement needs to be checked
E - the event that occurred
bumpNum - the amount to bump the achievement by
parms - any event-specific argument that help determine whether a bump is warranted.
Returns:
the list of achievements that would be earned by the bump, if any. Empty list otherwise.

giveAwards

protected void giveAwards(MOB mob,
                          AchievementLibrary.Award[] awardSet,
                          AchievementLibrary.AchievementLoadFlag flag)

removeAwards

public java.lang.String removeAwards(MOB mob,
                                     AchievementLibrary.Award[] awardSet,
                                     AchievementLibrary.AchievementLoadFlag flag)
Description copied from interface: AchievementLibrary
When a player remorts, they lost their account achievement awards, which are restored later. This method is called to remove all account achievement rewards for a specific achievement.

Specified by:
removeAwards in interface AchievementLibrary
Parameters:
mob - the mob to lost
awardSet - the awards to remove
flag - whether this is happening before or after stat selection
Returns:
any messages you might want to show the user.

giveAwards

protected boolean giveAwards(AchievementLibrary.Achievement A,
                             Tattooable holder,
                             MOB mob,
                             AchievementLibrary.AchievementLoadFlag flag)

getAchievement

public AchievementLibrary.Achievement getAchievement(java.lang.String tattoo)
Description copied from interface: AchievementLibrary
Returns the achievement with the given tattoo key.

Specified by:
getAchievement in interface AchievementLibrary
Parameters:
tattoo - the tattoo key to find the achievement for
Returns:
the achievement object

deleteAchievement

public AchievementLibrary.Achievement deleteAchievement(java.lang.String tattoo)
Description copied from interface: AchievementLibrary
Finds and deleted the achievement with teh given tattoo key.

Specified by:
deleteAchievement in interface AchievementLibrary
Parameters:
tattoo - the tattoo key to find the achievement for
Returns:
the achievement object deleted, or null if not found

getAchievementsHelpFromMap

public java.lang.String getAchievementsHelpFromMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> helpMap,
                                                   AchievementLibrary.Event E,
                                                   java.lang.String parmName)
Description copied from interface: AchievementLibrary
Given the comments/help entried from the achievement definition file, and an event, and the name of the parameter inside the event, this returns the help entry for that parameter

Specified by:
getAchievementsHelpFromMap in interface AchievementLibrary
Parameters:
helpMap - the help map
E - the event to get help for
parmName - the parameter of that event to get help for
Returns:
the help text.

getAchievementsHelpMap

public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getAchievementsHelpMap()
Description copied from interface: AchievementLibrary
Returns all the comment/help entries from the achievement definition file The map is of the form event ID, then parameter->help map.

Specified by:
getAchievementsHelpMap in interface AchievementLibrary
Returns:
all the comment/help entries from the achievement definition file

buildRow

public java.lang.String buildRow(AchievementLibrary.Event E,
                                 java.util.Map<java.lang.String,java.lang.String> parmTree)

getAwardString

public java.lang.String getAwardString(AchievementLibrary.Award[] awards)
Description copied from interface: AchievementLibrary
Converts a parsed awards list back into an unparsed parameter/value string.

Specified by:
getAwardString in interface AchievementLibrary
Parameters:
awards - a parsed awards list
Returns:
an unparsed parameter/value string

addModifyAchievement

public boolean addModifyAchievement(MOB mob,
                                    AccountStats.Agent agent,
                                    java.lang.String tattoo,
                                    AchievementLibrary.Achievement A)
Description copied from interface: AchievementLibrary
Allows a new achievement to be added or removed, with a user interface editor presented for the given mob.

Specified by:
addModifyAchievement in interface AchievementLibrary
Parameters:
mob - the mob adding or editing the achievement
agent - whether player or account achievement
tattoo - the tattoo of the new or old achievement
A - the achievement to modify, or null for new
Returns:
true if the achievement was added or modified, false otherwise

resaveAchievements

public void resaveAchievements(java.lang.String modifyTattoo)
Description copied from interface: AchievementLibrary
Forces any changed or deleted achievements to re-saved to the definition file.

Specified by:
resaveAchievements in interface AchievementLibrary
Parameters:
modifyTattoo - the tattoo modified or deleted

evaluateAchievements

public boolean evaluateAchievements(MOB mob)
Description copied from interface: AchievementLibrary
Iterates through all the achievements to see if the given mob has completed any new ones, granting them and the awards if they have.

Specified by:
evaluateAchievements in interface AchievementLibrary
Parameters:
mob - the player to evaluate
Returns:
true if any achievements were newly completed, false otherwise

reloadAchievements

public void reloadAchievements()
Description copied from interface: AchievementLibrary
Forces all achievements to be reloaded from the definition file.

Specified by:
reloadAchievements in interface AchievementLibrary

grantAbilitiesAndExpertises

public void grantAbilitiesAndExpertises(MOB mob)
Description copied from interface: AchievementLibrary
Typically called when a mob gains a level, to allow the achievements on the mob to assign any new skills or expertises. Can also be called just to populate a mob with achievement skills, so it should also confirm any lower level skills also.

Specified by:
grantAbilitiesAndExpertises in interface AchievementLibrary
Parameters:
mob - the mob to give abilities to.
See Also:
AbilityContainer.addAbility(Ability)

loadPlayerSkillAwards

public void loadPlayerSkillAwards(Tattooable mob,
                                  PlayerStats stats)
Description copied from interface: AchievementLibrary
When a player is loaded, this method inspects their tattoos for any past achievements and, if found, loads the playerstats with trackable skill and expertises mappings, allowing them to receive those awards when the time is right.

Specified by:
loadPlayerSkillAwards in interface AchievementLibrary
Parameters:
mob - the tattooable mob to check tattoos on
stats - the playerstats to load with prizes
See Also:
AchievementLibrary.grantAbilitiesAndExpertises(MOB)

reloadPlayerAwards

public void reloadPlayerAwards(MOB mob,
                               AchievementLibrary.AchievementLoadFlag flag)
Description copied from interface: AchievementLibrary
When a player remorts, they keep their player achievements, but the rewards are removed. This method is called to re-reward all player achievement rewards.

Specified by:
reloadPlayerAwards in interface AchievementLibrary
Parameters:
mob - the mob to award
flag - this is happening before or after stat selection

loadAccountAchievements

public void loadAccountAchievements(MOB mob,
                                    AchievementLibrary.AchievementLoadFlag flag)
Description copied from interface: AchievementLibrary
When a new player is created, this method inspects their account tattoos for any that need to be passed down to this new player. If any are passed down, then the awards are granted, including skill awards if any.

Specified by:
loadAccountAchievements in interface AchievementLibrary
Parameters:
mob - the new character to load up.
flag - the circumstances under which achievements are being loaded
See Also:
AchievementLibrary.loadPlayerSkillAwards(Tattooable, PlayerStats)

makeAchievmentHelp

protected java.lang.String makeAchievmentHelp(AchievementLibrary.Achievement A)

getAchievementsHelp

public java.lang.String getAchievementsHelp(java.lang.String ID,
                                            boolean exact)
Description copied from interface: AchievementLibrary
Searches for an Achievement of the given tattoo name or display name, and returns a help entry for the achievement.

Specified by:
getAchievementsHelp in interface AchievementLibrary
Parameters:
ID - the tattoo name or display name
exact - true for exact matches only, false for startswith
Returns:
the help entry, or ""

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