package pt.epvc.roleta.logic

data class Prize(
    val id: Int,
    val text: String,
    val weight: Double,
    val colorHex: String
)

object PrizeLogic {
    val prizes = listOf(
        Prize(1, "Tenta novamente", 13.33, "#4F46E5"),
        Prize(2, "Fica para a próxima", 12.5, "#06B6D4"),
        Prize(3, "Um chapéu", 1.5, "#10B981"),
        Prize(4, "Uma caneta", 8.0, "#F59E0B"),
        Prize(5, "Tenta novamente", 13.33, "#EC4899"),
        Prize(6, "Tenta novamente", 13.34, "#4F46E5"),
        Prize(7, "Fica para a próxima", 12.5, "#06B6D4"),
        Prize(8, "Uma garrafa", 7.0, "#10B981"),
        Prize(9, "Um porta-lápis", 3.5, "#F59E0B"),
        Prize(10, "Um lápis", 15.0, "#EC4899")
    )

    fun getRandomPrize(): Prize {
        val totalWeight = prizes.sumOf { it.weight }
        val randomValue = Math.random() * totalWeight
        var cumulativeWeight = 0.0

        for (prize in prizes) {
            cumulativeWeight += prize.weight
            if (randomValue <= cumulativeWeight) {
                return prize
            }
        }
        return prizes.last()
    }
}
