package me.msoucy.ptures.model

import me.msoucy.ptures.controller.Engine

sealed class Status {

    open fun onTurnStart(creature: Creature) {
        // Do nothing
    }

    open fun onAdd(creature: Creature) {
        // Do nothing
    }

    open fun onTurnEnd(creature: Creature) {
        // Do nothing
    }

    open fun attackMod(creature: Creature) = 1.0
    open fun defenseMod(creature: Creature) = 1.0
}

sealed class VisibleStatus(val label: String = "") : Status()

sealed class CountdownStatus(private var turns: Int) : Status() {
    override fun onTurnEnd(creature: Creature) {
        turns--
        if (turns == 0) {
            onCountdownReached(creature)
            creature.removeStatus(this)
        }
    }

    open fun onCountdownReached(creature: Creature) {
    }
}

object KnockedOut : VisibleStatus("ko")
object Burned : VisibleStatus("burned") {
    override fun onTurnEnd(creature : Creature) {
        // Deal a small amount of damage
    }
}

object Stunned : VisibleStatus("stunned")
object Poisoned : VisibleStatus("poisoned")
class Flying(private vararg val targets : Creature) : CountdownStatus(1) {
    override fun onCountdownReached(creature: Creature) {
        super.onCountdownReached(creature)
        creature.activeSkill = SkillChoice(Skills.Fly2, targets.toList())
    }
}
