import * as CHARACTER from "./character.mjs"
import * as WEAPON from "./weapon.mjs"
import * as ARMOR from "./armor.mjs"
import * as SHIELD from "./shield.mjs"
import * as SPELL from "./spell.mjs"
import * as SKILL from "./skill.mjs"
import * as EQUIPMENT from "./equipment.mjs"
import * as CHARACTERISTICS from "./characteristic-tables.mjs"
import * as MONSTER from "./monster.mjs"
import * as RACE from "./race.mjs"
import * as CLASS from "./class.mjs"

export const SYSTEM_ID = "fvtt-prism-rpg"
export const DEV_MODE = false

export const MONEY = {
  coppercoin: {
    id: "coppercoin",
    abbrev: "cc",
    label: "PRISMRPG.Money.CopperCoin",
    valuetb: 1
  },
  silvercoin: {
    id: "silvercoin",
    abbrev: "sc",
    label: "PRISMRPG.Money.SilverCoin",
    valuetb: 5
  },
  goldcoin: {
    id: "goldcoin",
    abbrev: "gc",
    label: "PRISMRPG.Money.GoldCoin",
    valuetb: 10
  },
  note: {
    id: "note",
    abbrev: "nt",
    label: "PRISMRPG.Money.Note",
    valuetb: 100
  },
  steam: {
    id: "steam",
    abbrev: "st",
    label: "PRISMRPG.Money.Steam",
    valuetb: 1000
  }
}

export const MORTAL_CHOICES = {
  "mankind": { label: "Mankind", id: "mankind", defenseBonus: 0 },
  "elf": { label: "Elf", id: "elf", defenseBonus: 0 },
  "dwarf": { label: "Dwarf", id: "dwarf", defenseBonus: 0 },
  "halfelf": { label: "Half-Elf", id: "halfelf", defenseBonus: 0 },
  "halforc": { label: "Half-Orc", id: "halforc", defenseBonus: 0 },
  "gnome": { label: "Gnome", id: "gnome", defenseBonus: 2 },
  "halflings": { label: "Halfling", id: "halflings", defenseBonus: 2 }
}

export const ADVANTAGE_CHOICES = {
  "none": { label: "None", value: "none" },
  "advantage": { label: "Advantage", value: "advantage" },
  "disadvantage": { label: "Disadvantage", value: "disadvantage" }
}

export const MOVEMENT_CHOICES = {
  "none": { label: "None (D20E Disfavor)", disfavor: true, value: "2D20kl" },
  "walk": { label: "Walk (D20E)", disfavor: true, value: "D20" },
  "incombat": { label: "In Combat (D20E)", favor: false, value: "D20" },
  "run": { label: "Jog/Run/Sprint (D20E Favor)", favor: true, value: "2D20kh" }
}

export const MOVE_DIRECTION_CHOICES = {
  "away": { label: "Away (+0)", value: "+0" },
  "toward": { label: "Toward (0)", value: "0" },
  "lateral": { label: "Lateral (Red +5)", value: "+5" },
  "none": { label: "None (+0)", value: "0" },
}

export const SIZE_CHOICES = {
  "tiny": { label: "Tiny (Blue +11)", value: "+11" },
  "small": { label: "Small (Purple +7)", value: "+7" },
  "medium": { label: "Medium (Red +5)", value: "+5" },
  "large": { label: "Large (Yellow +1)", value: "+1" },
  "huge": { label: "Huge (0)", value: "0" }
}

export const RANGE_CHOICES = {
  "pointblank": { label: "Point Blank (Special)", value: "pointblank" },
  "short": { label: "Short (+0)", value: "0" },
  "medium": { label: "Medium (Red +5)", value: "+5" },
  "long": { label: "Long (Purle +7)", value: "+7" },
  "extreme": { label: "Extreme (Grey +9)", value: "+9" },
  "beyondskill": { label: "Beyond Skill (Blue +11)", value: "beyondskill" }
}

