package ru.dbotthepony.mc.otm.block.entity

import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import java.util.function.IntPredicate
import java.util.function.Predicate

enum class RedstoneSetting(val label: Component, val description: Component): IntPredicate {
	IGNORED(TranslatableComponent("otm.gui.redstone.ignored"), TranslatableComponent("otm.gui.redstone.ignored.description")) {
		override fun test(t: Int): Boolean {
			return true
		}
	},
	LOW(TranslatableComponent("otm.gui.redstone.low"), TranslatableComponent("otm.gui.redstone.low.description")) {
		override fun test(t: Int): Boolean {
			return t <= 0
		}
	},
	HIGH(TranslatableComponent("otm.gui.redstone.high"), TranslatableComponent("otm.gui.redstone.high.description")) {
		override fun test(t: Int): Boolean {
			return t > 0
		}
	};

	operator fun next(): RedstoneSetting {
		return values[(ordinal + 1) % values.size]
	}

	companion object {
		private val values = values()

		operator fun get(index: Int): RedstoneSetting {
			if (index !in 0 .. 2)
				return LOW

			return values[index]
		}
	}
}
