feat(io): GameIO music seams; push room track per turn, silence at menu
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -143,5 +143,6 @@ public final class App {
|
|||||||
new LookCommand().execute(ctx, List.of());
|
new LookCommand().execute(ctx, List.of());
|
||||||
|
|
||||||
game.run();
|
game.run();
|
||||||
|
io.setMusic(null); // fade music out when returning to the menu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class Game {
|
|||||||
ctx.getPlayer().getCurrentRoom());
|
ctx.getPlayer().getCurrentRoom());
|
||||||
ctx.getIo().setMap(map);
|
ctx.getIo().setMap(map);
|
||||||
ctx.getIo().setQuests(QuestEngine.viewOf(ctx));
|
ctx.getIo().setQuests(QuestEngine.viewOf(ctx));
|
||||||
|
ctx.getIo().setMusic(ctx.getPlayer().getCurrentRoom().getMusic());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,6 +65,16 @@ public interface GameIO {
|
|||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Per-turn current-room music track; null/blank = silence. Console no-op; GUI plays. */
|
||||||
|
default void setMusic(String track) {
|
||||||
|
// no audio in text mode
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Applies the music volume/level. Console no-op; GUI sets it. */
|
||||||
|
default void setMusicLevel(MusicLevel level) {
|
||||||
|
// no audio in text mode
|
||||||
|
}
|
||||||
|
|
||||||
/** On-demand quest log (the 'quests' command). Default renders styled text. */
|
/** On-demand quest log (the 'quests' command). Default renders styled text. */
|
||||||
default void showQuests(QuestView view) {
|
default void showQuests(QuestView view) {
|
||||||
print(QuestText.render(view));
|
print(QuestText.render(view));
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package thb.jeanluc.adventure.io;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class MusicSeamDefaultTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void defaultMusicSeamsAreSilentNoOps() {
|
||||||
|
TestIO io = new TestIO();
|
||||||
|
io.setMusic("anything.ogg");
|
||||||
|
io.setMusic(null);
|
||||||
|
io.setMusicLevel(MusicLevel.HIGH);
|
||||||
|
assertThat(io.outputs()).isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user