mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 08:18:00 +01:00
Properly replace existing spells when casting one with different traits. #353
This commit is contained in:
parent
e053539d1b
commit
1d15630566
1 changed files with 9 additions and 2 deletions
|
@ -100,12 +100,19 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
|
||||||
|
|
||||||
if (newSpell.getResult() != ActionResult.FAIL && canCast(newSpell.getValue().type())) {
|
if (newSpell.getResult() != ActionResult.FAIL && canCast(newSpell.getValue().type())) {
|
||||||
CustomisedSpellType<?> spell = newSpell.getValue();
|
CustomisedSpellType<?> spell = newSpell.getValue();
|
||||||
|
if (newSpell.getResult() == ActionResult.CONSUME) {
|
||||||
|
CustomisedSpellType<?> equippedType = player.getCharms().getEquippedSpell(player.getCharms().getHand());
|
||||||
|
if (equippedType.type() == spell.type()) {
|
||||||
|
player.getCharms().equipSpell(player.getCharms().getHand(), spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasExact = player.getSpellSlot().contains(spell);
|
||||||
boolean removed = player.getSpellSlot().removeWhere(s -> {
|
boolean removed = player.getSpellSlot().removeWhere(s -> {
|
||||||
return s.findMatches(spell).findAny().isPresent() && (spell.isEmpty() || !SpellType.PLACED_SPELL.test(s));
|
return s.findMatches(spell.type()).findAny().isPresent() && (spell.isEmpty() || !SpellType.PLACED_SPELL.test(s));
|
||||||
}, true);
|
}, true);
|
||||||
player.subtractEnergyCost(removed ? 2 : 4);
|
player.subtractEnergyCost(removed ? 2 : 4);
|
||||||
if (!removed) {
|
if (!hasExact && !spell.isEmpty()) {
|
||||||
Spell s = spell.apply(player, CastingMethod.DIRECT);
|
Spell s = spell.apply(player, CastingMethod.DIRECT);
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
player.spawnParticles(ParticleTypes.LARGE_SMOKE, 6);
|
player.spawnParticles(ParticleTypes.LARGE_SMOKE, 6);
|
||||||
|
|
Loading…
Reference in a new issue