Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Best way to determine whether a spell is castable?

Eyyyyy Macarena
Joined
Oct 24, 2018
Messages
58
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:

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?
 
Top