export const SYSTEM_ID = "fvtt-oath-hammer"

export const ATTRIBUTES = {
  might: { id: "might", abbrev: "M", label: "OATHHAMMER.Attribute.Might" },
  toughness: { id: "toughness", abbrev: "T", label: "OATHHAMMER.Attribute.Toughness" },
  agility: { id: "agility", abbrev: "A", label: "OATHHAMMER.Attribute.Agility" },
  willpower: { id: "willpower", abbrev: "WP", label: "OATHHAMMER.Attribute.Willpower" },
  intelligence: { id: "intelligence", abbrev: "I", label: "OATHHAMMER.Attribute.Intelligence" },
  fate: { id: "fate", abbrev: "F", label: "OATHHAMMER.Attribute.Fate" }
}

export const LINEAGE_CHOICES = {
  dwarf:    { id: "dwarf",    label: "OATHHAMMER.Lineage.Dwarf" },
  firbolg:  { id: "firbolg",  label: "OATHHAMMER.Lineage.Firbolg" },
  halfling: { id: "halfling", label: "OATHHAMMER.Lineage.Halfling" },
  "high-elf":  { id: "high-elf",  label: "OATHHAMMER.Lineage.HighElf" },
  human:    { id: "human",    label: "OATHHAMMER.Lineage.Human" },
  "wood-elf":  { id: "wood-elf",  label: "OATHHAMMER.Lineage.WoodElf" }
}

export const CLASS_CHOICES = {
  berserker:  { id: "berserker",  label: "OATHHAMMER.Class.Berserker" },
  champion:   { id: "champion",   label: "OATHHAMMER.Class.Champion" },
  delver:     { id: "delver",     label: "OATHHAMMER.Class.Delver" },
  knight:     { id: "knight",     label: "OATHHAMMER.Class.Knight" },
  mage:       { id: "mage",       label: "OATHHAMMER.Class.Mage" },
  priest:     { id: "priest",     label: "OATHHAMMER.Class.Priest" },
  scout:      { id: "scout",      label: "OATHHAMMER.Class.Scout" },
  soldier:    { id: "soldier",    label: "OATHHAMMER.Class.Soldier" },
  spellblade: { id: "spellblade", label: "OATHHAMMER.Class.Spellblade" },
  troubadour: { id: "troubadour", label: "OATHHAMMER.Class.Troubadour" }
}

export const OATH_TYPES = {
  "oath-of-compassion":   { id: "oath-of-compassion",   label: "OATHHAMMER.OathType.Compassion" },
  "oath-of-courage":      { id: "oath-of-courage",      label: "OATHHAMMER.OathType.Courage" },
  "oath-of-diligence":    { id: "oath-of-diligence",    label: "OATHHAMMER.OathType.Diligence" },
  "oath-of-faith":        { id: "oath-of-faith",        label: "OATHHAMMER.OathType.Faith" },
  "oath-of-humility":     { id: "oath-of-humility",     label: "OATHHAMMER.OathType.Humility" },
  "oath-of-justice":      { id: "oath-of-justice",      label: "OATHHAMMER.OathType.Justice" },
  "oath-of-loyalty":      { id: "oath-of-loyalty",      label: "OATHHAMMER.OathType.Loyalty" },
  "oath-of-peace":        { id: "oath-of-peace",        label: "OATHHAMMER.OathType.Peace" },
  "oath-of-perseverance": { id: "oath-of-perseverance", label: "OATHHAMMER.OathType.Perseverance" },
  "oath-of-purity":       { id: "oath-of-purity",       label: "OATHHAMMER.OathType.Purity" },
  "oath-of-truth":        { id: "oath-of-truth",        label: "OATHHAMMER.OathType.Truth" },
  "oath-of-wisdom":       { id: "oath-of-wisdom",       label: "OATHHAMMER.OathType.Wisdom" }
}

export const SORCEROUS_TRADITIONS = {
  elemental:   { id: "elemental",   label: "OATHHAMMER.Tradition.Elemental" },
  illusionist: { id: "illusionist", label: "OATHHAMMER.Tradition.Illusionist" },
  imperial:    { id: "imperial",    label: "OATHHAMMER.Tradition.Imperial" },
  infernal:    { id: "infernal",    label: "OATHHAMMER.Tradition.Infernal" },
  runic:       { id: "runic",       label: "OATHHAMMER.Tradition.Runic" },
  stygian:     { id: "stygian",     label: "OATHHAMMER.Tradition.Stygian" }
}

