Add ready state to sign templates.
Adds support for a new `ready` state in the template engine for arena signs. A sign is in the `ready` state when there are players in the lobby and all of them have readied up. This is only relevant in arenas with start delay timers, as the arena session automatically starts when all players are ready otherwise. The new state is completely optional, even when no base state is provided, and it inherits from the `joining` state when not defined. Closes #593
This commit is contained in:
committed by
Andreas Troelsen
parent
5f7be69f0f
commit
90d1f211fa
@@ -95,6 +95,47 @@ public class RendersTemplateTest {
|
||||
assertThat(result, equalTo(joining));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readyOverridesLobbyIfPlayersReady() {
|
||||
Player ready = mock(Player.class);
|
||||
Arena arena = mock(Arena.class);
|
||||
when(arena.configName()).thenReturn("castle");
|
||||
when(arena.isRunning()).thenReturn(false);
|
||||
when(arena.getPlayersInLobby()).thenReturn(Collections.singleton(ready));
|
||||
when(arena.getNonreadyPlayers()).thenReturn(Collections.emptyList());
|
||||
when(arena.getReadyPlayersInLobby()).thenReturn(Collections.singleton(ready));
|
||||
String[] readyTemplate = {"we", "are", "all", "ready"};
|
||||
Template template = new Template.Builder("template")
|
||||
.withBase(new String[]{"this", "is", "the", "base"})
|
||||
.withJoining(new String[]{"joining", "template", "is", "here"})
|
||||
.withReady(readyTemplate)
|
||||
.build();
|
||||
|
||||
String[] result = subject.render(template, arena);
|
||||
|
||||
assertThat(result, equalTo(readyTemplate));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readyPlayersReturnsJoiningIfNotDefined() {
|
||||
Player ready = mock(Player.class);
|
||||
Arena arena = mock(Arena.class);
|
||||
when(arena.configName()).thenReturn("castle");
|
||||
when(arena.isRunning()).thenReturn(false);
|
||||
when(arena.getPlayersInLobby()).thenReturn(Collections.singleton(ready));
|
||||
when(arena.getNonreadyPlayers()).thenReturn(Collections.emptyList());
|
||||
when(arena.getReadyPlayersInLobby()).thenReturn(Collections.singleton(ready));
|
||||
String[] joining = {"we", "in", "da", "lobby"};
|
||||
Template template = new Template.Builder("template")
|
||||
.withBase(new String[]{"this", "is", "the", "base"})
|
||||
.withJoining(joining)
|
||||
.build();
|
||||
|
||||
String[] result = subject.render(template, arena);
|
||||
|
||||
assertThat(result, equalTo(joining));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rendersReadyListEntries() {
|
||||
Player ready = mock(Player.class);
|
||||
|
||||
Reference in New Issue
Block a user