Change cost estimate for spellcasting to properly account for whether a spell is active or not

This commit is contained in:
Sollace 2021-12-24 16:37:27 +02:00
parent 62e5ab01cc
commit 3d2a50655b
2 changed files with 3 additions and 33 deletions

View file

@ -48,21 +48,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
@Override
@Nullable
public Hit tryActivate(Pony player) {
float manaLevel = player.getMagicalReserves().getMana().get();
TypedActionResult<ItemStack> amulet = getAmulet(player);
if (amulet.getResult().isAccepted()) {
return Hit.of(manaLevel > 0 && ((AmuletItem)amulet.getValue().getItem()).canCharge(amulet.getValue()));
}
ActionResult spell = player.getCharms().getSpellInHand(Hand.MAIN_HAND).getResult();
if (spell != ActionResult.PASS) {
return Hit.of(spell != ActionResult.FAIL && manaLevel > 4F);
}
return Hit.of(manaLevel > (player.getSpellSlot().isPresent() ? 2F : 4F));
return Hit.of(player.getMagicalReserves().getMana().get() >= getCostEstimate(player));
}
@Override
@ -80,15 +66,9 @@ public class UnicornCastingAbility implements Ability<Hit> {
return Math.min(manaLevel, ((AmuletItem)amulet.getValue().getItem()).getChargeRemainder(amulet.getValue()));
}
if (player.getCharms().getSpellInHand(Hand.MAIN_HAND).getResult() == ActionResult.CONSUME) {
return 4F;
}
TypedActionResult<CustomisedSpellType<?>> spell = player.getCharms().getSpellInHand(Hand.MAIN_HAND);
if (player.getSpellSlot().isPresent()) {
return 2F;
}
return 4F;
return !spell.getResult().isAccepted() || spell.getValue().isOn(player) ? 2 : 4;
}
@Override

View file

@ -57,16 +57,6 @@ public interface SpellContainer {
return get(null, update);
}
/**
* Returns true if this caster has an active effect attached to it.
*
* @deprecated To be removed
*/
@Deprecated
default boolean isPresent() {
return contains((SpellPredicate<?>)null);
}
/**
* Gets the active effect for this caster updating it if needed.
*/