package util

import (
	. "openquell/config"
)

// find an item in a list, generic variant
func Contains[E comparable](s []E, v E) bool {
	for _, vs := range s {
		if v == vs {
			return true
		}
	}

	return false
}

// look if a key in a map exists, generic variant
func Exists[K comparable, V any](m map[K]V, v K) bool {
	if _, ok := m[v]; ok {
		return true
	}

	return false
}

func DirectionStr(dir int) string {
	str := "Stop"
	switch dir {
	case East:
		str = "East"
	case West:
		str = "West"
	case South:
		str = "South"
	case North:
		str = "North"
	case All:
		str = "All"
	}

	return str
}
