diff --git a/src/main/java/net/tfminecraft/magic/blood/BloodConfig.java b/src/main/java/net/tfminecraft/magic/blood/BloodConfig.java index e8a4f03..95469b4 100644 --- a/src/main/java/net/tfminecraft/magic/blood/BloodConfig.java +++ b/src/main/java/net/tfminecraft/magic/blood/BloodConfig.java @@ -135,6 +135,7 @@ public static boolean load(File source, Logger log) { RoomTemplate.load(config.getConfigurationSection("placement.room.template"), log); huntPointsRequired = Math.max(1, config.getInt("hunt.points_required", 7)); WhisperConfig.load(config.getConfigurationSection("whispers"), config.getConfigurationSection("voices"), log); + OccultistHints.load(config.getConfigurationSection("hints"), log); AnimalConfig.load(config.getConfigurationSection("animal"), log); CorruptionConfig.load(config.getConfigurationSection("corruption"), log); ChoiceConfig.load(config.getConfigurationSection("choice"), config.getConfigurationSection("classes"), @@ -204,6 +205,7 @@ public static void reset() { purifyCheckMinutes = 10; huntPointsRequired = 7; WhisperConfig.reset(); + OccultistHints.reset(); AnimalConfig.reset(); CorruptionConfig.reset(); ChoiceConfig.reset(); diff --git a/src/main/java/net/tfminecraft/magic/blood/BloodListener.java b/src/main/java/net/tfminecraft/magic/blood/BloodListener.java index d9aa7e9..7565c70 100644 --- a/src/main/java/net/tfminecraft/magic/blood/BloodListener.java +++ b/src/main/java/net/tfminecraft/magic/blood/BloodListener.java @@ -367,7 +367,8 @@ public void onCharacterDeath(CharacterDeathEvent event) { Player online = Bukkit.getPlayer(killer.ownerId()); Player current = online != null && character.equalsIgnoreCase(AltarService.currentCharacter(online)) ? online : null; - WhisperService.addTo(character, killer.ownerId().toString(), WhisperConfig.characterKill(), current); + WhisperService.addTo(character, killer.ownerId().toString(), WhisperConfig.characterKill(), current, + OccultistHints.Deed.CHARACTER_KILL); } /** HIGHEST: after other damage plugins, so the ritual knife's stroke stays lethal on a bound animal. */ diff --git a/src/main/java/net/tfminecraft/magic/blood/EvilPlayWhispers.java b/src/main/java/net/tfminecraft/magic/blood/EvilPlayWhispers.java index e676946..de8aaac 100644 --- a/src/main/java/net/tfminecraft/magic/blood/EvilPlayWhispers.java +++ b/src/main/java/net/tfminecraft/magic/blood/EvilPlayWhispers.java @@ -61,6 +61,7 @@ static void onPlay(Player player, boolean sessionStarted) { if (character == null) { return; } - WhisperService.addTo(character, player.getUniqueId().toString(), WhisperConfig.robbery(), player); + WhisperService.addTo(character, player.getUniqueId().toString(), WhisperConfig.robbery(), player, + OccultistHints.Deed.ROBBERY); } } diff --git a/src/main/java/net/tfminecraft/magic/blood/OccultistHints.java b/src/main/java/net/tfminecraft/magic/blood/OccultistHints.java new file mode 100644 index 0000000..9829a03 --- /dev/null +++ b/src/main/java/net/tfminecraft/magic/blood/OccultistHints.java @@ -0,0 +1,180 @@ +package net.tfminecraft.magic.blood; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.UUID; +import java.util.logging.Logger; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; + +import net.tfminecraft.magic.util.MagicText; + +/** + * Faint hints for characters with a fast trait (Occultist) whose voices have not woken yet: a short + * line when a deed feeds their whisper meter, and now and then a riddle when they are alone. Both are + * the character's own thoughts in the pale colours; they never name the rules or the god. + * From the hints: section of the wildmagic/bloodmagic config. + */ +public final class OccultistHints { + + /** What fed the meter. Each has its own hint lines (hints.deeds.). */ + public enum Deed { + STOLEN_ANIMAL, + OWN_ANIMAL, + CHARACTER_KILL, + ROBBERY, + CORRUPTION + } + + private static final long MINUTE = 60_000L; + /** When each online player may next hear a riddle (by player). */ + private static final Map NEXT_RIDDLE = new HashMap<>(); + /** When each online player may next hear a hint for each deed (by player). */ + private static final Map> NEXT_DEED = new HashMap<>(); + + private static boolean enabled = true; + private static String style = ""; + private static List colours = List.of(); + private static String sound = ""; + private static float pitch = 1f; + private static float volume = 0.4f; + private static long deedCooldown = 60 * MINUTE; + private static final Map> DEEDS = new EnumMap<>(Deed.class); + private static List riddles = List.of(); + private static int[] firstRiddle = {30, 90}; + private static int[] riddleInterval = {120, 240}; + + private OccultistHints() {} + + static void reset() { + enabled = true; + style = ""; + colours = List.of(); + sound = ""; + pitch = 1f; + volume = 0.4f; + deedCooldown = 60 * MINUTE; + DEEDS.clear(); + riddles = List.of(); + firstRiddle = new int[] {30, 90}; + riddleInterval = new int[] {120, 240}; + } + + static void load(ConfigurationSection section, Logger log) { + reset(); + if (section == null) { + return; + } + enabled = section.getBoolean("enabled", true); + style = section.getString("style", ""); + List stops = new ArrayList<>(); + for (String raw : section.getStringList("colors")) { + if (VoiceColours.valid(raw)) { + stops.add(raw.trim()); + } else { + log.warning("[Magic] blood magic config hints.colors: '" + raw + "' is not a #rrggbb colour"); + } + } + colours = List.copyOf(stops); + sound = section.getString("sound", ""); + pitch = (float) section.getDouble("pitch", 1.0); + volume = (float) Math.max(0, section.getDouble("volume", 0.4)); + deedCooldown = Math.max(0, section.getInt("deed_cooldown_minutes", 60)) * MINUTE; + for (Deed deed : Deed.values()) { + List lines = section.getStringList("deeds." + deed.name().toLowerCase(Locale.ROOT)); + if (!lines.isEmpty()) { + DEEDS.put(deed, List.copyOf(lines)); + } + } + riddles = List.copyOf(section.getStringList("riddles")); + firstRiddle = range(section.getIntegerList("first_riddle_minutes"), firstRiddle); + riddleInterval = range(section.getIntegerList("riddle_interval_minutes"), riddleInterval); + } + + private static int[] range(List raw, int[] fallback) { + if (raw.size() != 2) { + return fallback; + } + int min = Math.max(1, Math.min(raw.get(0), raw.get(1))); + return new int[] {min, Math.max(min, Math.max(raw.get(0), raw.get(1)))}; + } + + /** + * A deed just fed a fast-trait character's meter (the voices are not awake yet): one line about it, + * at most once per deed_cooldown_minutes for each kind of deed. + */ + static void deed(Player player, Deed deed) { + List lines = DEEDS.getOrDefault(deed, List.of()); + if (!enabled || lines.isEmpty()) { + return; + } + long now = WhisperService.clock.getAsLong(); + Map due = NEXT_DEED.computeIfAbsent(player.getUniqueId(), id -> new EnumMap<>(Deed.class)); + if (now < due.getOrDefault(deed, 0L)) { + return; + } + due.put(deed, now + deedCooldown); + say(player, lines.get(WhisperService.random.nextInt(lines.size()))); + } + + /** + * Once a minute for each online player with a character. A riddle falls due a while after they + * join and then every riddle_interval_minutes; it waits until they are alone, and only a fast-trait + * character whose voices have not woken hears it. + */ + static void tick(Player player, String character, BloodRecord record) { + UUID id = player.getUniqueId(); + if (!enabled || riddles.isEmpty() || record != null && record.getStage() != BloodStage.NONE) { + NEXT_RIDDLE.remove(id); + return; + } + long now = WhisperService.clock.getAsLong(); + Long due = NEXT_RIDDLE.get(id); + if (due == null) { + NEXT_RIDDLE.put(id, now + minutes(firstRiddle) * MINUTE); + return; + } + if (now < due || !WhisperService.alone(player)) { + return; + } + // The trait is only looked up when a riddle falls due; without it the next check is an interval away. + if (WhisperService.fastTraitOf.test(character)) { + say(player, riddles.get(WhisperService.random.nextInt(riddles.size()))); + } + NEXT_RIDDLE.put(id, now + minutes(riddleInterval) * MINUTE); + } + + private static int minutes(int[] range) { + return range[0] + WhisperService.random.nextInt(range[1] - range[0] + 1); + } + + /** One line to this player alone, in the hints' colours and sound. */ + static void say(Player player, String line) { + String prefix = MagicText.format(style); + player.sendMessage(colours.isEmpty() ? prefix + MagicText.format(line) + : VoiceColours.gradient(line, colours, prefix)); + if (!sound.isBlank()) { + player.playSound(player.getLocation(), sound, volume, pitch); + } + } + + /** Forget the player's timers, e.g. after a quit or a character switch. */ + static void forget(UUID player) { + NEXT_RIDDLE.remove(player); + NEXT_DEED.remove(player); + } + + static Long nextRiddle(UUID player) { + return NEXT_RIDDLE.get(player); + } + + static void clear() { + NEXT_RIDDLE.clear(); + NEXT_DEED.clear(); + } +} diff --git a/src/main/java/net/tfminecraft/magic/blood/WhisperService.java b/src/main/java/net/tfminecraft/magic/blood/WhisperService.java index defce72..7377b3f 100644 --- a/src/main/java/net/tfminecraft/magic/blood/WhisperService.java +++ b/src/main/java/net/tfminecraft/magic/blood/WhisperService.java @@ -71,10 +71,19 @@ public static void add(Player player, double amount) { * before the voices start. Returns true when this woke them. */ public static boolean addTo(String character, String owner, double amount, Player online) { - return addTo(character, owner, amount, online, true); + return addTo(character, owner, amount, online, true, null); } - private static boolean addTo(String character, String owner, double amount, Player online, boolean multiply) { + /** + * As {@link #addTo(String, String, double, Player)}, for a deed: a fast-trait character online + * whose voices it did not wake gets a faint hint about it. + */ + public static boolean addTo(String character, String owner, double amount, Player online, OccultistHints.Deed deed) { + return addTo(character, owner, amount, online, true, deed); + } + + private static boolean addTo(String character, String owner, double amount, Player online, boolean multiply, + OccultistHints.Deed deed) { if (!BloodConfig.isEnabled() || amount <= 0) { return false; } @@ -82,13 +91,17 @@ private static boolean addTo(String character, String owner, double amount, Play if (record.getStage() != BloodStage.NONE) { return false; } - double gain = amount * (multiply && fastTraitOf.test(character) ? WhisperConfig.fastMultiplier() : 1); + boolean fast = fastTraitOf.test(character); + double gain = amount * (multiply && fast ? WhisperConfig.fastMultiplier() : 1); record.setWhisper(record.getWhisper() + gain); boolean woke = record.getWhisper() >= WhisperConfig.threshold(); if (woke) { awaken(record, online); } BloodRecords.save(record); + if (!woke && fast && deed != null && online != null) { + OccultistHints.deed(online, deed); + } return woke; } @@ -121,7 +134,13 @@ public static void animalKill(Player killer, Entity animal) { return; } switch (keeper(killer, animal)) { - case OTHERS -> add(killer, WhisperConfig.animalOthers()); + case OTHERS -> { + String character = AltarService.currentCharacter(killer); + if (character != null) { + addTo(character, killer.getUniqueId().toString(), WhisperConfig.animalOthers(), killer, + OccultistHints.Deed.STOLEN_ANIMAL); + } + } case OWN -> ownAnimal(killer); default -> { } } @@ -184,7 +203,7 @@ static void ownAnimal(Player killer) { return; } record.addOwnAnimalWhisper(day, gain); - addTo(character, owner, gain, killer, false); + addTo(character, owner, gain, killer, false, OccultistHints.Deed.OWN_ANIMAL); } static boolean blade(ItemStack item) { @@ -224,13 +243,15 @@ static void tick(MagicTickContext context) { if (record != null && record.getStage() != BloodStage.NONE) { voiceIfDue(player, record); } + OccultistHints.tick(player, character, record); } } private static void tenMinutes(Player player, String character) { double eq = equilibrium.applyAsDouble(player); if (!Double.isNaN(eq) && eq <= WhisperConfig.corruptionBelow()) { - addTo(character, player.getUniqueId().toString(), WhisperConfig.corruption(), player); + addTo(character, player.getUniqueId().toString(), WhisperConfig.corruption(), player, + OccultistHints.Deed.CORRUPTION); } BloodRecord record = BloodRecords.get(character); if (record == null) { @@ -427,6 +448,7 @@ static void give(Player player, ItemStack item) { /** Forget the player's voice timer, e.g. after a quit or a character switch. */ public static void forget(UUID player) { NEXT_VOICE.remove(player); + OccultistHints.forget(player); } /** Lets the next minute tick speak to the player straight away. */ @@ -441,6 +463,7 @@ static Long nextVoice(UUID player) { public static void clear() { NEXT_VOICE.clear(); KEEPERS_AT_DEATH.clear(); + OccultistHints.clear(); } private static double sessionEquilibrium(Player player) { diff --git a/src/main/resources/wildmagic/bloodmagic/voices.yml b/src/main/resources/wildmagic/bloodmagic/voices.yml index 9aabbd4..83d10f2 100644 --- a/src/main/resources/wildmagic/bloodmagic/voices.yml +++ b/src/main/resources/wildmagic/bloodmagic/voices.yml @@ -158,3 +158,47 @@ voices: - "They would call me evil. They'd be right. And far too late." - "Quiet. So quiet. No god, no father. I did it all myself." - "...and in the quiet, something old and patient is smiling. It sounds like me." + +# Faint hints for fast-trait characters (Occultist) whose voices haven't woken yet. They are the +# character's own thoughts, in the own voice's first pale colours, and never name the rules or the god. +# deeds: one line when a deed feeds the meter (and doesn't wake the voices), at most once per +# deed_cooldown_minutes per kind of deed. riddles: one at random, the first a while after joining +# (first_riddle_minutes), then every riddle_interval_minutes, each waiting until nobody else is within +# voices.alone_radius. Minutes count while online; both stop once the voices wake. +hints: + enabled: true + style: "§o" + colors: ["#d8d2e0", "#bdb6c9"] + sound: tfmc_blood:heart + pitch: 1.2 + volume: 0.4 + deed_cooldown_minutes: 60 + first_riddle_minutes: [30, 90] + riddle_interval_minutes: [120, 240] + deeds: + # Killed with a blade an animal another player keeps. + stolen_animal: + - "It wasn't mine, and somehow that made it better. For a moment something far away leaned closer." + - "Someone will find their pen one short tomorrow. Why do I feel so warm?" + # Killed with a blade an animal they keep themselves. + own_animal: + - "Only one of my own. Something far away looked up, and then lost interest." + - "My own beast. It felt like a small gift. Too small." + # A character they killed died for good. + character_kill: + - "They won't get up again. In the stillness afterwards, something very old drew a long breath." + - "A death that stays. The quiet around me listened, and seemed pleased." + # Started robbing, pickpocketing, lockpicking or looting a grave. + robbery: + - "A lock gives, a purse goes light, and something far away smiles at me. I can't explain it." + - "Taking what isn't mine shouldn't feel like being noticed. It does." + # Their magic's equilibrium sank deep. + corruption: + - "My magic has soured, and the sourness feels like company." + riddles: + - "I dreamt of a stone under the earth again. It was dry, and it was waiting. I woke up thirsty." + - "A beast from someone else's pen, taken while its keeper sleeps. Why does the thought warm me?" + - "Most who fall in a fight get up again. It's the ones who never do that I keep thinking about." + - "Locks, purses, graves. Every time I take what isn't mine, the quiet seems to lean closer." + - "The scholars write that a True Vampire named Alaric Thorme taught blood magic once. Who taught him?" + - "Some nights the quiet feels like it's listening for blood that hasn't been spilled yet." diff --git a/src/test/java/net/tfminecraft/magic/blood/OccultistHintsTest.java b/src/test/java/net/tfminecraft/magic/blood/OccultistHintsTest.java new file mode 100644 index 0000000..5a4de46 --- /dev/null +++ b/src/test/java/net/tfminecraft/magic/blood/OccultistHintsTest.java @@ -0,0 +1,220 @@ +package net.tfminecraft.magic.blood; + +import static org.junit.jupiter.api.Assertions.*; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Cow; +import org.bukkit.inventory.ItemStack; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.mockbukkit.mockbukkit.entity.PlayerMock; + +import net.tfminecraft.magic.tick.MagicTickContext; + +class OccultistHintsTest { + private static final long MINUTE = 60_000L; + + @TempDir Path temp; + BloodFixture fx; + final AtomicLong now = new AtomicLong(1_000_000L); + + @BeforeEach + void setup() { + fx = new BloodFixture(temp); + BloodFixture.loadBundled(fx.logger); + WhisperService.clock = now::get; + WhisperService.random = new Random(1); + WhisperService.equilibrium = player -> Double.NaN; + WhisperService.fastTraitOf = character -> true; + } + + @AfterEach + void cleanup() { + WhisperService.clear(); + WhisperService.clock = System::currentTimeMillis; + WhisperService.random = new Random(); + WhisperService.fastTraitOf = WhisperService::fastTrait; + WhisperService.equilibrium = player -> Double.NaN; + FakeHusbandry.restore(); + fx.close(); + } + + static String plain(String message) { + return WhisperServiceTest.plain(message); + } + + static List lines(String path) throws Exception { + org.bukkit.configuration.file.YamlConfiguration yaml = org.bukkit.configuration.file.YamlConfiguration + .loadConfiguration(new java.io.File("src/main/resources/wildmagic/bloodmagic/voices.yml")); + return yaml.getStringList("hints." + path); + } + + void load(String... yaml) throws Exception { + Path file = temp.resolve("hints" + System.nanoTime() + ".yml"); + Files.writeString(file, String.join("\n", yaml) + "\n"); + BloodConfig.load(file.toFile(), fx.logger); + BloodConfig.setEnabled(true); + } + + @Test + void aDeedThatFeedsAnOccultistsMeterGetsAFaintLineOncePerCooldown() throws Exception { + PlayerMock player = fx.player("occultist"); + String id = BloodFixture.id("occultist"); + assertFalse(WhisperService.addTo(id, "o", 4, player, OccultistHints.Deed.ROBBERY)); + assertEquals(12, BloodRecords.get(id).getWhisper(), "still tripled"); + String line = player.nextMessage(); + assertTrue(lines("deeds.robbery").contains(plain(line)), line); + assertTrue(line.contains("§o"), "in the hints' style"); + player.assertSoundHeard("tfmc_blood:heart"); + + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + assertNull(player.nextMessage(), "the same deed waits out its cooldown"); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.CHARACTER_KILL); + assertTrue(lines("deeds.character_kill").contains(plain(player.nextMessage())), "another deed has its own"); + now.addAndGet(60 * MINUTE); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + assertNotNull(player.nextMessage(), "after the cooldown"); + } + + @Test + void noHintWithoutTheTraitADeedAPlayerOrWhenTheVoicesWake() { + PlayerMock player = fx.player("occultist"); + String id = BloodFixture.id("occultist"); + WhisperService.addTo(id, "o", 1, player); + assertNull(player.nextMessage(), "staff additions are no deed"); + WhisperService.addTo(id, "o", 1, null, OccultistHints.Deed.ROBBERY); + WhisperService.fastTraitOf = character -> false; + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + assertNull(player.nextMessage(), "no fast trait"); + WhisperService.fastTraitOf = character -> true; + assertTrue(WhisperService.addTo(id, "o", 30, player, OccultistHints.Deed.ROBBERY)); + assertNull(player.nextMessage(), "the voices take over"); + WhisperService.addTo(id, "o", 30, player, OccultistHints.Deed.ROBBERY); + assertNull(player.nextMessage(), "awake: the meter no longer fills"); + } + + @Test + void eachDeedSourceNamesItsDeed() throws Exception { + FakeHusbandry.use(); + PlayerMock player = fx.player("occultist"); + PlayerMock bare = fx.server.addPlayer(); + player.getInventory().setItemInMainHand(new ItemStack(Material.IRON_SWORD)); + bare.getInventory().setItemInMainHand(new ItemStack(Material.IRON_SWORD)); + Cow cow = fx.world.spawn(player.getLocation(), Cow.class); + WhisperServiceTest.keep(cow, java.util.UUID.randomUUID()); + WhisperService.animalKill(bare, cow); + assertNull(bare.nextMessage(), "no character, nothing"); + WhisperService.animalKill(player, cow); + assertTrue(lines("deeds.stolen_animal").contains(plain(player.nextMessage()))); + WhisperServiceTest.keep(cow, player.getUniqueId()); + WhisperService.animalKill(player, cow); + assertTrue(lines("deeds.own_animal").contains(plain(player.nextMessage()))); + + WhisperService.equilibrium = p -> -50; + WhisperService.tick(MagicTickContext.between(599, 600)); + assertTrue(lines("deeds.corruption").contains(plain(player.nextMessage()))); + } + + @Test + void riddlesComeRarelyWhenAloneAndStopOnceTheVoicesWake() throws Exception { + PlayerMock player = fx.player("occultist"); + String id = BloodFixture.id("occultist"); + OccultistHints.tick(player, id, null); + long due = OccultistHints.nextRiddle(player.getUniqueId()); + assertTrue(due >= now.get() + 30 * MINUTE && due <= now.get() + 90 * MINUTE, "first a while after joining"); + OccultistHints.tick(player, id, null); + assertNull(player.nextMessage(), "not yet"); + + now.set(due); + PlayerMock witness = fx.server.addPlayer(); + witness.teleport(player.getLocation()); + OccultistHints.tick(player, id, null); + assertNull(player.nextMessage(), "waits until nobody is near"); + witness.teleport(new Location(fx.world, 500, 11, 500)); + OccultistHints.tick(player, id, BloodRecords.getOrCreate(id, "o")); + assertTrue(lines("riddles").contains(plain(player.nextMessage()))); + long next = OccultistHints.nextRiddle(player.getUniqueId()); + assertTrue(next >= now.get() + 120 * MINUTE && next <= now.get() + 240 * MINUTE, "then every few hours"); + + now.set(next); + WhisperService.fastTraitOf = character -> false; + OccultistHints.tick(player, id, null); + assertNull(player.nextMessage(), "no fast trait, no riddle"); + assertTrue(OccultistHints.nextRiddle(player.getUniqueId()) > now.get(), "checked again an interval later"); + + OccultistHints.tick(player, id, fx.record("occultist", BloodStage.WHISPERED)); + assertNull(OccultistHints.nextRiddle(player.getUniqueId()), "the voices woke"); + OccultistHints.tick(player, id, null); + WhisperService.forget(player.getUniqueId()); + assertNull(OccultistHints.nextRiddle(player.getUniqueId()), "a quit or switch forgets the timer"); + } + + @Test + void theMinuteTickRunsTheRiddles() { + PlayerMock player = fx.player("occultist"); + WhisperService.tick(MagicTickContext.between(59, 60)); + assertNotNull(OccultistHints.nextRiddle(player.getUniqueId())); + WhisperService.clear(); + assertNull(OccultistHints.nextRiddle(player.getUniqueId())); + } + + @Test + void settingsCanSwitchOffRecolourAndRetimeTheHints() throws Exception { + java.util.List warnings = new java.util.ArrayList<>(); + fx.logger.addHandler(new Handler() { + @Override public void publish(LogRecord record) { warnings.add(record.getMessage()); } + @Override public void flush() { } + @Override public void close() { } + }); + PlayerMock player = fx.player("occultist"); + String id = BloodFixture.id("occultist"); + + load("hints:", " colors: [red, '#112233']", " sound: ''", " deed_cooldown_minutes: 0", + " first_riddle_minutes: [5, 1]", " riddle_interval_minutes: [3]", + " deeds:", " robbery: [taken]", " riddles: [hush]"); + assertTrue(warnings.stream().anyMatch(w -> w.contains("hints.colors"))); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + assertEquals("taken", plain(player.nextMessage())); + assertEquals("taken", plain(player.nextMessage()), "no cooldown"); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.CHARACTER_KILL); + assertNull(player.nextMessage(), "a deed without lines says nothing"); + OccultistHints.tick(player, id, null); + long due = OccultistHints.nextRiddle(player.getUniqueId()); + assertTrue(due >= now.get() + MINUTE && due <= now.get() + 5 * MINUTE, "reversed range is sorted"); + now.set(due); + OccultistHints.tick(player, id, null); + assertEquals("hush", plain(player.nextMessage())); + long next = OccultistHints.nextRiddle(player.getUniqueId()); + assertTrue(next >= now.get() + 120 * MINUTE, "a range that isn't two numbers keeps the default"); + + load("hints:", " style: '§o'", " deeds:", " robbery: [plain]"); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + String line = player.nextMessage(); + assertEquals("plain", plain(line)); + assertTrue(line.startsWith("§o"), "without colours the style leads: " + line); + OccultistHints.tick(player, id, null); + assertNull(OccultistHints.nextRiddle(player.getUniqueId()), "no riddles, no timer"); + + load("hints:", " enabled: false", " deeds:", " robbery: [off]", " riddles: [off]"); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + OccultistHints.tick(player, id, null); + assertNull(player.nextMessage()); + assertNull(OccultistHints.nextRiddle(player.getUniqueId())); + + load("enabled: true"); + WhisperService.addTo(id, "o", 1, player, OccultistHints.Deed.ROBBERY); + assertNull(player.nextMessage(), "no hints section: nothing to say"); + } +}