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

Class Spell

code/src/java/pcgen/core/spell/Spell.java:37–99  ·  view source on GitHub ↗

Spell represents a magic spell from the games rules.

Source from the content-addressed store, hash-verified

35 * {@code Spell} represents a magic spell from the games rules.
36 */
37@SuppressWarnings("serial")
38public final class Spell extends PObject implements InfoFacade, Ungranted
39{
40 public static final CDOMReference<SpellList> SPELLS;
41
42 static
43 {
44 SpellList wpl = new SpellList();
45 wpl.setName("*Spells");
46 SPELLS = CDOMDirectSingleRef.getRef(wpl);
47 }
48
49 @Override
50 public String getPCCText()
51 {
52 StringJoiner txt = new StringJoiner("\t");
53 txt.add(getDisplayName());
54 Globals.getContext().unparse(this).forEach(txt::add);
55 txt.add(PrerequisiteWriter.prereqsToString(this));
56 return txt.toString();
57 }
58
59 /**
60 * Tests to see if two Spell objects are equal.
61 *
62 * @param obj Spell to compare to.
63 *
64 * @return <tt>true</tt> if the Spells are the same.
65 */
66 @Override
67 public boolean equals(final Object obj)
68 {
69 return obj instanceof Spell && getKeyName().equalsIgnoreCase(((Spell) obj).getKeyName());
70 }
71
72 /**
73 * Need something consistent with equals - this causes conflicts with the same name
74 * but that's ok, it's only a hashcode.
75 */
76 @Override
77 public int hashCode()
78 {
79 return getKeyName().hashCode();
80 }
81
82 public boolean isAllowed(Type t)
83 {
84 boolean allowed = containsInList(ListKey.ITEM, t);
85 boolean prohibited = Type.POTION.equals(t) || containsInList(ListKey.PROHIBITED_ITEM, t);
86 return allowed || !prohibited;
87 }
88
89 @Override
90 public String toString()
91 {
92 if (SettingsHandler.guiUsesOutputNameSpells())
93 {
94 return getOutputName();

Callers

nothing calls this directly

Calls 2

getRefMethod · 0.95
setNameMethod · 0.65

Tested by

no test coverage detected