Adds a SpellLikeAbility to this facet if the CDOMObject added to a Player Character contains a SPELLS entry. Triggered when one of the Facets to which SpellsFacet listens fires a DataFacetChangeEvent to indicate a CDOMObject was added to a Player Character. @param dfce The DataFacetChan
(DataFacetChangeEvent<CharID, CDOMObject> dfce)
| 55 | * change |
| 56 | */ |
| 57 | @Override |
| 58 | public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) |
| 59 | { |
| 60 | CharID id = dfce.getCharID(); |
| 61 | CDOMObject cdo = dfce.getCDOMObject(); |
| 62 | |
| 63 | Collection<CDOMReference<Spell>> mods = cdo.getListMods(Spell.SPELLS); |
| 64 | if (mods == null) |
| 65 | { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | for (CDOMReference<Spell> ref : mods) |
| 70 | { |
| 71 | Collection<AssociatedPrereqObject> assocs = cdo.getListAssociations(Spell.SPELLS, ref); |
| 72 | Collection<Spell> spells = ref.getContainedObjects(); |
| 73 | for (AssociatedPrereqObject apo : assocs) |
| 74 | { |
| 75 | Formula times = apo.getAssociation(AssociationKey.TIMES_PER_UNIT); |
| 76 | String timeunit = apo.getAssociation(AssociationKey.TIME_UNIT); |
| 77 | // The timeunit needs to default to day as per the docs |
| 78 | if (timeunit == null) |
| 79 | { |
| 80 | timeunit = "Day"; |
| 81 | } |
| 82 | String casterlevel = apo.getAssociation(AssociationKey.CASTER_LEVEL); |
| 83 | String dcformula = apo.getAssociation(AssociationKey.DC_FORMULA); |
| 84 | String book = apo.getAssociation(AssociationKey.SPELLBOOK); |
| 85 | String ident = cdo.getQualifiedKey(); |
| 86 | for (Spell sp : spells) |
| 87 | { |
| 88 | SpellLikeAbility sla = |
| 89 | new SpellLikeAbility(sp, times, timeunit, book, casterlevel, dcformula, ident); |
| 90 | sla.addAllPrerequisites(apo.getPrerequisiteList()); |
| 91 | add(id, sla, cdo); |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Removes all SpellLikeAbility objects granted by a CDOMObject when that |
nothing calls this directly
no test coverage detected