package me.msoucy.ptures.model

@DslMarker
annotation class SkillMarker

enum class Target {
    Selected,
    Self,
    Others,
    Opponents,
    All
}

enum class Attribute {
    Neutral,
    Stone,
    Fire,
    Water,
    Air,
    Wood
}

class Damage(val power : Int) {
    var target = Target.Selected
    var accuracy = 100
}

@SkillMarker
class Skill(val name : String, val attribute : Attribute) {
    val preSteps = mutableListOf<Pair<Status, Target>>()
    val damageSteps = mutableListOf<Damage>()
    val postSteps = mutableListOf<Pair<Status, Target>>()

    fun damage(power : Int, block : Damage.() -> Unit = {}) {
        val d = Damage(power)
        d.block()
        damageSteps.add(d)
    }

    fun addStatus(status : Status, target : Target = Target.Selected) {
        postSteps.add(Pair(status, target))
    }
}

fun skill(name : String, attribute : Attribute = Attribute.Neutral, block : Skill.() -> Unit) : Skill {
    val ret = Skill(name, attribute)
    ret.block()
    return ret
}

val Tackle = skill("Tackle") {
    damage(20)
}

val DoubleKick = skill("Double Kick") {
    repeat(2) {
        damage(35) {
            accuracy = 85
        }
    }
}

val DoubleEdge = skill("Double Edge") {
    damage(20)
    damage(10) {
        target = Target.Self
    }
}

val Fly = skill("Fly") {
    addStatus(Flying(), Target.Self)
}