From eda44cb8743c709c15a7ed03381d05e43728e647 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 19 Dec 2024 20:18:39 +0100 Subject: feat: Add corpse loot detection --- src/main/kotlin/moe/nea/ledger/NumberUtil.kt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main/kotlin/moe/nea/ledger/NumberUtil.kt') 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 Pattern.useMatcher(string: String, block: Matcher.() -> T): T? = matcher(string).takeIf { it.matches() }?.let(block) +fun 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() -- cgit