// Three divine traditions for miracles (p.130)
export const DIVINE_TRADITIONS = {
  druidic:    "OATHHAMMER.DivineTradition.Druidic",
  profane:    "OATHHAMMER.DivineTradition.Profane",
  sanctified: "OATHHAMMER.DivineTradition.Sanctified"
}

// Elemental sub-types for Elemental tradition spells (p.103)
export const ELEMENTAL_CHOICES = {
  air:    "OATHHAMMER.Element.Air",
  earth:  "OATHHAMMER.Element.Earth",
  fire:   "OATHHAMMER.Element.Fire",
  water:  "OATHHAMMER.Element.Water",
  varies: "OATHHAMMER.Element.Varies"
}

// Rune types for Runic tradition spells (p.120)
export const RUNE_TYPE_CHOICES = {
  armor:    "OATHHAMMER.RuneType.Armor",
  talisman: "OATHHAMMER.RuneType.Talisman",
  warding:  "OATHHAMMER.RuneType.Warding",
  weapon:   "OATHHAMMER.RuneType.Weapon"
}

// Weapon proficiency groups (from book pp.82-84)
export const WEAPON_PROFICIENCY_GROUPS = {
  common:   "OATHHAMMER.WeaponGroup.Common",
  dueling:  "OATHHAMMER.WeaponGroup.Dueling",
  heavy:    "OATHHAMMER.WeaponGroup.Heavy",
  polearms: "OATHHAMMER.WeaponGroup.Polearms",
  bows:     "OATHHAMMER.WeaponGroup.Bows",
  throwing: "OATHHAMMER.WeaponGroup.Throwing"
}

// Weapon traits (from book p.82)
export const WEAPON_TRAITS = {
  block:       "OATHHAMMER.WeaponTrait.Block",
  brutal:      "OATHHAMMER.WeaponTrait.Brutal",
  clumsy:      "OATHHAMMER.WeaponTrait.Clumsy",
  couched:     "OATHHAMMER.WeaponTrait.Couched",
  deadly:      "OATHHAMMER.WeaponTrait.Deadly",
  fast:        "OATHHAMMER.WeaponTrait.Fast",
  flaming:     "OATHHAMMER.WeaponTrait.Flaming",
  nimble:      "OATHHAMMER.WeaponTrait.Nimble",
  parry:       "OATHHAMMER.WeaponTrait.Parry",
  reload:      "OATHHAMMER.WeaponTrait.Reload",
  repel:       "OATHHAMMER.WeaponTrait.Repel",
  stunning:    "OATHHAMMER.WeaponTrait.Stunning",
  sweep:       "OATHHAMMER.WeaponTrait.Sweep",
  "two-handed":  "OATHHAMMER.WeaponTrait.TwoHanded",
  versatile:   "OATHHAMMER.WeaponTrait.Versatile"
}

// Special Properties that can be added to weapons via crafting (p.98)
export const WEAPON_SPECIAL_PROPERTIES = {
  accurate:       "OATHHAMMER.WeaponProperty.Accurate",
  "adv-mechanism":"OATHHAMMER.WeaponProperty.AdvMechanism",
  "armor-bane":   "OATHHAMMER.WeaponProperty.ArmorBane",
  balanced:       "OATHHAMMER.WeaponProperty.Balanced",
  "heavy-draw":   "OATHHAMMER.WeaponProperty.HeavyDraw",
  "master-crafted":"OATHHAMMER.WeaponProperty.MasterCrafted",
  ornate:         "OATHHAMMER.WeaponProperty.Ornate",
  refined:        "OATHHAMMER.WeaponProperty.Refined",
  "rune-etched":  "OATHHAMMER.WeaponProperty.RuneEtched",
  tempered:       "OATHHAMMER.WeaponProperty.Tempered",
}

export const CURRENCY_CHOICES = {
  gp: "OATHHAMMER.Currency.GP",
  sp: "OATHHAMMER.Currency.SP",
  cp: "OATHHAMMER.Currency.CP"
}

export const ARMOR_TYPE_CHOICES = {
  light:  "OATHHAMMER.ArmorType.Light",
  medium: "OATHHAMMER.ArmorType.Medium",
  heavy:  "OATHHAMMER.ArmorType.Heavy"
}