export const ATTACKER_AIM_CHOICES = {
  "simple": { label: "Simple (+0)", value: "0" },
  "careful": { label: "Careful (Red +5)", value: "+4" },
  "focused": { label: "Focused (Grey +9)", value: "+9" }
}

export const SPELL_LETHARGY_DICE = [
  { dice: "D6", level: "1-5", value: "6", maxLevel: 5 },
  { dice: "D8", level: "6-10", value: "8", maxLevel: 10 },
  { dice: "D10", value: "10", level: "11-15", maxLevel: 15 },
  { dice: "D12", value: "12", level: "16-20", maxLevel: 20 },
  { dice: "D20", value: "20", level: "21-25", maxLevel: 25 }
]

export const GRANTED_DICE_CHOICES = {
  "0": { label: "None", value: "0" },
  "D2": { label: "D2", value: "D2" },
  "D3": { label: "D3", value: "D3" },
  "D4": { label: "D4", value: "D4" },
  "D6": { label: "D6", value: "D6" },
  "D8": { label: "D8", value: "D8" },
  "D10": { label: "D10", value: "D10" },
  "D12": { label: "D12", value: "D12" },
  "D20": { label: "D20", value: "D20" }
}

export const INITIATIVE_DICE_CHOICES_PER_CLASS = {
  "untrained": [
    { "name": "Asleep or totally distracted (2D12)", "value": "2D12" },
    { "name": "Awake but unsuspecting (2D8)", "value": "2D8" },
    { "name": "Declared Ready on Alert (2D6)", "value": "2D6" },
    /*{ "name": "Aware of the enemy, can hear them but not see (2D4)", "value": "2D4" },
    { "name": "Aware and know exactly where the enemy is (2D3)", "value": "2D3" }*/
  ],
  "fighter": [
    { "name": "Asleep or totally distracted (1D12)", "value": "1D12" },
    { "name": "Awake but unsuspecting (1D8)", "value": "1D8" },
    { "name": "Declared Ready on Alert (1)", "value": "1" },
    /*{ "name": "Aware of the enemy, can hear them but not see (1D4)", "value": "1D4" },
    { "name": "Aware and know exactly where the enemy is (1D3)", "value": "1D3" }*/
  ],
  "rogue": [
    { "name": "Asleep or totally distracted (1D10)", "value": "1D10" },
    { "name": "Awake but unsuspecting (1D8)", "value": "1D8" },
    { "name": "Declared Ready on Alert (1)", "value": "1" },
    /*{ "name": "Aware of the enemy, can hear them but not see (1D3)", "value": "1D3" },
    { "name": "Aware and know exactly where the enemy is (1D2)", "value": "1D2" }*/
  ],
  "ranger": [
    { "name": "Asleep or totally distracted (1D10)", "value": "1D10" },
    { "name": "Awake but unsuspecting (1D8)", "value": "1D8" },
    { "name": "Declared Ready on Alert (1)", "value": "1" },
    /*{ "name": "Aware of the enemy, can hear them but not see (1D4)", "value": "1D4" },
    { "name": "Aware and know exactly where the enemy is (1D3)", "value": "1D3" }*/
  ],
  "cleric": [
    { "name": "Asleep or totally distracted (1D12)", "value": "1D12" },
    { "name": "Awake but unsuspecting (1D10)", "value": "1D10" },
    { "name": "Declared Ready on Alert (1)", "value": "1" },
    /*{ "name": "Aware of the enemy, can hear them but not see (1D6)", "value": "1D6" },
    { "name": "Aware and know exactly where the enemy is (1D4)", "value": "1D4" }*/
  ],
  "magicuser": [
    { "name": "Sleeping to recover Mana Points (2D20)", "value": "2D20" },
    { "name": "Asleep or totally distracted (1D20)", "value": "1D20" },
    { "name": "Awake but unsuspecting (1D12)", "value": "1D12" },
    { "name": "Declared Ready on Alert (1)", "value": "1" },
    /*{ "name": "Aware of the enemy, can hear them but not see (1D8)", "value": "1D8" },
    { "name": "Aware and know exactly where the enemy is (1D6)", "value": "1D6" }*/
  ]
}

