mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-03 16:51:28 +01:00
You can now cast more than one placed spell at a time (for any type of placed spell, not just portals)
This commit is contained in:
parent
ab017ded6e
commit
0250d8875a
3 changed files with 17 additions and 6 deletions
|
@ -106,7 +106,9 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
||||||
if (newSpell.getResult() != ActionResult.FAIL) {
|
if (newSpell.getResult() != ActionResult.FAIL) {
|
||||||
CustomisedSpellType<?> spell = newSpell.getValue();
|
CustomisedSpellType<?> spell = newSpell.getValue();
|
||||||
|
|
||||||
boolean removed = player.getSpellSlot().removeIf(spell.isEmpty() ? spell : SpellType.PORTAL.negate().and(spell), true);
|
boolean removed = player.getSpellSlot().removeWhere(s -> {
|
||||||
|
return s.findMatches(spell).findAny().isPresent() && (spell.isEmpty() || !SpellType.PLACED_SPELL.test(s));
|
||||||
|
}, true);
|
||||||
player.subtractEnergyCost(removed ? 2 : 4);
|
player.subtractEnergyCost(removed ? 2 : 4);
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
Spell s = spell.apply(player);
|
Spell s = spell.apply(player);
|
||||||
|
|
|
@ -40,11 +40,20 @@ public interface SpellContainer {
|
||||||
void put(@Nullable Spell effect);
|
void put(@Nullable Spell effect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all matching active effects.
|
* Removes all active effects that match or contain a matching effect.
|
||||||
*
|
*
|
||||||
* @return True if the collection was changed
|
* @return True if the collection was changed
|
||||||
*/
|
*/
|
||||||
boolean removeIf(Predicate<Spell> test, boolean update);
|
default boolean removeIf(Predicate<Spell> test, boolean update) {
|
||||||
|
return removeWhere(spell -> spell.findMatches(test).findFirst().isPresent(), update);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all matching top level active effects.
|
||||||
|
*
|
||||||
|
* @return True if the collection was changed
|
||||||
|
*/
|
||||||
|
boolean removeWhere(Predicate<Spell> test, boolean update);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates active spells and optionally removes matching ones.
|
* Iterates active spells and optionally removes matching ones.
|
||||||
|
|
|
@ -66,9 +66,9 @@ public class EffectSync implements SpellContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeIf(Predicate<Spell> test, boolean update) {
|
public boolean removeWhere(Predicate<Spell> test, boolean update) {
|
||||||
return reduce((initial, effect) -> {
|
return reduce((initial, effect) -> {
|
||||||
if (!effect.findMatches(test).findFirst().isPresent()) {
|
if (!test.test(effect)) {
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
spells.removeReference(effect);
|
spells.removeReference(effect);
|
||||||
|
@ -140,6 +140,6 @@ public class EffectSync implements SpellContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface Alteration {
|
private interface Alteration {
|
||||||
boolean apply(boolean initial, Spell item);
|
boolean apply(boolean initial, Spell spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue