mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-28 07:37:58 +01:00
Change cost estimate for spellcasting to properly account for whether a spell is active or not
This commit is contained in:
parent
62e5ab01cc
commit
3d2a50655b
2 changed files with 3 additions and 33 deletions
|
@ -48,21 +48,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Hit tryActivate(Pony player) {
|
public Hit tryActivate(Pony player) {
|
||||||
float manaLevel = player.getMagicalReserves().getMana().get();
|
return Hit.of(player.getMagicalReserves().getMana().get() >= getCostEstimate(player));
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,15 +66,9 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
||||||
return Math.min(manaLevel, ((AmuletItem)amulet.getValue().getItem()).getChargeRemainder(amulet.getValue()));
|
return Math.min(manaLevel, ((AmuletItem)amulet.getValue().getItem()).getChargeRemainder(amulet.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getCharms().getSpellInHand(Hand.MAIN_HAND).getResult() == ActionResult.CONSUME) {
|
TypedActionResult<CustomisedSpellType<?>> spell = player.getCharms().getSpellInHand(Hand.MAIN_HAND);
|
||||||
return 4F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.getSpellSlot().isPresent()) {
|
return !spell.getResult().isAccepted() || spell.getValue().isOn(player) ? 2 : 4;
|
||||||
return 2F;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 4F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -57,16 +57,6 @@ public interface SpellContainer {
|
||||||
return get(null, update);
|
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.
|
* Gets the active effect for this caster updating it if needed.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue