- Joined
- Oct 24, 2018
- Messages
- 58
- Thread Author
- #1
I can't seem to find a built-in method to determine whether a spell is castable. Looking around, it seems to be possible to do something among these lines:
But the problem is that getComponent isn't part of any spellbook interface so you'd need to implement separate methods for each spellbook.
Am I missing something?
Code:
public static boolean spellIsCastable(Magic.Lunar spell) {
int id = spell.getSpriteIdWhenAvailable();
return Optional.ofNullable(spell.getComponent())
.map(InterfaceComponent::getSpriteId)
.map(actualSpriteId -> actualSpriteId == id)
.orElse(false);
}
But the problem is that getComponent isn't part of any spellbook interface so you'd need to implement separate methods for each spellbook.
Am I missing something?