export const CHAR_CLASSES = {
  "untrained": "Untrained",
  "fighter": "Fighter",
  "rogue": "Rogue",
  "ranger": "Ranger",
  "cleric": "Cleric",
  "magicuser": "Magic User"
}

export const CHAR_CLASSES_DEFINES = {
  "untrained": { id: "untrained", label: "Untrained" },
  "fighter": { id: "fighter", label: "Fighter" },
  "rogue": { id: "rogue", label: "Rogue" },
  "ranger": { id: "ranger", label: "Ranger" },
  "cleric": { id: "cleric", label: "Cleric" },
  "magicuser": { id: "magicuser", label: "Magic User" }
}

export const DICE_VALUES = {
  "d3": "D3",
  "d4": "D4",
  "d6": "D6",
  "d8": "D8",
  "d10": "D10",
  "d12": "D12",
  "d20": "D20"
}

export const CHARACTERISTIC_ATTACK = ["str", "int", "wis", "dex"]
export const CHARACTERISTIC_RANGED_ATTACK = ["int", "wis", "dex"]
export const CHARACTERISTIC_DEFENSE = ["int", "wis", "dex"]
export const CHARACTERISTIC_DAMAGE = ["str"]

export const DEFENSE_DICE_VALUES = {
  "0": "0",
  "d3": "D3",
  "d4": "D4",
  "d6": "D6",
  "d8": "D8",
  "d10": "D10"
}

export const CHOICE_DICE = {
  "D4": "D4",
  "D6": "D6",
  "D8": "D8",
  "D10": "D10",
  "D12": "D12",
  "D20": "D20"
}

export const MIRACLE_TYPES = {
  "combat": "Combat",
  "noncombat": "Non-Combat",
  "ritualfaith": "Ritual of Faith"
}

export const CHOICE_MODIFIERS = {
  "-9": "-9",
  "-8": "-8",
  "-7": "-7",
  "-6": "-6",
  "-5": "-5",
  "-4": "-4",
  "-3": "-3",
  "-2": "-2",
  "-1": "-1",
  "+0": "0",
  "+1": "+1",
  "+2": "+2",
  "+3": "+3",
  "+4": "+4",
  "+5": "+5",
  "+6": "+6",
  "+7": "+7",
  "+8": "+8",
  "+9": "+9",
  "+10": "+10",
  "+11": "+11",
  "+12": "+12",
  "+13": "+13",
  "+14": "+14",
  "+15": "+15",
  "+16": "+16",
  "+17": "+17",
  "+18": "+18",
  "+19": "+19",
  "+20": "+20",
  "+21": "+21",
  "+22": "+22",
  "+23": "+23",
  "+24": "+24",
  "+25": "+25"
}

export const ASCII = `


┌─────────────────────────────────────────────────────┐
│8888888b.  8888888b.  8888888 .d8888b.  888b     d888│
│888   Y88b 888   Y88b   888  d88P  Y88b 8888b   d8888│
│888    888 888    888   888  Y88b.      88888b.d88888│
│888   d88P 888   d88P   888   "Y888b.   888Y88888P888│
│8888888P"  8888888P"    888      "Y88b. 888 Y888P 888│
│888        888 T88b     888        "888 888  Y8P  888│
│888        888  T88b    888  Y88b  d88P 888   "   888│
│888        888   T88b 8888888 "Y8888P"  888       888│
│                                                     │
│                                                     │
│                                                     │
│8888888b.  8888888b.   .d8888b.                      │
│888   Y88b 888   Y88b d88P  Y88b                     │
│888    888 888    888 888    888                     │
│888   d88P 888   d88P 888                            │
│8888888P"  8888888P"  888  88888                     │
│888 T88b   888        888    888                     │
│888  T88b  888        Y88b  d88P                     │
│888   T88b 888         "Y8888P88                     │
└─────────────────────────────────────────────────────┘
`

/**
 * Include all constant definitions within the SYSTEM global export
 * @type {Object}
 */
