mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Apply trait-specific corruption when using a spell
This commit is contained in:
parent
ceac5bb649
commit
3e848e86ed
4 changed files with 11 additions and 1 deletions
|
@ -25,6 +25,11 @@ public interface Spell extends NbtSerialisable, Affine {
|
|||
*/
|
||||
SpellType<?> getType();
|
||||
|
||||
/**
|
||||
* Gets the traits of this spell.
|
||||
*/
|
||||
SpellTraits getTraits();
|
||||
|
||||
/**
|
||||
* The unique id of this particular spell instance.
|
||||
*/
|
||||
|
|
|
@ -35,7 +35,7 @@ public abstract class AbstractSpell implements Spell {
|
|||
return type;
|
||||
}
|
||||
|
||||
protected SpellTraits getTraits() {
|
||||
public final SpellTraits getTraits() {
|
||||
return traits == null ? SpellTraits.EMPTY : traits;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ public final class SpellTraits implements Iterable<Map.Entry<Trait, Float>> {
|
|||
this(new EnumMap<>(from.traits));
|
||||
}
|
||||
|
||||
public float getCorruption() {
|
||||
return (float)stream().filter(e -> e.getValue() != 0).mapToDouble(e -> e.getKey().getGroup().getCorruption()).sum();
|
||||
}
|
||||
|
||||
public SpellTraits multiply(float factor) {
|
||||
return factor == 0 ? EMPTY : map(v -> v * factor);
|
||||
}
|
||||
|
|
|
@ -606,6 +606,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
|||
if (spell.getAffinity() == Affinity.BAD && entity.getWorld().random.nextInt(120) == 0) {
|
||||
getCorruption().add(1);
|
||||
}
|
||||
getCorruption().add((int)spell.getTraits().getCorruption());
|
||||
}
|
||||
setDirty();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue