package race_types

// RaceTypeProvider defines the interface for accessing race type information
type RaceTypeProvider interface {
	// GetRaceType returns the race type ID for a given model ID
	GetRaceType(modelID int16) int16
	
	// GetRaceBaseType returns the base category type for a model ID
	GetRaceBaseType(modelID int16) int16
	
	// GetRaceTypeCategory returns the category name for a model ID
	GetRaceTypeCategory(modelID int16) string
	
	// GetRaceTypeSubCategory returns the subcategory name for a model ID
	GetRaceTypeSubCategory(modelID int16) string
	
	// GetRaceTypeModelName returns the model name for a model ID
	GetRaceTypeModelName(modelID int16) string
	
	// GetRaceTypeInfo returns complete race type information for a model ID
	GetRaceTypeInfo(modelID int16) *RaceType
}

// CreatureTypeChecker defines the interface for checking creature types
type CreatureTypeChecker interface {
	// IsCreatureType checks if a model ID represents a specific creature type
	IsCreatureType(modelID int16, creatureType int16) bool
	
	// IsUndead checks if a model ID represents an undead creature
	IsUndead(modelID int16) bool
	
	// IsDragonkind checks if a model ID represents a dragon-type creature
	IsDragonkind(modelID int16) bool
	
	// IsMagical checks if a model ID represents a magical creature
	IsMagical(modelID int16) bool
	
	// IsNatural checks if a model ID represents a natural creature
	IsNatural(modelID int16) bool
	
	// IsSentient checks if a model ID represents a sentient being
	IsSentient(modelID int16) bool
}

// RaceTypeAware defines the interface for entities that have a race type
type RaceTypeAware interface {
	// GetModelType returns the model type ID of the entity
	GetModelType() int16
	
	// SetModelType sets the model type ID of the entity
	SetModelType(modelType int16)
}

// NPCRaceTypeAdapter provides race type functionality for NPCs
type NPCRaceTypeAdapter struct {
	npc              RaceTypeAware
	raceTypeProvider RaceTypeProvider
}

// NewNPCRaceTypeAdapter creates a new NPC race type adapter
func NewNPCRaceTypeAdapter(npc RaceTypeAware, provider RaceTypeProvider) *NPCRaceTypeAdapter {
	return &NPCRaceTypeAdapter{
		npc:              npc,
		raceTypeProvider: provider,
	}
}

// GetRaceType returns the race type ID for the NPC
func (a *NPCRaceTypeAdapter) GetRaceType() int16 {
	if a.raceTypeProvider == nil {
		return 0
	}
	return a.raceTypeProvider.GetRaceType(a.npc.GetModelType())
}

// GetRaceBaseType returns the base category type for the NPC
func (a *NPCRaceTypeAdapter) GetRaceBaseType() int16 {
	if a.raceTypeProvider == nil {
		return 0
	}
	return a.raceTypeProvider.GetRaceBaseType(a.npc.GetModelType())
}

// GetRaceTypeCategory returns the category name for the NPC
func (a *NPCRaceTypeAdapter) GetRaceTypeCategory() string {
	if a.raceTypeProvider == nil {
		return ""
	}
	return a.raceTypeProvider.GetRaceTypeCategory(a.npc.GetModelType())
}

// GetRaceTypeInfo returns complete race type information for the NPC
func (a *NPCRaceTypeAdapter) GetRaceTypeInfo() *RaceType {
	if a.raceTypeProvider == nil {
		return nil
	}
	return a.raceTypeProvider.GetRaceTypeInfo(a.npc.GetModelType())
}

// IsUndead checks if the NPC is an undead creature
func (a *NPCRaceTypeAdapter) IsUndead() bool {
	baseType := a.GetRaceBaseType()
	return baseType == Undead
}

// IsDragonkind checks if the NPC is a dragon-type creature
func (a *NPCRaceTypeAdapter) IsDragonkind() bool {
	baseType := a.GetRaceBaseType()
	return baseType == Dragonkind
}

// IsMagical checks if the NPC is a magical creature
func (a *NPCRaceTypeAdapter) IsMagical() bool {
	baseType := a.GetRaceBaseType()
	return baseType == Magical || baseType == Mechanimagical
}

// IsNatural checks if the NPC is a natural creature
func (a *NPCRaceTypeAdapter) IsNatural() bool {
	baseType := a.GetRaceBaseType()
	return baseType == Natural
}

// IsSentient checks if the NPC is a sentient being
func (a *NPCRaceTypeAdapter) IsSentient() bool {
	baseType := a.GetRaceBaseType()
	return baseType == Sentient
}

// DamageModifier defines an interface for race-type-based damage calculations
type DamageModifier interface {
	// GetDamageModifier returns damage modifier based on attacker and target race types
	// This could be used for implementing race-specific damage bonuses/penalties
	GetDamageModifier(attackerModelID, targetModelID int16) float32
}

// LootModifier defines an interface for race-type-based loot modifications
type LootModifier interface {
	// GetLootTableModifier returns loot table modifications based on creature race type
	// This could be used for implementing race-specific loot tables
	GetLootTableModifier(modelID int16) string
}

// AIBehaviorModifier defines an interface for race-type-based AI behavior
type AIBehaviorModifier interface {
	// GetAIBehaviorFlags returns AI behavior flags based on race type
	// This could be used for implementing race-specific AI behaviors
	GetAIBehaviorFlags(modelID int16) uint32
	
	// GetAggressionLevel returns aggression level based on race type
	GetAggressionLevel(modelID int16) int8
	
	// GetFleeHealthPercent returns health percentage at which creature flees
	GetFleeHealthPercent(modelID int16) float32
}