MCPcopy Create free account
hub / github.com/PCGen/pcgen / dataAdded

Method dataAdded

code/src/java/pcgen/cdom/facet/SpellBookFacet.java:55–83  ·  view source on GitHub ↗

Adds a SpellBook to this facet if the Equipment added to a Player Character was a SpellBook. Triggered when one of the Facets to which SpellBookFacet listens fires a DataFacetChangeEvent to indicate a piece of Equipment was added to a Player Character. @param dfce The DataFacetChangeEve

(DataFacetChangeEvent<CharID, Equipment> dfce)

Source from the content-addressed store, hash-verified

53 * change
54 */
55 @Override
56 public void dataAdded(DataFacetChangeEvent<CharID, Equipment> dfce)
57 {
58 Equipment eq = dfce.getCDOMObject();
59 if (eq.isType(Constants.TYPE_SPELLBOOK))
60 {
61 CharID id = dfce.getCharID();
62 String baseBookname = eq.getName();
63 String bookName = eq.getName();
64 int qty = (int) eq.qty();
65 for (int i = 0; i < qty; i++)
66 {
67 if (i > 0)
68 {
69 bookName = baseBookname + " #" + (i + 1);
70 }
71 SpellBook book = getBookNamed(id, bookName);
72 if (book == null)
73 {
74 book = new SpellBook(bookName, SpellBook.TYPE_SPELL_BOOK);
75 }
76 book.setEquip(eq);
77 if (!containsBookNamed(id, book.getName()))
78 {
79 add(id, book);
80 }
81 }
82 }
83 }
84
85 /**
86 * Triggered when one of the Facets to which SpellBookFacet listens fires a

Callers

nothing calls this directly

Calls 10

isTypeMethod · 0.95
getNameMethod · 0.95
qtyMethod · 0.95
getBookNamedMethod · 0.95
setEquipMethod · 0.95
containsBookNamedMethod · 0.95
getNameMethod · 0.95
addMethod · 0.95
getCDOMObjectMethod · 0.65
getCharIDMethod · 0.65

Tested by

no test coverage detected