// Armor traits (p.88): Clanging = -1 Stealth; Reinforced = red dice for armor rolls
export const ARMOR_TRAITS = {
  clanging:   "OATHHAMMER.ArmorTrait.Clanging",
  reinforced: "OATHHAMMER.ArmorTrait.Reinforced"
}

// Ammunition types (p.88): standard = arrow/bolt; bodkin = -1 armor; envenomed = poison; incendiary = flaming
export const AMMO_TYPE_CHOICES = {
  standard:   "OATHHAMMER.AmmoType.Standard",
  bodkin:     "OATHHAMMER.AmmoType.Bodkin",
  envenomed:  "OATHHAMMER.AmmoType.Envenomed",
  incendiary: "OATHHAMMER.AmmoType.Incendiary"
}

// Equipment sub-categories matching the rulebook sections (pp.90-96)
export const EQUIPMENT_TYPE_CHOICES = {
  potion:           "OATHHAMMER.EquipmentType.Potion",
  container:        "OATHHAMMER.EquipmentType.Container",
  mount:            "OATHHAMMER.EquipmentType.Mount",
  "healing-supply": "OATHHAMMER.EquipmentType.HealingSupply",
  food:             "OATHHAMMER.EquipmentType.Food",
  "light-source":   "OATHHAMMER.EquipmentType.LightSource",
  misc:             "OATHHAMMER.EquipmentType.Misc",
  vehicle:          "OATHHAMMER.EquipmentType.Vehicle",
  animal:           "OATHHAMMER.EquipmentType.Animal",
  "war-machine":    "OATHHAMMER.EquipmentType.WarMachine"
}

// Magic item sub-types for Focus/Talisman/Trinket (p.136)
// Weapon and Armor magic items use their respective item types with isMagic=true.
export const MAGIC_ITEM_TYPE_CHOICES = {
  focus:    "OATHHAMMER.MagicItemType.Focus",
  talisman: "OATHHAMMER.MagicItemType.Talisman",
  trinket:  "OATHHAMMER.MagicItemType.Trinket"
}

// Magic item quality (p.136): determines power and how they are found
export const MAGIC_QUALITY_CHOICES = {
  lesser:    "OATHHAMMER.MagicQuality.Lesser",
  greater:   "OATHHAMMER.MagicQuality.Greater",
  legendary: "OATHHAMMER.MagicQuality.Legendary"
}

export const RARITY_CHOICES = {
  always: "OATHHAMMER.Rarity.Always",
  common: "OATHHAMMER.Rarity.Common",
  uncommon: "OATHHAMMER.Rarity.Uncommon",
  rare: "OATHHAMMER.Rarity.Rare",
  "very-rare": "OATHHAMMER.Rarity.VeryRare",
  legendary: "OATHHAMMER.Rarity.Legendary"
}

// Rarity key → Difficulty Value for Fortune rolls
export const RARITY_DV = {
  always: 0,
  common: 1,
  uncommon: 2,
  rare: 3,
  "very-rare": 4,
  legendary: 5
}

// Two types of trait per the rulebook terminology
export const TRAIT_TYPE_CHOICES = {
  "special-trait":  "OATHHAMMER.TraitType.SpecialTrait",
  "class-trait":    "OATHHAMMER.TraitType.ClassTrait",
  "lineage-trait":  "OATHHAMMER.TraitType.LineageTrait"
}

// When a trait's uses reset (none = passive/always on)
export const TRAIT_USAGE_PERIOD = {
  none:      "OATHHAMMER.UsagePeriod.None",
  round:     "OATHHAMMER.UsagePeriod.Round",
  encounter: "OATHHAMMER.UsagePeriod.Encounter",
  day:       "OATHHAMMER.UsagePeriod.Day"
}

