package net.moonleay.gimble.editor.util

import net.moonleay.gimble.editor.state.EditorState
import net.moonleay.gimble.editor.state.mode.Capability
import net.moonleay.gimble.editor.state.mode.Mode
import net.moonleay.gimble.editor.state.mode.ModeModifier

object EditorUtil {

    /*
    * Check if a player should be able to perform an action
    * */
    fun shouldPlayer(capability: Capability, state: EditorState): Boolean {
        when (capability) {
            Capability.INSERT -> {
                return state.editorMode == Mode.INSERT
            }

            Capability.REPLACE -> {
                return state.editorMode == Mode.REPLACE
            }

            Capability.CAN_INTERACT -> {
                return state.editorMode != Mode.VISUAL && state.editorMode != Mode.NORMAL
            }

            Capability.NO_CLIP -> {
                return state.editorModifier.contains(ModeModifier.NO_CLIP)
            }

            Capability.FORCE_PLACE -> {
                return state.editorModifier.contains(ModeModifier.FORCE_PLACE)
            }

            Capability.NO_UPDATES -> {
                return state.editorModifier.contains(ModeModifier.NO_UPDATES)
            }

            Capability.BULLDOZER -> {
                return state.editorModifier.contains(ModeModifier.BULLDOZER)
            }
        }
    }
}
