Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
680 B
32 lines
680 B
package org.openrs2.util
|
|
|
|
import org.openrs2.util.charset.Cp1252Charset
|
|
|
|
public fun CharSequence.indefiniteArticle(): String {
|
|
require(isNotEmpty())
|
|
|
|
return when (first().lowercaseChar()) {
|
|
'a', 'e', 'i', 'o', 'u' -> "an"
|
|
else -> "a"
|
|
}
|
|
}
|
|
|
|
public fun CharSequence.krHashCode(): Int {
|
|
var hash = 0
|
|
for (c in this) {
|
|
hash = ((hash shl 5) - hash) + Cp1252Charset.encode(c)
|
|
}
|
|
return hash
|
|
}
|
|
|
|
public fun CharSequence.jagHashCode(): Int {
|
|
var hash = 0
|
|
for (c in this) {
|
|
hash = (hash * 61) + (c.code - 32)
|
|
}
|
|
return hash
|
|
}
|
|
|
|
public fun String.capitalize(): String {
|
|
return replaceFirstChar { it.titlecase() }
|
|
}
|
|
|