export const STATUS_EFFECTS = [
  {
    id: "blinded",
    name: "OATHHAMMER.Condition.Blinded",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/blinded.svg",
    description: "OATHHAMMER.Condition.BlindedDesc"
  },
  {
    id: "confused",
    name: "OATHHAMMER.Condition.Confused",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/confused.svg",
    description: "OATHHAMMER.Condition.ConfusedDesc"
  },
  {
    id: "dazed",
    name: "OATHHAMMER.Condition.Dazed",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/dazed.svg",
    description: "OATHHAMMER.Condition.DazedDesc"
  },
  {
    id: "deafened",
    name: "OATHHAMMER.Condition.Deafened",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/deafened.svg",
    description: "OATHHAMMER.Condition.DeafenedDesc"
  },
  {
    id: "demoralized",
    name: "OATHHAMMER.Condition.Demoralized",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/demoralized.svg",
    description: "OATHHAMMER.Condition.DemoralizedDesc"
  },
  {
    id: "diseased",
    name: "OATHHAMMER.Condition.Diseased",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/diseased.svg",
    description: "OATHHAMMER.Condition.DiseasedDesc"
  },
  {
    id: "enfeebled",
    name: "OATHHAMMER.Condition.Enfeebled",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/enfeebled.svg",
    description: "OATHHAMMER.Condition.EnfeebledDesc"
  },
  {
    id: "fatigued",
    name: "OATHHAMMER.Condition.Fatigued",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/fatigued.svg",
    description: "OATHHAMMER.Condition.FatiguedDesc"
  },
  {
    id: "frightened",
    name: "OATHHAMMER.Condition.Frightened",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/frightened.svg",
    description: "OATHHAMMER.Condition.FrightenedDesc"
  },
  {
    id: "ignited",
    name: "OATHHAMMER.Condition.Ignited",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/ignited.svg",
    description: "OATHHAMMER.Condition.IgnitedDesc"
  },
  {
    id: "inspired",
    name: "OATHHAMMER.Condition.Inspired",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/inspired.svg",
    description: "OATHHAMMER.Condition.InspiredDesc"
  },
  {
    id: "invisible",
    name: "OATHHAMMER.Condition.Invisible",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/invisible.svg",
    description: "OATHHAMMER.Condition.InvisibleDesc"
  },
  {
    id: "poisoned",
    name: "OATHHAMMER.Condition.Poisoned",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/poisoned.svg",
    description: "OATHHAMMER.Condition.PoisonedDesc"
  },
  {
    id: "restrained",
    name: "OATHHAMMER.Condition.Restrained",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/restrained.svg",
    description: "OATHHAMMER.Condition.RestrainedDesc"
  },
  {
    id: "stunned",
    name: "OATHHAMMER.Condition.Stunned",
    img: "systems/fvtt-oath-hammer/assets/icons/conditions/stunned.svg",
    description: "OATHHAMMER.Condition.StunnedDesc"
  }
]

export const ATTRIBUTE_RANK_CHOICES = { 1: "1", 2: "2", 3: "3", 4: "4" }

// 26 skills: each mapped to its primary attribute. "magic" is dual (WP=miracles, INT=spells).
export const SKILLS = {
  academics:     { id: "academics",      attribute: "intelligence", label: "OATHHAMMER.Skill.Academics" },
  acrobatics:    { id: "acrobatics",     attribute: "agility",      label: "OATHHAMMER.Skill.Acrobatics" },
  animalHandling:{ id: "animalHandling", attribute: "willpower",    label: "OATHHAMMER.Skill.AnimalHandling" },
  athletics:     { id: "athletics",      attribute: "might",        label: "OATHHAMMER.Skill.Athletics" },
  brewing:       { id: "brewing",        attribute: "intelligence", label: "OATHHAMMER.Skill.Brewing" },
  carpentry:     { id: "carpentry",      attribute: "agility",      label: "OATHHAMMER.Skill.Carpentry" },
  defense:       { id: "defense",        attribute: "agility",      label: "OATHHAMMER.Skill.Defense" },
  dexterity:     { id: "dexterity",      attribute: "agility",      label: "OATHHAMMER.Skill.Dexterity" },
  diplomacy:     { id: "diplomacy",      attribute: "willpower",    label: "OATHHAMMER.Skill.Diplomacy" },
  discipline:    { id: "discipline",     attribute: "willpower",    label: "OATHHAMMER.Skill.Discipline" },
  fighting:      { id: "fighting",       attribute: "might",        label: "OATHHAMMER.Skill.Fighting" },
  folklore:      { id: "folklore",       attribute: "willpower",    label: "OATHHAMMER.Skill.Folklore" },
  fortune:       { id: "fortune",        attribute: "fate",         label: "OATHHAMMER.Skill.Fortune" },
  heal:          { id: "heal",           attribute: "intelligence", label: "OATHHAMMER.Skill.Heal" },
  leadership:    { id: "leadership",     attribute: "willpower",    label: "OATHHAMMER.Skill.Leadership" },
  magic:         { id: "magic",          attribute: "willpower",    label: "OATHHAMMER.Skill.Magic" },
  masonry:       { id: "masonry",        attribute: "might",        label: "OATHHAMMER.Skill.Masonry" },
  orientation:   { id: "orientation",    attribute: "intelligence", label: "OATHHAMMER.Skill.Orientation" },
  perception:    { id: "perception",     attribute: "willpower",    label: "OATHHAMMER.Skill.Perception" },
  resilience:    { id: "resilience",     attribute: "toughness",    label: "OATHHAMMER.Skill.Resilience" },
  ride:          { id: "ride",           attribute: "agility",      label: "OATHHAMMER.Skill.Ride" },
  shooting:      { id: "shooting",       attribute: "agility",      label: "OATHHAMMER.Skill.Shooting" },
  smithing:      { id: "smithing",       attribute: "might",        label: "OATHHAMMER.Skill.Smithing" },
  stealth:       { id: "stealth",        attribute: "agility",      label: "OATHHAMMER.Skill.Stealth" },
  survival:      { id: "survival",       attribute: "willpower",    label: "OATHHAMMER.Skill.Survival" },
  tracking:      { id: "tracking",       attribute: "intelligence", label: "OATHHAMMER.Skill.Tracking" },
}

