package ru.dbotthepony.mc.otm.config

import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem

object ToolsConfig : AbstractConfig("tools") {
	val AXES_BREAK_LEAVES_INSTANTLY: Boolean by builder.define("AXES_BREAK_LEAVES_INSTANTLY", true)

	init {
		EnergySwordItem.registerConfig(builder)
	}

	object ExplosiveHammer {
		val MAX_TRAVEL: Double by builder
			.comment("Max distance, in blocks, the nail can travel", "This also dictates potential max damage nail can deal (controlled by TRAVEL_DAMAGE_MULT)")
			.comment("The nail penetrate through blocks and entities, losing power in process")
			.comment("The nail can not travel into unloaded chunks and will stop immediately if it does so")
			.comment("The nail travels its entire path instantaneously")
			.defineInRange("MAX_TRAVEL", 64.0, 0.0, Double.MAX_VALUE)

		val TRAVEL_EXPLOSION_RESIST_MULT: Double by builder
			.comment("Multiplier of explosion resistance of blocks on nail path")
			.comment("If explosion resistance multiplied by this is bigger than nail current force (base of MAX_TRAVEL)")
			.comment("then nail movement halts, otherwise nail force is reduced by explosion resistance multiplied by this")
			.comment("and block is broken (if DAMAGE_BLOCKS is true, otherwise it only acts as stopping power)")
			.comment("---")
			.comment("Values over 1 will make blocks more resistant to be penetrated through (and broken)")
			.comment("Values below 1 will make blocks less resistant to be penetrated though (and broken)")
			.comment("Value of 0 means no matter how strong block resistance is, it will be broken by nail", "(this includes bedrock!!!)")
			.comment("---")
			.defineInRange("TRAVEL_EXPLOSION_RESIST_MULT", 1.75, 0.0, Double.MAX_VALUE)

		val TRAVEL_DAMAGE_MULT: Double by builder
			.comment("Multiplier of current nail force (base of MAX_TRAVEL) for damage values")
			.comment("That is, any being on path of nail will get damaged by nail power multiplied by this")
			.defineInRange("TRAVEL_DAMAGE_MULT", 0.5, 0.0, Double.MAX_VALUE)

		val TRAVEL_MAX_HEALTH_MULT: Double by builder
			.comment("Multiplier of being's max health in nail path subtracted from nail force when penetrating through")
			.defineInRange("TRAVEL_MAX_HEALTH_MULT", 0.5, 0.0, Double.MAX_VALUE)

		val DAMAGE_BLOCKS: Boolean by builder
			.comment("Should hammer (**not** explosion) damage blocks", "Blocks damaged this way will always be dropped")
			.define("DAMAGE_BLOCKS", true)

		val EXPLOSION_DAMAGE_BLOCKS: Boolean by builder
			.comment("Should hammer **explosion** damage blocks")
			.define("EXPLOSION_DAMAGE_BLOCKS", false)

		val FLY_OFF_CHANCE: Double by builder
			.comment("Chance that hammer will fly off hands of attacker upon impact")
			.defineInRange("FLY_OFF_CHANCE", 0.4, 0.0, 1.0)

		val SELF_HARM_CHANCE: Double by builder
			.comment("When hammer DOES NOT fly off hands, what is chance of it damaging the user?", "(this does not account for damage because of hitting things close)", "(idiot)")
			.defineInRange("SELF_HARM_CHANCE", 0.25, 0.0, 1.0)

		val SELF_HARM_MIN_DAMAGE: Double by builder
			.comment("When hammer DOES NOT fly off hands, what is minimal damage it deals to the user (in half of hearts)?")
			.defineInRange("SELF_HARM_MIN_DAMAGE", 2.0, 0.0, Double.MAX_VALUE)

		val SELF_HARM_MAX_DAMAGE: Double by builder
			.comment("When hammer DOES NOT fly off hands, what is maximal damage it deals to the user (in half of hearts)?")
			.defineInRange("SELF_HARM_MAX_DAMAGE", 10.0, 0.0, Double.MAX_VALUE)

		val FLY_OFF_DAMAGE_CHANCE: Double by builder
			.comment("When hammer flies off hands, what is chance of it damaging the user?")
			.defineInRange("FLY_OFF_DAMAGE_CHANCE", 0.4, 0.0, 1.0)

		val FLY_OFF_MIN_DAMAGE: Double by builder
			.comment("When hammer flies off hands, what is minimal damage it deals to the user (in half of hearts)?")
			.defineInRange("FLY_OFF_MIN_DAMAGE", 4.0, 0.0, Double.MAX_VALUE)

		val FLY_OFF_MAX_DAMAGE: Double by builder
			.comment("When hammer flies off hands, what is maximal damage it deals to the user (in half of hearts)?")
			.defineInRange("FLY_OFF_MAX_DAMAGE", 20.0, 0.0, Double.MAX_VALUE)
	}

	init {
		builder.push("ExplosiveHammer")
		ExplosiveHammer
		builder.pop()
	}
}
