fix(teleport): enforce visitor warm-up
This commit is contained in:
@@ -95,7 +95,7 @@ final class BaseTeleportManager implements Listener {
|
||||
begin(
|
||||
visitor,
|
||||
owner.base().orElseThrow(),
|
||||
policy.warmup(owner),
|
||||
policy.visitorWarmup(owner),
|
||||
owner.playerId(),
|
||||
policy.cooldown(owner),
|
||||
"visit " + owner.latestName() + "'s base"
|
||||
|
||||
@@ -25,6 +25,13 @@ public final class TeleportPolicy {
|
||||
};
|
||||
}
|
||||
|
||||
public Duration visitorWarmup(PlayerState owner) {
|
||||
Duration warmup = warmup(owner);
|
||||
return warmup.compareTo(Duration.ofSeconds(1)) < 0
|
||||
? Duration.ofSeconds(1)
|
||||
: warmup;
|
||||
}
|
||||
|
||||
public Duration cooldown(PlayerState player) {
|
||||
return switch (player.cooldownLevel()) {
|
||||
case 0 -> Duration.ofSeconds(settings.current().initialTeleportCooldownSeconds());
|
||||
|
||||
@@ -22,6 +22,17 @@ final class TeleportPolicyTest {
|
||||
assertEquals(Duration.ZERO, policy.warmup(player.withTeleportLevels(3, 0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void visitorWarmupHasOneSecondMinimum() {
|
||||
PlayerState player = baseThreePlayer();
|
||||
|
||||
assertEquals(Duration.ofSeconds(30), policy.visitorWarmup(player));
|
||||
assertEquals(
|
||||
Duration.ofSeconds(1),
|
||||
policy.visitorWarmup(player.withTeleportLevels(3, 0))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cooldownLevelsUseApprovedDurations() {
|
||||
PlayerState player = baseThreePlayer();
|
||||
|
||||
Reference in New Issue
Block a user