diff --git a/build.gradle b/build.gradle index 447d712a..561c9db8 100644 --- a/build.gradle +++ b/build.gradle @@ -60,7 +60,7 @@ configure(subprojects - project(':android')) { subprojects { version = '2.0.0-beta' ext.appName = 'Terminal Control 2' - ext.buildVersion = 8 + ext.buildVersion = 9 repositories { mavenCentral() maven { url 'https://s01.oss.sonatype.org' } diff --git a/core/src/main/kotlin/com/bombbird/terminalcontrol2/traffic/TrafficTools.kt b/core/src/main/kotlin/com/bombbird/terminalcontrol2/traffic/TrafficTools.kt index ba99f805..99aed9ec 100644 --- a/core/src/main/kotlin/com/bombbird/terminalcontrol2/traffic/TrafficTools.kt +++ b/core/src/main/kotlin/com/bombbird/terminalcontrol2/traffic/TrafficTools.kt @@ -708,9 +708,9 @@ fun calculateAdditionalTimeToNextDeparture(backlog: Int, maxAdvDep: Int): Int { val threshold1 = (maxAdvDep * 0.5f).roundToInt() return when { backlog >= 10 -> 0 - backlog >= -threshold1 -> 0 + 120 * (10 - backlog) / (10 + threshold1) - backlog >= -maxAdvDep -> 120 + (320 - 120) * (-threshold1 - backlog) / (maxAdvDep - threshold1) - else -> 320 + backlog >= -threshold1 -> 0 + 240 * (10 - backlog) / (10 + threshold1) + backlog >= -maxAdvDep -> 240 + (640 - 240) * (-threshold1 - backlog) / (maxAdvDep - threshold1) + else -> 640 } } diff --git a/core/src/test/kotlin/TrafficToolsTest.kt b/core/src/test/kotlin/TrafficToolsTest.kt index e49fa09b..6bcd5ce3 100644 --- a/core/src/test/kotlin/TrafficToolsTest.kt +++ b/core/src/test/kotlin/TrafficToolsTest.kt @@ -9,16 +9,16 @@ object TrafficToolsTest: FunSpec() { calculateAdditionalTimeToNextDeparture(24, 40) shouldBe 0 calculateAdditionalTimeToNextDeparture(15, 40) shouldBe 0 calculateAdditionalTimeToNextDeparture(10, 40) shouldBe 0 - calculateAdditionalTimeToNextDeparture(3, 40) shouldBe 28 - calculateAdditionalTimeToNextDeparture(-14, 40) shouldBe 96 - calculateAdditionalTimeToNextDeparture(-6, 20) shouldBe 96 - calculateAdditionalTimeToNextDeparture(-20, 40) shouldBe 120 - calculateAdditionalTimeToNextDeparture(-29, 40) shouldBe 210 - calculateAdditionalTimeToNextDeparture(-58, 80) shouldBe 210 - calculateAdditionalTimeToNextDeparture(-40, 40) shouldBe 320 - calculateAdditionalTimeToNextDeparture(-47, 40) shouldBe 320 - calculateAdditionalTimeToNextDeparture(-30, 20) shouldBe 320 - calculateAdditionalTimeToNextDeparture(-15, 10) shouldBe 320 + calculateAdditionalTimeToNextDeparture(3, 40) shouldBe 56 + calculateAdditionalTimeToNextDeparture(-14, 40) shouldBe 192 + calculateAdditionalTimeToNextDeparture(-6, 20) shouldBe 192 + calculateAdditionalTimeToNextDeparture(-20, 40) shouldBe 240 + calculateAdditionalTimeToNextDeparture(-29, 40) shouldBe 420 + calculateAdditionalTimeToNextDeparture(-58, 80) shouldBe 420 + calculateAdditionalTimeToNextDeparture(-40, 40) shouldBe 640 + calculateAdditionalTimeToNextDeparture(-47, 40) shouldBe 640 + calculateAdditionalTimeToNextDeparture(-30, 20) shouldBe 640 + calculateAdditionalTimeToNextDeparture(-15, 10) shouldBe 640 } } }