timers: Fix inferno timer starting time
This commit is contained in:
@@ -119,8 +119,8 @@ public class TimersPlugin extends Plugin
|
||||
private static final int VENOM_VALUE_CUTOFF = -40; // Antivenom < -40 <= Antipoison < 0
|
||||
private static final int POISON_TICK_LENGTH = 30;
|
||||
|
||||
private static final int FIGHT_CAVES_REGION_ID = 9551;
|
||||
private static final int INFERNO_REGION_ID = 9043;
|
||||
static final int FIGHT_CAVES_REGION_ID = 9551;
|
||||
static final int INFERNO_REGION_ID = 9043;
|
||||
private static final Pattern TZHAAR_WAVE_MESSAGE = Pattern.compile("Wave: (\\d+)");
|
||||
private static final String TZHAAR_DEFEATED_MESSAGE = "You have been defeated!";
|
||||
private static final Pattern TZHAAR_COMPLETE_MESSAGE = Pattern.compile("Your (TzTok-Jad|TzKal-Zuk) kill count is:");
|
||||
@@ -679,7 +679,16 @@ public class TimersPlugin extends Plugin
|
||||
int wave = Integer.parseInt(matcher.group(1));
|
||||
if (wave == 1)
|
||||
{
|
||||
config.tzhaarStartTime(now);
|
||||
if (isInInferno())
|
||||
{
|
||||
// The first wave message of the inferno comes six seconds after the ingame timer starts counting
|
||||
config.tzhaarStartTime(now.minus(Duration.ofSeconds(6)));
|
||||
}
|
||||
else
|
||||
{
|
||||
config.tzhaarStartTime(now);
|
||||
}
|
||||
|
||||
createTzhaarTimer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,6 @@ import org.mockito.stubbing.Answer;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TimersPluginTest
|
||||
{
|
||||
private static final int FIGHT_CAVES_REGION_ID = 9551;
|
||||
|
||||
@Inject
|
||||
private TimersPlugin timersPlugin;
|
||||
|
||||
@@ -270,7 +268,7 @@ public class TimersPluginTest
|
||||
public void testTzhaarTimer()
|
||||
{
|
||||
when(timersConfig.showTzhaarTimers()).thenReturn(true);
|
||||
when(client.getMapRegions()).thenReturn(new int[]{FIGHT_CAVES_REGION_ID});
|
||||
when(client.getMapRegions()).thenReturn(new int[]{TimersPlugin.FIGHT_CAVES_REGION_ID});
|
||||
|
||||
class InstantRef
|
||||
{
|
||||
@@ -327,4 +325,34 @@ public class TimersPluginTest
|
||||
verify(infoBoxManager, times(3)).removeInfoBox(captor.capture());
|
||||
verify(infoBoxManager, times(3)).addInfoBox(captor.capture());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfernoTimerStartOffset()
|
||||
{
|
||||
when(timersConfig.showTzhaarTimers()).thenReturn(true);
|
||||
when(client.getMapRegions()).thenReturn(new int[]{TimersPlugin.INFERNO_REGION_ID});
|
||||
|
||||
class InstantRef
|
||||
{
|
||||
Instant i;
|
||||
}
|
||||
|
||||
InstantRef startTime = new InstantRef();
|
||||
when(timersConfig.tzhaarStartTime()).then(a -> startTime.i);
|
||||
doAnswer((Answer<Void>) invocationOnMock ->
|
||||
{
|
||||
Object argument = invocationOnMock.getArguments()[0];
|
||||
startTime.i = (Instant) argument;
|
||||
return null;
|
||||
}).when(timersConfig).tzhaarStartTime(nullable(Instant.class));
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", "<col=ef1020>Wave: 1</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager, times(1)).addInfoBox(captor.capture());
|
||||
assertTrue(captor.getValue() instanceof ElapsedTimer);
|
||||
ElapsedTimer timer = (ElapsedTimer) captor.getValue();
|
||||
assertEquals("00:06", timer.getText());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user