/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.royaldev.fictitious.cards

import xyz.cardstock.cardstock.extensions.string.get

enum class Gender(val representation: Char) {
    MALE('m'),
    FEMALE('f'),
    TRANSGENDER('t'),
    NONGENDERED('/'),
    TETRIS_BAR('|');

    override fun toString(): String {
        val name = name.toLowerCase().replace('_', ' ')
        if (name.length < 2) return name.toUpperCase()
        return name[0].toUpperCase() + name[1, null]
    }

    companion object {
        fun byRepresentation(representation: Char): Gender? = Gender.values.firstOrNull { it.representation == representation }
    }
}
