Fix time change ability not appearing for unicorns wearing the unicorn amulet

This commit is contained in:
Sollace 2023-08-29 15:17:44 +01:00
parent 82ec2b4f14
commit 8385232c5b
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 5 additions and 4 deletions

View file

@ -186,13 +186,13 @@ public record Race (boolean canCast, FlightType flightType, boolean canUseEarth,
return REGISTRY.stream().filter(r -> r.isPermitted(player)).collect(Collectors.toSet());
}
public record Composite (Race physical, Race pseudo) {
public record Composite (Race physical, @Nullable Race pseudo) {
public boolean includes(Race race) {
return physical == race || pseudo == race;
}
public boolean any(Predicate<Race> test) {
return test.test(physical) || test.test(pseudo);
return test.test(physical) || (pseudo != null && test.test(pseudo));
}
}
}

View file

@ -18,7 +18,7 @@ public class TimeChangeAbility implements Ability<Hit> {
@Override
public boolean canUse(Race.Composite race) {
return race.physical() != race.pseudo() && race.pseudo() == Race.UNICORN;
return race.pseudo() == Race.UNICORN;
}
@Override

View file

@ -229,7 +229,8 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
return new Race.Composite(observed,
AmuletSelectors.UNICORN_AMULET.test(entity) ? Race.UNICORN
: AmuletSelectors.ALICORN_AMULET.test(entity) ? Race.ALICORN
: observed);
: null
);
}
/**