package persona

// MorphologyHints describes non-human physical features for humanoid characters.
// These are only applied when MorphLevel >= 25, allowing progressive creature
// features based on the transformation intensity.
type MorphologyHints struct {
	// EarType specifies non-human ear style.
	// Values: "pointed", "elf", "wolf", "cat", "fox", "bat", "rabbit"
	EarType string `json:"ear_type,omitempty" yaml:"ear_type,omitempty"`

	// TailType specifies tail style if present.
	// Values: "wolf", "cat", "fox", "demon", "dragon", "fluffy"
	TailType string `json:"tail_type,omitempty" yaml:"tail_type,omitempty"`

	// FangType specifies fang/teeth style.
	// Values: "subtle", "vampire", "wolf", "cat", "demon"
	FangType string `json:"fang_type,omitempty" yaml:"fang_type,omitempty"`

	// FurPatterns describes fur distribution at higher morph levels.
	// Example: ["light dusting on forearms", "along spine", "full coverage"]
	FurPatterns []string `json:"fur_patterns,omitempty" yaml:"fur_patterns,omitempty"`

	// ScalePattern describes scale distribution for reptilian creatures.
	// Example: "iridescent patches on shoulders and cheeks"
	ScalePattern string `json:"scale_pattern,omitempty" yaml:"scale_pattern,omitempty"`

	// WingType specifies wing style if present.
	// Values: "feathered", "bat", "fairy", "demon", "dragon"
	WingType string `json:"wing_type,omitempty" yaml:"wing_type,omitempty"`

	// HornType specifies horn style if present.
	// Values: "small_curved", "ram", "demon", "unicorn", "antlers"
	HornType string `json:"horn_type,omitempty" yaml:"horn_type,omitempty"`

	// ClawType specifies claw/nail style.
	// Values: "subtle", "retractable", "prominent", "talons"
	ClawType string `json:"claw_type,omitempty" yaml:"claw_type,omitempty"`
}

// HasFeatures returns true if any morphology features are defined.
func (m *MorphologyHints) HasFeatures() bool {
	if m == nil {
		return false
	}
	return m.EarType != "" ||
		m.TailType != "" ||
		m.FangType != "" ||
		len(m.FurPatterns) > 0 ||
		m.ScalePattern != "" ||
		m.WingType != "" ||
		m.HornType != "" ||
		m.ClawType != ""
}

// ValidEarTypes are the supported ear type values.
var ValidEarTypes = []string{
	"pointed", "elf", "wolf", "cat", "fox", "bat", "rabbit",
}

// ValidTailTypes are the supported tail type values.
var ValidTailTypes = []string{
	"wolf", "cat", "fox", "demon", "dragon", "fluffy",
}

// ValidFangTypes are the supported fang type values.
var ValidFangTypes = []string{
	"subtle", "vampire", "wolf", "cat", "demon",
}

// ValidWingTypes are the supported wing type values.
var ValidWingTypes = []string{
	"feathered", "bat", "fairy", "demon", "dragon",
}

// ValidHornTypes are the supported horn type values.
var ValidHornTypes = []string{
	"small_curved", "ram", "demon", "unicorn", "antlers",
}

// ValidClawTypes are the supported claw type values.
var ValidClawTypes = []string{
	"subtle", "retractable", "prominent", "talons",
}

// isValidType checks if a value is in the allowed list.
func isValidType(value string, allowed []string) bool {
	for _, v := range allowed {
		if v == value {
			return true
		}
	}
	return false
}

// IsValidEarType returns true if the ear type is valid.
func IsValidEarType(t string) bool {
	return t == "" || isValidType(t, ValidEarTypes)
}

// IsValidTailType returns true if the tail type is valid.
func IsValidTailType(t string) bool {
	return t == "" || isValidType(t, ValidTailTypes)
}

// IsValidFangType returns true if the fang type is valid.
func IsValidFangType(t string) bool {
	return t == "" || isValidType(t, ValidFangTypes)
}

// IsValidWingType returns true if the wing type is valid.
func IsValidWingType(t string) bool {
	return t == "" || isValidType(t, ValidWingTypes)
}

// IsValidHornType returns true if the horn type is valid.
func IsValidHornType(t string) bool {
	return t == "" || isValidType(t, ValidHornTypes)
}

// IsValidClawType returns true if the claw type is valid.
func IsValidClawType(t string) bool {
	return t == "" || isValidType(t, ValidClawTypes)
}
