com.huguesjohnson.tiamat
Class SkillCollection

java.lang.Object
  extended by com.huguesjohnson.tiamat.SkillCollection

public class SkillCollection
extends java.lang.Object

SkillCollection - used to store a collection of skills

Author:
Hugues Johnson

Constructor Summary
SkillCollection()
          Default constructor, uses default pathDelimiter.
SkillCollection(Skill[] skills)
          Create a new SkillCollection based off an array of Skills with a the default path delimiter.
SkillCollection(Skill[] skills, java.lang.String pathDelimiter)
          Create a new SkillCollection based off an array of Skills with a the default path delimiter.
SkillCollection(java.lang.String pathDelimiter)
          Create a new SkillCollection with a custom path delimiter.
 
Method Summary
 void adjustAllSkills(int percentage)
          Adjusts the values of all Skills in the collection by the given percentage, useful for updating all Skills uniformly for gaining/losing a level.
 void adjustSkills(java.lang.String rootPath, int percentage)
          Adjusts the values of all Skills under the rootPath by the given percentage, useful for updating all Skills uniformly for gaining/losing a level.
 Skill[] getAll()
          Returns all Skills in the collection.
 int getCount()
          Returns the total number of Skills in the collection.
 int getCount(java.lang.String path)
          Returns the total number of Skills starting from the specified path.
 SkillCollection getModifiersFor(java.lang.String targetPath)
          Returns a collection of all Skills that have a target with a name equal to targetPath.
 int getNetModification(java.lang.String targetPath)
          This method is used to get all the modifiers for a target and return the sum of their values.
 Skill getSkill(java.lang.String path)
          Returns the Skill with the specified path if it exists, otherwise null.
 boolean removeSkill(java.lang.String path)
          Removes the Skill with the specified path.
 void setSkill(java.lang.String path, Skill skill)
          Sets the Skill with the specified path, adds it if it doesn't exist.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SkillCollection

public SkillCollection()
Default constructor, uses default pathDelimiter.


SkillCollection

public SkillCollection(java.lang.String pathDelimiter)
Create a new SkillCollection with a custom path delimiter.

Parameters:
pathDelimiter - The new path delimiter to use.

SkillCollection

public SkillCollection(Skill[] skills)
Create a new SkillCollection based off an array of Skills with a the default path delimiter.

Parameters:
skills - The initial set of Skills to add to the collection.

SkillCollection

public SkillCollection(Skill[] skills,
                       java.lang.String pathDelimiter)
Create a new SkillCollection based off an array of Skills with a the default path delimiter.

Parameters:
skills - The initial set of Skills to add to the collection.
pathDelimiter - The new path delimiter to use.
Method Detail

removeSkill

public boolean removeSkill(java.lang.String path)
Removes the Skill with the specified path.

Parameters:
path - The path of the Skill to remove.
Returns:
The success of the operation.

getSkill

public Skill getSkill(java.lang.String path)
Returns the Skill with the specified path if it exists, otherwise null.

Parameters:
path - The path of the Skill to retreive.
Returns:
The Skill with the specified path if it exists, otherwise null.

setSkill

public void setSkill(java.lang.String path,
                     Skill skill)
Sets the Skill with the specified path, adds it if it doesn't exist.

Parameters:
path - The path of the Skill to set.
skill - The Skill to set.

getCount

public int getCount()
Returns the total number of Skills in the collection.

Returns:
The total number of Skills in the collection.

getCount

public int getCount(java.lang.String path)
Returns the total number of Skills starting from the specified path.

Parameters:
path - The starting path to count from.
Returns:
The total number of Skills starting from the specified path.

getModifiersFor

public SkillCollection getModifiersFor(java.lang.String targetPath)
Returns a collection of all Skills that have a target with a name equal to targetPath.

Parameters:
targetPath - The target name to look for.
Returns:
A collection of all Skills that have a target with a name equal to targetPath.

getNetModification

public int getNetModification(java.lang.String targetPath)
This method is used to get all the modifiers for a target and return the sum of their values.

Parameters:
targetPath - The target name to look for.
Returns:
The sum of modifiers for a target.

adjustAllSkills

public void adjustAllSkills(int percentage)
Adjusts the values of all Skills in the collection by the given percentage, useful for updating all Skills uniformly for gaining/losing a level.

Parameters:
percentage - The percentage to adjust all Skills by.

adjustSkills

public void adjustSkills(java.lang.String rootPath,
                         int percentage)
Adjusts the values of all Skills under the rootPath by the given percentage, useful for updating all Skills uniformly for gaining/losing a level.

Parameters:
rootPath - The path name to start at.
percentage - The percentage to adjust all Skills by.

getAll

public Skill[] getAll()
Returns all Skills in the collection.

Returns:
All Skills in the collection.

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the object.