package me.msoucy.ptures.model

import com.badlogic.gdx.math.MathUtils.clamp

class Stats(var atk : Int, var def : Int, var spd : Int, var hp : Int)

class Creature {
    var genes = Stats(5,5,5,5)
    var growth = Stats(5,5,5,5)
    var level = 1
    var currentHp = 1
    val statuses = mutableListOf<Status>()

    val atk : Int get() = statFormula(genes.atk, growth.atk)
    val def : Int get() = statFormula(genes.atk, growth.atk)
    val spd : Int get() = statFormula(genes.atk, growth.atk)
    val maxHp : Int get() = statFormula(genes.atk, growth.atk)

    fun apply(dmg : Damage) {
        currentHp = clamp(currentHp - dmg.power, 0, maxHp)
    }

    fun addStatus(status : Status) {
        if(status !in statuses)
        {
            statuses.add(status)
            status.onAdd(this)
        }
    }

    fun removeStatus(status : Status) {
        statuses.remove(status)
    }

    fun fullHeal() {
        currentHp = maxHp
        statuses.clear()
    }

    private fun statFormula(gene : Int, growth : Int) = (2 * gene + growth) * level / 100 + 5
}