diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-19 20:18:39 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-19 20:18:39 +0100 |
commit | eda44cb8743c709c15a7ed03381d05e43728e647 (patch) | |
tree | 557a3bd4f096584158b46921f4826208396b4baa /src/main/kotlin/moe/nea/ledger/NumberUtil.kt | |
parent | a046b198645811fe1b7db129942505c379aabb03 (diff) | |
download | LocalTransactionLedger-eda44cb8743c709c15a7ed03381d05e43728e647.tar.gz LocalTransactionLedger-eda44cb8743c709c15a7ed03381d05e43728e647.tar.bz2 LocalTransactionLedger-eda44cb8743c709c15a7ed03381d05e43728e647.zip |
feat: Add corpse loot detection
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/NumberUtil.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/NumberUtil.kt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/NumberUtil.kt b/src/main/kotlin/moe/nea/ledger/NumberUtil.kt index 008cfbf..438f342 100644 --- a/src/main/kotlin/moe/nea/ledger/NumberUtil.kt +++ b/src/main/kotlin/moe/nea/ledger/NumberUtil.kt @@ -75,9 +75,17 @@ fun parseShortNumber(string: String): Double { return k.toDouble() * scalarMultiplier } +fun Pattern.matches(string: String): Boolean = matcher(string).matches() inline fun <T> Pattern.useMatcher(string: String, block: Matcher.() -> T): T? = matcher(string).takeIf { it.matches() }?.let(block) +fun <T> String.ifDropLast(suffix: String, block: (String) -> T): T? { + if (endsWith(suffix)) { + return block(dropLast(suffix.length)) + } + return null +} + fun String.unformattedString(): String = replace("§.".toRegex(), "") val timeFormat: DateTimeFormatter = DateTimeFormatterBuilder() |