ClassFacet is a Facet that tracks the PCClass objects possessed by a Player Character.
| 44 | * |
| 45 | */ |
| 46 | public class ClassFacet extends AbstractDataFacet<CharID, PCClass> implements SetFacet<CharID, PCClass> |
| 47 | { |
| 48 | private final ClassLevelChangeSupport support = new ClassLevelChangeSupport(); |
| 49 | |
| 50 | /** |
| 51 | * Add the given PCClass to the list of PCClass objects stored in this |
| 52 | * ClassFacet for the Player Character represented by the given CharID. |
| 53 | * |
| 54 | * @param id |
| 55 | * The CharID representing the Player Character for which the |
| 56 | * given PCClass should be added |
| 57 | * @param obj |
| 58 | * The PCClass to be added to the list of PCClass objects stored |
| 59 | * in this AbstractListFacet for the Player Character represented |
| 60 | * by the given CharID |
| 61 | */ |
| 62 | public void addClass(CharID id, PCClass obj) |
| 63 | { |
| 64 | Objects.requireNonNull(obj, "PCClass to add may not be null"); |
| 65 | if (getConstructingClassInfo(id).addClass(obj)) |
| 66 | { |
| 67 | fireDataFacetChangeEvent(id, obj, DataFacetChangeEvent.DATA_ADDED); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Sets the PCClassLevel object associated with the given PCClass for the Player |
| 73 | * Character represented by the given CharID. Returns true if the set is successful. |
| 74 | * The set will be successful if the given PCClass is possessed by the given |
| 75 | * PlayerCharacter; false otherwise. |
| 76 | * |
| 77 | * The (numeric) class level for which the given PCClassLevel should be applied is |
| 78 | * determined by the level value set in the PCClassLevel. |
| 79 | * |
| 80 | * @param id |
| 81 | * The CharID representing the Player Character for which the given |
| 82 | * PCClassLevel should be set |
| 83 | * @param pcc |
| 84 | * The PCClass object for which the PCClassLevel object is set as the |
| 85 | * PCClass |
| 86 | * @param pcl |
| 87 | * The PCClassLevel object to be associated with the given PCClass and |
| 88 | * Player Character represented by the given CharID |
| 89 | * @return true if the set is successful; false otherwise. |
| 90 | * @throws CloneNotSupportedException |
| 91 | * if the class level cannot be thrown |
| 92 | */ |
| 93 | public boolean setClassLevel(CharID id, PCClass pcc, PCClassLevel pcl) throws CloneNotSupportedException |
| 94 | { |
| 95 | Objects.requireNonNull(pcc, "Class cannot be null in setClassLevel"); |
| 96 | Objects.requireNonNull(pcl, "Class Level cannot be null in setClassLevel"); |
| 97 | ClassInfo info = getClassInfo(id); |
| 98 | if (info == null) |
| 99 | { |
| 100 | return false; |
| 101 | } |
| 102 | PCClassLevel old = info.getClassLevel(pcc, pcl.get(IntegerKey.LEVEL)); |
| 103 | boolean returnVal = info.setClassLevel(pcc, pcl); |
nothing calls this directly
no outgoing calls
no test coverage detected