@file:JvmName("Utils")
package benzm.yugiohlifepointcounter.util


fun toStringWithSign(number: Int): String {
    val str = number.toString()
    if (number > 0)
        return "+$number"
    return str
}

fun extractChars(str: String, chars: String): String {
    var result = ""
    for (c in str) {
        if (chars.contains(c))
            result += c
    }
    return result
}

fun isOperation(op: String): Boolean {
    return op == "+" || op == "-" || op == "x" || op == "/"
}

fun isOperation(op: Char): Boolean {
    return isOperation(op.toString())
}

fun Int.toStringPrefixSign(): String {
    if (this <= 0)
        return this.toString()
    return "+$this"
}
fun String.toIntPrefixSign(): Int {
    if (this.isBlank())
        return 0
    if (this[0] == '+')
        return this.substring(1).toInt()
    return this.toInt()
}