-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #407 from fmasa/fix-auto-success
Fix autosuccess/autofailure SL calculation
- Loading branch information
Showing
2 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...commonTest/kotlin/cz/frantisekmasa/wfrp_master/common/core/domain/rolls/TestResultTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cz.frantisekmasa.wfrp_master.common.core.domain.rolls | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
|
||
class TestResultTest { | ||
@Test | ||
fun `rolling 100 is fumble`() { | ||
val testResult = TestResult(100, 60) | ||
assertTrue(testResult.isFumble) | ||
} | ||
|
||
@Test | ||
fun `rolling under tested value is success`() { | ||
val testResult = TestResult(9, 60) | ||
assertEquals("+6", testResult.successLevelText) | ||
} | ||
|
||
@Test | ||
fun `rolling exactly the value is success`() { | ||
val testResult = TestResult(60, 60) | ||
assertEquals("+0", testResult.successLevelText) | ||
} | ||
|
||
@Test | ||
fun `rolling bellow auto success threshold is success`() { | ||
assertEquals("+2", TestResult(5, 25).successLevelText) | ||
assertEquals("+1", TestResult(5, 6).successLevelText) | ||
assertEquals("+1", TestResult(5, 1).successLevelText) | ||
} | ||
|
||
@Test | ||
fun `rolling double under tested value is critical`() { | ||
val testResult = TestResult(11, 60) | ||
assertTrue(testResult.isCritical) | ||
} | ||
|
||
@Test | ||
fun `rolling over value is failure`() { | ||
val testResult = TestResult(16, 15) | ||
assertEquals("-0", testResult.successLevelText) | ||
} | ||
|
||
@Test | ||
fun `rolling above auto failure threshold is success`() { | ||
assertEquals("-2", TestResult(96, 70).successLevelText) | ||
assertEquals("-1", TestResult(96, 97).successLevelText) | ||
assertEquals("-1", TestResult(96, 95).successLevelText) | ||
} | ||
|
||
@Test | ||
fun `rolling double over roll value is fumble`() { | ||
val testResult = TestResult(77, 70) | ||
assertTrue(testResult.isFumble) | ||
} | ||
} |