public void castSpell(Ability ability) { if (ability.state != Ability.State.READY && ability.abilityStats.castType != Castable.CastType.TOGGLE) return; if (ability.abilityStats.castType == Castable.CastType.ALIVETARGET) { if (owner.selectedUnit == null || !Alive.class.isAssignableFrom(owner.selectedUnit.getClass())) return; ability.setTarget((Alive) owner.selectedUnit); } try { ability.activate(); } catch (SLEImproperInputException e) { System.out.println("The hero was unable to cast the spell due to improper input"); e.printStackTrace(); } for (Buff b : getBuffs()) if (b.activationTrigger == Buff.TriggerType.ONSPELLCAST) b.trigger(this); }