// Skills grouped by primary attribute (for sheet display)
export const SKILLS_BY_ATTRIBUTE = {
  might:        ["athletics", "fighting", "masonry", "smithing"],
  toughness:    ["resilience"],
  agility:      ["acrobatics", "carpentry", "defense", "dexterity", "ride", "shooting", "stealth"],
  willpower:    ["animalHandling", "diplomacy", "discipline", "folklore", "leadership", "magic", "perception", "survival"],
  intelligence: ["academics", "brewing", "heal", "orientation", "tracking"],
  fate:         ["fortune"],
}

export const ASCII = `
·················································
:   ___       _   _       _   _                :
:  / _ \\ __ _| |_| |__   | | | | __ _ _ __ ___ :
: | | | / _\` | __| '_ \\  | |_| |/ _\` | '_ \` _ \\:
: | |_| | (_| | |_| | | | |  _  | (_| | | | | | |
:  \\___/ \\__,_|\\__|_| |_| |_| |_|\\__,_|_| |_| |_|
:                                                :
·················································
`

export const BUILDING_SKILL_CHOICES = {
  carpentry: "OATHHAMMER.BuildingSkill.Carpentry",
  masonry:   "OATHHAMMER.BuildingSkill.Masonry"
}

export const SETTLEMENT_ARCHETYPES = {
  "center-of-learning":   "OATHHAMMER.SettlementArchetype.CenterOfLearning",
  "dwarven-borough":      "OATHHAMMER.SettlementArchetype.DwarvenBorough",
  "free-city":            "OATHHAMMER.SettlementArchetype.FreeCity",
  "guild-municipality":   "OATHHAMMER.SettlementArchetype.GuildMunicipality",
  "nocklander-outpost":   "OATHHAMMER.SettlementArchetype.NocklanderOutpost",
  "pilgrim-mission":      "OATHHAMMER.SettlementArchetype.PilgrimMission",
  "port-town":            "OATHHAMMER.SettlementArchetype.PortTown",
  "velathi-colony":       "OATHHAMMER.SettlementArchetype.VelathiColony"
}

export const SYSTEM = {
  id: SYSTEM_ID,
  ATTRIBUTES,
  SKILLS,
  SKILLS_BY_ATTRIBUTE,
  LINEAGE_CHOICES,
  CLASS_CHOICES,
  OATH_TYPES,
  SORCEROUS_TRADITIONS,
  DIVINE_TRADITIONS,
  ELEMENTAL_CHOICES,
  RUNE_TYPE_CHOICES,
  WEAPON_PROFICIENCY_GROUPS,
  WEAPON_TRAITS,
  WEAPON_SPECIAL_PROPERTIES,
  ARMOR_TYPE_CHOICES,
  ARMOR_TRAITS,
    CURRENCY_CHOICES,
  AMMO_TYPE_CHOICES,
  EQUIPMENT_TYPE_CHOICES,
  MAGIC_ITEM_TYPE_CHOICES,
  MAGIC_QUALITY_CHOICES,
  RARITY_CHOICES,
  RARITY_DV,
  TRAIT_TYPE_CHOICES,
  TRAIT_USAGE_PERIOD,
  BUILDING_SKILL_CHOICES,
  SETTLEMENT_ARCHETYPES,
  STATUS_EFFECTS,
  ATTRIBUTE_RANK_CHOICES,
  ASCII
}