export const SYSTEM = {
  id: SYSTEM_ID,
  CHARACTERISTICS: CHARACTER.CHARACTERISTICS,
  SUB_ATTRIBUTES: CHARACTER.SUB_ATTRIBUTES,
  CHARACTERISTICS_TABLES: CHARACTERISTICS.TABLES,
  CHARACTERISTICS_MAJOR: CHARACTERISTICS.MAJOR,
  MONSTER_CHARACTERISTICS: MONSTER.MONSTER_CHARACTERISTICS,
  MONSTER_RESIST: MONSTER.MONSTER_RESIST,
  MONSTER_SAVES: MONSTER.MONSTER_SAVES,
  SAVES: CHARACTER.SAVES,
  CHALLENGES: CHARACTER.CHALLENGES,
  SKILL_CATEGORY: SKILL.CATEGORY,
  CORE_SKILLS: SKILL.CORE_SKILLS,
  CORE_SKILLS_CHOICES: SKILL.CORE_SKILLS_CHOICES,
  CORE_SKILL_BONUS: SKILL.CORE_SKILL_BONUS,
  ARMOR_TYPE: ARMOR.TYPE,
  ARMOR_BASE_AC: ARMOR.BASE_AC,
  ARMOR_AC_BONUS_ATTRIBUTES: ARMOR.AC_BONUS_ATTRIBUTES,
  ARMOR_WITHSTAND_APC: ARMOR.WITHSTAND_APC,
  ARMOR_SET_REQUIREMENTS: ARMOR.SET_REQUIREMENTS,
  SHIELD_TYPE: SHIELD.TYPE,
  SHIELD_TYPE_CHOICES: SHIELD.TYPE_CHOICES,
  SHIELD_BLOCK_AUGMENTS: SHIELD.BLOCK_AUGMENTS,
  EQUIPMENT_CATEGORY: EQUIPMENT.CATEGORY,
  SPELL_RANGE: SPELL.RANGE,
  SPELL_COLORS: SPELL.COLORS,
  SPELL_COLORS_CHOICES: SPELL.COLORS_CHOICES,
  WEAPON_TYPE: WEAPON.TYPE,
  WEAPON_TYPE_CHOICES: WEAPON.TYPE_CHOICES,
  WEAPON_GROUP: WEAPON.WEAPON_GROUP,
  WEAPON_GROUP_CHOICES: WEAPON.WEAPON_GROUP_CHOICES,
  WEAPON_DAMAGE_TYPE: WEAPON.DAMAGE_TYPE,
  WEAPON_CLASS: WEAPON.WEAPON_CLASS,
  COMBAT_PROGRESSION_DICE: DICE_VALUES,
  WEAPON_CATEGORIES: WEAPON.WEAPON_CATEGORIES,
  CHARACTERISTIC_ATTACK,
  CHARACTERISTIC_RANGED_ATTACK,
  CHARACTERISTIC_DEFENSE,
  CHARACTERISTIC_DAMAGE,
  INITIATIVE_DICE_CHOICES_PER_CLASS,
  CHAR_CLASSES,
  CHAR_CLASSES_DEFINES,
  MONEY,
  ASCII,
  CHOICE_MODIFIERS,
  CHOICE_DICE,
  DEV_MODE,
  MOVEMENT_CHOICES,
  MOVE_DIRECTION_CHOICES,
  SIZE_CHOICES,
  RANGE_CHOICES,
  ADVANTAGE_CHOICES,
  ATTACKER_AIM_CHOICES,
  MORTAL_CHOICES,
  MIRACLE_TYPES,
  SPELL_LETHARGY_DICE,
  GRANTED_DICE_CHOICES,
  RACE_SIZE: RACE.SIZE,
  RACE_AGE_CATEGORY: RACE.AGE_CATEGORY,
  CLASS_ARCHETYPE: CLASS.ARCHETYPE,
  CLASS_TYPE: CLASS.CLASS_TYPE,
  CLASS_SPELLCASTING_TYPE: CLASS.SPELLCASTING_TYPE
}
