package factions

// Faction represents a single faction with its properties
type Faction struct {
	ID             int32  // Faction ID
	Name           string // Faction name
	Type           string // Faction type/category
	Description    string // Faction description
	NegativeChange int16  // Amount faction decreases by default
	PositiveChange int16  // Amount faction increases by default
	DefaultValue   int32  // Default faction value for new characters
}

// NewFaction creates a new faction with the given parameters
func NewFaction(id int32, name, factionType, description string) *Faction {
	return &Faction{
		ID:             id,
		Name:           name,
		Type:           factionType,
		Description:    description,
		NegativeChange: 0,
		PositiveChange: 0,
		DefaultValue:   0,
	}
}

// GetID returns the faction ID
func (f *Faction) GetID() int32 {
	return f.ID
}

// GetName returns the faction name
func (f *Faction) GetName() string {
	return f.Name
}

// GetType returns the faction type
func (f *Faction) GetType() string {
	return f.Type
}

// GetDescription returns the faction description
func (f *Faction) GetDescription() string {
	return f.Description
}

// GetNegativeChange returns the default decrease amount
func (f *Faction) GetNegativeChange() int16 {
	return f.NegativeChange
}

// GetPositiveChange returns the default increase amount
func (f *Faction) GetPositiveChange() int16 {
	return f.PositiveChange
}

// GetDefaultValue returns the default faction value
func (f *Faction) GetDefaultValue() int32 {
	return f.DefaultValue
}

// SetNegativeChange sets the default decrease amount
func (f *Faction) SetNegativeChange(amount int16) {
	f.NegativeChange = amount
}

// SetPositiveChange sets the default increase amount
func (f *Faction) SetPositiveChange(amount int16) {
	f.PositiveChange = amount
}

// SetDefaultValue sets the default faction value
func (f *Faction) SetDefaultValue(value int32) {
	f.DefaultValue = value
}

// Clone creates a copy of the faction
func (f *Faction) Clone() *Faction {
	return &Faction{
		ID:             f.ID,
		Name:           f.Name,
		Type:           f.Type,
		Description:    f.Description,
		NegativeChange: f.NegativeChange,
		PositiveChange: f.PositiveChange,
		DefaultValue:   f.DefaultValue,
	}
}

// IsValid returns true if the faction has valid data
func (f *Faction) IsValid() bool {
	return f.ID > 0 && len(f.Name) > 0
}

// IsSpecialFaction returns true if this is a special faction (ID <= 10)
func (f *Faction) IsSpecialFaction() bool {
	return f.ID <= SpecialFactionIDMax
}

// CanIncrease returns true if this faction can be increased
func (f *Faction) CanIncrease() bool {
	return !f.IsSpecialFaction() && f.PositiveChange != 0
}

// CanDecrease returns true if this faction can be decreased
func (f *Faction) CanDecrease() bool {
	return !f.IsSpecialFaction() && f.NegativeChange != 0
}
