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)
| 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 |
nothing calls this directly
no test coverage detected