export const compendiumJournals = {
    welcome: 'Compendium.daggerheart.journals.JournalEntry.g7NhKvwltwafmMyR'
};

export const ruleChoice = {
    on: {
        id: 'on',
        label: 'DAGGERHEART.CONFIG.RuleChoice.on'
    },
    of: {
        id: 'off',
        label: 'DAGGERHEART.CONFIG.RuleChoice.off'
    },
    onWithToggle: {
        id: 'onWithToggle',
        label: 'DAGGERHEART.CONFIG.RuleChoice.onWithToggle'
    },
    offWithToggle: {
        id: 'offWithToggle',
        label: 'DAGGERHEART.CONFIG.RuleChoice.offWithToggle'
    }
};

export const templateRanges = {
    self: {
        id: 'self',
        short: 's',
        label: 'DAGGERHEART.CONFIG.Range.self.name',
        description: 'DAGGERHEART.CONFIG.Range.self.description',
        distance: 0
    },
    melee: {
        id: 'melee',
        short: 'm',
        label: 'DAGGERHEART.CONFIG.Range.melee.name',
        description: 'DAGGERHEART.CONFIG.Range.melee.description',
        distance: 1
    },
    veryClose: {
        id: 'veryClose',
        short: 'vc',
        label: 'DAGGERHEART.CONFIG.Range.veryClose.name',
        description: 'DAGGERHEART.CONFIG.Range.veryClose.description',
        distance: 3
    },
    close: {
        id: 'close',
        short: 'c',
        label: 'DAGGERHEART.CONFIG.Range.close.name',
        description: 'DAGGERHEART.CONFIG.Range.close.description',
        distance: 10
    },
    far: {
        id: 'far',
        short: 'f',
        label: 'DAGGERHEART.CONFIG.Range.far.name',
        description: 'DAGGERHEART.CONFIG.Range.far.description',
        distance: 20
    }
};

export const range = {
    ...templateRanges,
    veryFar: {
        id: 'veryFar',
        short: 'vf',
        label: 'DAGGERHEART.CONFIG.Range.veryFar.name',
        description: 'DAGGERHEART.CONFIG.Range.veryFar.description',
        distance: 30
    }
};

export const groupAttackRange = {
    melee: range.melee,
    veryClose: range.veryClose,
    close: range.close,
    far: range.far,
    veryFar: range.veryFar
};

/* circle|cone|rect|ray used to be CONST.MEASURED_TEMPLATE_TYPES. Hardcoded for now */
export const templateTypes = {
    circle: {
        id: 'circle',
        label: 'Circle'
    },
    cone: {
        id: 'cone',
        label: 'Cone'
    },
    rectangle: {
        id: 'rectangle',
        label: 'Rectangle'
    },
    line: {
        id: 'line',
        label: 'Line'
    },
    emanation: {
        id: 'emanation',
        label: 'Emanation'
    },
    inFront: {
        id: 'inFront',
        label: 'In Front'
    }
};

export const rangeInclusion = {
    withinRange: {
        id: 'withinRange',
        label: 'DAGGERHEART.CONFIG.RangeInclusion.withinRange'
    },
    outsideRange: {
        id: 'outsideRange',
        label: 'DAGGERHEART.CONFIG.RangeInclusion.outsideRange'
    }
};

export const otherTargetTypes = {
    friendly: {
        id: 'friendly',
        label: 'DAGGERHEART.CONFIG.TargetTypes.friendly'
    },
    hostile: {
        id: 'hostile',
        label: 'DAGGERHEART.CONFIG.TargetTypes.hostile'
    },
    any: {
        id: 'any',
        label: 'DAGGERHEART.CONFIG.TargetTypes.any'
    }
};

export const targetTypes = {
    self: {
        id: 'self',
        label: 'DAGGERHEART.CONFIG.TargetTypes.self'
    },
    ...otherTargetTypes
};

export const burden = {
    oneHanded: {
        value: 'oneHanded',
        label: 'DAGGERHEART.CONFIG.Burden.oneHanded'
    },
    twoHanded: {
        value: 'twoHanded',
        label: 'DAGGERHEART.CONFIG.Burden.twoHanded'
    }
};

export const damageTypes = {
    physical: {
        id: 'physical',
        label: 'DAGGERHEART.CONFIG.DamageType.physical.name',
        abbreviation: 'DAGGERHEART.CONFIG.DamageType.physical.abbreviation',
        icon: 'fa-hand-fist'
    },
    magical: {
        id: 'magical',
        label: 'DAGGERHEART.CONFIG.DamageType.magical.name',
        abbreviation: 'DAGGERHEART.CONFIG.DamageType.magical.abbreviation',
        icon: 'fa-wand-sparkles'
    }
};

export const healingTypes = {
    hitPoints: {
        id: 'hitPoints',
        label: 'DAGGERHEART.CONFIG.HealingType.hitPoints.name',
        abbreviation: 'DAGGERHEART.CONFIG.HealingType.hitPoints.abbreviation'
    },
    stress: {
        id: 'stress',
        label: 'DAGGERHEART.CONFIG.HealingType.stress.name',
        abbreviation: 'DAGGERHEART.CONFIG.HealingType.stress.abbreviation'
    },
    hope: {
        id: 'hope',
        label: 'DAGGERHEART.CONFIG.HealingType.hope.name',
        abbreviation: 'DAGGERHEART.CONFIG.HealingType.hope.abbreviation'
    },
    armor: {
        id: 'armor',
        label: 'DAGGERHEART.CONFIG.HealingType.armor.name',
        abbreviation: 'DAGGERHEART.CONFIG.HealingType.armor.abbreviation'
    },
    fear: {
        id: 'fear',
        label: 'DAGGERHEART.CONFIG.HealingType.fear.name',
        abbreviation: 'DAGGERHEART.CONFIG.HealingType.fear.abbreviation'
    }
};

export const defeatedConditions = () => {
    const defeated = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).defeated;
    return Object.keys(defeatedConditionChoices).reduce((acc, key) => {
        const choice = defeatedConditionChoices[key];
        acc[key] = {
            ...choice,
            img: defeated[`${choice.id}Icon`],
            description: game.i18n.localize(`DAGGERHEART.CONFIG.Condition.${choice.id}.description`)
        };

        return acc;
    }, {});
};

export const defeatedConditionChoices = {
    deathMove: {
        id: 'deathMove',
        name: 'DAGGERHEART.CONFIG.Condition.deathMove.name'
    },
    defeated: {
        id: 'defeated',
        name: 'DAGGERHEART.CONFIG.Condition.defeated.name'
    },
    unconscious: {
        id: 'unconscious',
        name: 'DAGGERHEART.CONFIG.Condition.unconscious.name'
    },
    dead: {
        id: 'dead',
        name: 'DAGGERHEART.CONFIG.Condition.dead.name'
    }
};

export const conditions = () => ({
    vulnerable: {
        id: 'vulnerable',
        name: 'DAGGERHEART.CONFIG.Condition.vulnerable.name',
        img: 'icons/magic/control/silhouette-fall-slip-prone.webp',
        description: 'DAGGERHEART.CONFIG.Condition.vulnerable.description',
        autoApplyFlagId: 'auto-vulnerable'
    },
    hidden: {
        id: 'hidden',
        name: 'DAGGERHEART.CONFIG.Condition.hidden.name',
        img: 'icons/magic/perception/silhouette-stealth-shadow.webp',
        description: 'DAGGERHEART.CONFIG.Condition.hidden.description'
    },
    restrained: {
        id: 'restrained',
        name: 'DAGGERHEART.CONFIG.Condition.restrained.name',
        img: 'icons/magic/control/debuff-chains-shackle-movement-red.webp',
        description: 'DAGGERHEART.CONFIG.Condition.restrained.description'
    },
    ...defeatedConditions()
});

export const defaultRestOptions = {
    shortRest: () => ({
        tendToWounds: {
            id: 'tendToWounds',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.name'),
            icon: 'fa-solid fa-bandage',
            img: 'icons/magic/life/cross-worn-green.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.description'),
            actions: {
                tendToWounds: {
                    type: 'healing',
                    systemPath: 'restMoves.shortRest.moves.tendToWounds.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.name'),
                    img: 'icons/magic/life/cross-worn-green.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        amount: 1,
                        type: 'friendly'
                    },
                    damage: {
                        parts: {
                            hitPoints: {
                                applyTo: healingTypes.hitPoints.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '1d4 + @tier'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        clearStress: {
            id: 'clearStress',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.name'),
            icon: 'fa-regular fa-face-surprise',
            img: 'icons/magic/perception/eye-ringed-green.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.description'),
            actions: {
                clearStress: {
                    type: 'healing',
                    systemPath: 'restMoves.shortRest.moves.clearStress.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.name'),
                    img: 'icons/magic/perception/eye-ringed-green.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        type: 'self'
                    },
                    damage: {
                        parts: {
                            stress: {
                                applyTo: healingTypes.stress.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '1d4 + @tier'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        repairArmor: {
            id: 'repairArmor',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'),
            icon: 'fa-solid fa-hammer',
            img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.description'),
            actions: {
                repairArmor: {
                    type: 'healing',
                    systemPath: 'restMoves.shortRest.moves.repairArmor.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'),
                    img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        amount: 1,
                        type: 'friendly'
                    },
                    damage: {
                        parts: {
                            armor: {
                                applyTo: healingTypes.armor.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '1d4 + @tier'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        prepare: {
            id: 'prepare',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.prepare.name'),
            icon: 'fa-solid fa-dumbbell',
            img: 'icons/skills/trades/academics-merchant-scribe.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.prepare.description'),
            actions: {
                prepare: {
                    type: 'healing',
                    systemPath: 'restMoves.shortRest.moves.prepare.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.prepare.name'),
                    img: 'icons/skills/trades/academics-merchant-scribe.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        type: 'self'
                    },
                    damage: {
                        parts: {
                            hope: {
                                applyTo: healingTypes.hope.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '1'
                                    }
                                }
                            }
                        }
                    }
                },
                prepareWithFriends: {
                    type: 'healing',
                    systemPath: 'restMoves.shortRest.moves.prepare.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.prepareWithFriends.name'),
                    img: 'icons/skills/trades/academics-merchant-scribe.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        type: 'self'
                    },
                    damage: {
                        parts: {
                            hope: {
                                applyTo: healingTypes.hope.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '2'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        }
    }),
    longRest: () => ({
        tendToWounds: {
            id: 'tendToWounds',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.tendToWounds.name'),
            icon: 'fa-solid fa-bandage',
            img: 'icons/magic/life/cross-worn-green.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.tendToWounds.description'),
            actions: {
                tendToWounds: {
                    type: 'healing',
                    systemPath: 'restMoves.longRest.moves.tendToWounds.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.tendToWounds.name'),
                    img: 'icons/magic/life/cross-worn-green.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        amount: 1,
                        type: 'friendly'
                    },
                    damage: {
                        parts: {
                            hitPoints: {
                                applyTo: healingTypes.hitPoints.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '@system.resources.hitPoints.max'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        clearStress: {
            id: 'clearStress',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.clearStress.name'),
            icon: 'fa-regular fa-face-surprise',
            img: 'icons/magic/perception/eye-ringed-green.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.clearStress.description'),
            actions: {
                clearStress: {
                    type: 'healing',
                    systemPath: 'restMoves.longRest.moves.clearStress.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.clearStress.name'),
                    img: 'icons/magic/perception/eye-ringed-green.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        type: 'self'
                    },
                    damage: {
                        parts: {
                            stress: {
                                applyTo: healingTypes.stress.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '@system.resources.stress.max'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        repairArmor: {
            id: 'repairArmor',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.repairArmor.name'),
            icon: 'fa-solid fa-hammer',
            img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.repairArmor.description'),
            actions: {
                repairArmor: {
                    type: 'healing',
                    systemPath: 'restMoves.longRest.moves.repairArmor.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.repairArmor.name'),
                    img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        amount: 1,
                        type: 'friendly'
                    },
                    damage: {
                        parts: {
                            armor: {
                                applyTo: healingTypes.armor.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '@system.armorScore.max'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        prepare: {
            id: 'prepare',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.prepare.name'),
            icon: 'fa-solid fa-dumbbell',
            img: 'icons/skills/trades/academics-merchant-scribe.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.prepare.description'),
            actions: {
                prepare: {
                    type: 'healing',
                    systemPath: 'restMoves.longRest.moves.prepare.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.prepare.name'),
                    img: 'icons/skills/trades/academics-merchant-scribe.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        type: 'self'
                    },
                    damage: {
                        parts: {
                            hope: {
                                applyTo: healingTypes.hope.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '1'
                                    }
                                }
                            }
                        }
                    }
                },
                prepareWithFriends: {
                    type: 'healing',
                    systemPath: 'restMoves.longRest.moves.prepare.actions',
                    name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.prepareWithFriends.name'),
                    img: 'icons/skills/trades/academics-merchant-scribe.webp',
                    actionType: 'action',
                    chatDisplay: false,
                    target: {
                        type: 'self'
                    },
                    damage: {
                        parts: {
                            hope: {
                                applyTo: healingTypes.hope.id,
                                value: {
                                    custom: {
                                        enabled: true,
                                        formula: '2'
                                    }
                                }
                            }
                        }
                    }
                }
            },
            effects: []
        },
        workOnAProject: {
            id: 'workOnAProject',
            name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.workOnAProject.name'),
            icon: 'fa-solid fa-diagram-project',
            img: 'icons/skills/social/thumbsup-approval-like.webp',
            description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.workOnAProject.description'),
            actions: {},
            effects: []
        }
    })
};

export const deathMoves = {
    avoidDeath: {
        id: 'avoidDeath',
        name: 'DAGGERHEART.CONFIG.DeathMoves.avoidDeath.name',
        img: 'icons/magic/time/hourglass-yellow-green.webp',
        icon: 'fa-person-running',
        description: 'DAGGERHEART.CONFIG.DeathMoves.avoidDeath.description'
    },
    riskItAll: {
        id: 'riskItAll',
        name: 'DAGGERHEART.CONFIG.DeathMoves.riskItAll.name',
        img: 'icons/sundries/gaming/dice-pair-white-green.webp',
        icon: 'fa-dice',
        description: 'DAGGERHEART.CONFIG.DeathMoves.riskItAll.description'
    },
    blazeOfGlory: {
        id: 'blazeOfGlory',
        name: 'DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.name',
        img: 'icons/magic/life/heart-cross-strong-flame-purple-orange.webp',
        icon: 'fa-burst',
        description: 'DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.description'
    }
};

export const tiers = {
    1: {
        id: 1,
        label: 'DAGGERHEART.GENERAL.Tiers.1'
    },
    2: {
        id: 2,
        label: 'DAGGERHEART.GENERAL.Tiers.2'
    },
    3: {
        id: 3,
        label: 'DAGGERHEART.GENERAL.Tiers.3'
    },
    4: {
        id: 4,
        label: 'DAGGERHEART.GENERAL.Tiers.4'
    }
};

export const diceTypes = {
    d4: 'd4',
    d6: 'd6',
    d8: 'd8',
    d10: 'd10',
    d12: 'd12',
    d20: 'd20'
};

export const dieFaces = [4, 6, 8, 10, 12, 20];

export const multiplierTypes = {
    prof: 'Proficiency',
    cast: 'Spellcast',
    scale: 'Cost Scaling',
    result: 'Roll Result',
    flat: 'Flat',
    tier: 'Tier'
};

export const diceSetNumbers = {
    prof: 'Proficiency',
    cast: 'Spellcast',
    scale: 'Cost Scaling',
    flat: 'Flat'
};

export const diceSoNiceSFXClasses = {
    PlayAnimationBright: {
        id: 'PlayAnimationBright',
        label: 'DICESONICE.PlayAnimationBright'
    },
    PlayAnimationDark: {
        id: 'PlayAnimationDark',
        label: 'DICESONICE.PlayAnimationDark'
    },
    PlayAnimationOutline: {
        id: 'PlayAnimationOutline',
        label: 'DICESONICE.PlayAnimationOutline'
    },
    PlayAnimationImpact: {
        id: 'PlayAnimationImpact',
        label: 'DICESONICE.PlayAnimationImpact'
    },
    // PlayConfettiStrength1: {
    //     id: 'PlayConfettiStrength1',
    //     label: 'DICESONICE.PlayConfettiStrength1'
    // },
    // PlayConfettiStrength2: {
    //     id: 'PlayConfettiStrength2',
    //     label: 'DICESONICE.PlayConfettiStrength2'
    // },
    // PlayConfettiStrength3: {
    //     id: 'PlayConfettiStrength3',
    //     label: 'DICESONICE.PlayConfettiStrength3'
    // },
    PlayAnimationThormund: {
        id: 'PlayAnimationThormund',
        label: 'DICESONICE.PlayAnimationThormund'
    },
    PlayAnimationParticleSpiral: {
        id: 'PlayAnimationParticleSpiral',
        label: 'DICESONICE.PlayAnimationParticleSpiral'
    },
    PlayAnimationParticleSparkles: {
        id: 'PlayAnimationParticleSparkles',
        label: 'DICESONICE.PlayAnimationParticleSparkles'
    },
    PlayAnimationParticleVortex: {
        id: 'PlayAnimationParticleVortex',
        label: 'DICESONICE.PlayAnimationParticleVortex'
    },
    PlaySoundEpicWin: {
        id: 'PlaySoundEpicWin',
        label: 'DICESONICE.PlaySoundEpicWin'
    },
    PlaySoundEpicFail: {
        id: 'PlaySoundEpicFail',
        label: 'DICESONICE.PlaySoundEpicFail'
    }
    // "PlaySoundCustom",
    // "PlayMacro"
};

export const daggerheartDiceAnimationEvents = {
    critical: {
        id: 'critical',
        label: 'DAGGERHEART.CONFIG.DaggerheartDiceAnimationEvents.critical.name'
    },
    higher: {
        id: 'higher',
        label: 'DAGGERHEART.CONFIG.DaggerheartDiceAnimationEvents.higher.name'
    }
};

const getDiceSoNiceSFX = sfxOptions => {
    const diceSoNice = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).diceSoNiceData;
    const criticalAnimationData = diceSoNice.sfx.critical;
    if (sfxOptions.critical && criticalAnimationData.class) {
        return {
            specialEffect: criticalAnimationData.class,
            options: { ...criticalAnimationData.options }
        };
    }

    if (sfxOptions.higher && sfxOptions.data.higher) {
        return {
            specialEffect: sfxOptions.data.higher.class,
            options: { ...sfxOptions.data.higher.options }
        };
    }

    return {};
};

export const getDiceSoNicePreset = async (type, faces, sfxOptions = {}) => {
    const system = game.dice3d.DiceFactory.systems.get(type.system).dice.get(faces);
    if (!system) {
        ui.notifications.error(
            game.i18n.format('DAGGERHEART.UI.Notifications.noDiceSystem', {
                system: game.dice3d.DiceFactory.systems.get(type.system).name,
                faces: faces
            })
        );
        return;
    }

    if (system.modelFile && !system.modelLoaded) {
        await system.loadModel(game.dice3d.DiceFactory.loaderGLTF);
    } else {
        await system.loadTextures();
    }

    return {
        modelFile: system.modelFile,
        appearance: {
            ...system.appearance,
            ...type
        },
        sfx: getDiceSoNiceSFX(sfxOptions)
    };
};

export const getDiceSoNicePresets = async (
    result,
    hopeFaces,
    fearFaces,
    advantageFaces = 'd6',
    disadvantageFaces = 'd6'
) => {
    const diceSoNice = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).diceSoNiceData;

    const { isCritical, withHope, withFear } = result;

    return {
        hope: await getDiceSoNicePreset(diceSoNice.hope, hopeFaces, {
            critical: isCritical,
            higher: withHope,
            data: diceSoNice.hope.sfx
        }),
        fear: await getDiceSoNicePreset(diceSoNice.fear, fearFaces, {
            critical: isCritical,
            higher: withFear,
            data: diceSoNice.fear.sfx
        }),
        advantage: await getDiceSoNicePreset(diceSoNice.advantage, advantageFaces),
        disadvantage: await getDiceSoNicePreset(diceSoNice.disadvantage, disadvantageFaces)
    };
};

export const refreshTypes = {
    scene: {
        id: 'session',
        label: 'DAGGERHEART.GENERAL.RefreshType.scene'
    },
    session: {
        id: 'session',
        label: 'DAGGERHEART.GENERAL.RefreshType.session'
    },
    shortRest: {
        id: 'shortRest',
        label: 'DAGGERHEART.GENERAL.RefreshType.shortrest'
    },
    longRest: {
        id: 'longRest',
        label: 'DAGGERHEART.GENERAL.RefreshType.longrest'
    }
};

export const itemAbilityCosts = {
    resource: {
        id: 'resource',
        label: 'DAGGERHEART.GENERAL.resource',
        group: 'Global'
    },
    quantity: {
        id: 'quantity',
        label: 'DAGGERHEART.GENERAL.quantity',
        group: 'Global'
    }
};

export const abilityCosts = {
    hitPoints: {
        id: 'hitPoints',
        label: 'DAGGERHEART.CONFIG.HealingType.hitPoints.name',
        group: 'Global'
    },
    stress: {
        id: 'stress',
        label: 'DAGGERHEART.CONFIG.HealingType.stress.name',
        group: 'Global'
    },
    hope: {
        id: 'hope',
        label: 'DAGGERHEART.CONFIG.HealingType.hope.name',
        group: 'TYPES.Actor.character'
    },
    armor: {
        id: 'armor',
        label: 'DAGGERHEART.CONFIG.HealingType.armor.name',
        group: 'TYPES.Actor.character'
    },
    fear: {
        id: 'fear',
        label: 'DAGGERHEART.CONFIG.HealingType.fear.name',
        group: 'TYPES.Actor.adversary'
    },
    resource: itemAbilityCosts.resource
};

export const countdownProgressionTypes = {
    actionRoll: {
        id: 'actionRoll',
        label: 'DAGGERHEART.CONFIG.CountdownType.actionRoll'
    },
    characterAttack: {
        id: 'characterAttack',
        label: 'DAGGERHEART.CONFIG.CountdownType.characterAttack'
    },
    characterSpotlight: {
        id: 'characterSpotlight',
        label: 'DAGGERHEART.CONFIG.CountdownType.characterSpotlight'
    },
    custom: {
        id: 'custom',
        label: 'DAGGERHEART.CONFIG.CountdownType.custom'
    },
    fear: {
        id: 'fear',
        label: 'DAGGERHEART.CONFIG.CountdownType.fear'
    },
    spotlight: {
        id: 'spotlight',
        label: 'DAGGERHEART.CONFIG.CountdownType.spotlight'
    }
};
export const rollTypes = {
    attack: {
        id: 'attack',
        label: 'DAGGERHEART.CONFIG.RollTypes.attack.name'
    },
    spellcast: {
        id: 'spellcast',
        label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name',
        playerOnly: true
    },
    trait: {
        id: 'trait',
        label: 'DAGGERHEART.CONFIG.RollTypes.trait.name',
        playerOnly: true
    },
    diceSet: {
        id: 'diceSet',
        label: 'DAGGERHEART.CONFIG.RollTypes.diceSet.name'
    }
};

export const attributionSources = {
    daggerheart: {
        label: 'Daggerheart',
        values: [{ label: 'Daggerheart SRD' }]
    }
};

export const fearDisplay = {
    token: { value: 'token', label: 'DAGGERHEART.SETTINGS.Appearance.fearDisplay.token' },
    bar: { value: 'bar', label: 'DAGGERHEART.SETTINGS.Appearance.fearDisplay.bar' },
    hide: { value: 'hide', label: 'DAGGERHEART.SETTINGS.Appearance.fearDisplay.hide' }
};

export const basicOwnershiplevels = {
    0: { value: 0, label: 'OWNERSHIP.NONE' },
    2: { value: 2, label: 'OWNERSHIP.OBSERVER' },
    3: { value: 3, label: 'OWNERSHIP.OWNER' }
};

export const simpleOwnershiplevels = {
    [-1]: { value: -1, label: 'OWNERSHIP.INHERIT' },
    ...basicOwnershiplevels
};

export const countdownBaseTypes = {
    narrative: {
        id: 'narrative',
        label: 'DAGGERHEART.APPLICATIONS.Countdown.types.narrative'
    },
    encounter: {
        id: 'encounter',
        label: 'DAGGERHEART.APPLICATIONS.Countdown.types.encounter'
    }
};

export const countdownLoopingTypes = {
    noLooping: {
        id: 'noLooping',
        label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.noLooping'
    },
    looping: {
        id: 'looping',
        label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.looping'
    },
    increasing: {
        id: 'increasing',
        label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.increasing'
    },
    decreasing: {
        id: 'decreasing',
        label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.decreasing'
    }
};

export const countdownAppMode = {
    textIcon: 'text-icon',
    iconOnly: 'icon-only'
};

export const sceneRangeMeasurementSetting = {
    disable: {
        id: 'disable',
        label: 'DAGGERHEART.CONFIG.SceneRangeMeasurementTypes.disable'
    },
    default: {
        id: 'default',
        label: 'DAGGERHEART.CONFIG.SceneRangeMeasurementTypes.default'
    },
    custom: {
        id: 'custom',
        label: 'DAGGERHEART.CONFIG.SceneRangeMeasurementTypes.custom'
    }
};

export const tagTeamRollTypes = {
    trait: {
        id: 'trait',
        label: 'DAGGERHEART.CONFIG.TagTeamRollTypes.trait'
    },
    ability: {
        id: 'ability',
        label: 'DAGGERHEART.CONFIG.TagTeamRollTypes.ability'
    },
    damageAbility: {
        id: 'damageAbility',
        label: 'DAGGERHEART.CONFIG.TagTeamRollTypes.damageAbility'
    }
};

export const baseActiveEffectModes = {
    custom: {
        id: 'custom',
        priority: 0,
        label: 'EFFECT.CHANGES.TYPES.custom'
    },
    multiply: {
        id: 'multiply',
        priority: 10,
        label: 'EFFECT.CHANGES.TYPES.multiply'
    },
    add: {
        id: 'add',
        priority: 20,
        label: 'EFFECT.CHANGES.TYPES.add'
    },
    subtract: {
        id: 'subtract',
        priority: 20,
        label: 'EFFECT.CHANGES.TYPES.subtract'
    },
    downgrade: {
        id: 'downgrade',
        priority: 30,
        label: 'EFFECT.CHANGES.TYPES.downgrade'
    },
    upgrade: {
        id: 'upgrade',
        priority: 40,
        label: 'EFFECT.CHANGES.TYPES.upgrade'
    },
    override: {
        id: 'override',
        priority: 50,
        label: 'EFFECT.CHANGES.TYPES.override'
    }
};

export const activeEffectModes = {
    armor: {
        id: 'armor',
        priority: 20,
        label: 'TYPES.ActiveEffect.armor'
    },
    ...baseActiveEffectModes
};

export const activeEffectArmorInteraction = {
    none: { id: 'none', label: 'DAGGERHEART.CONFIG.ArmorInteraction.none.label' },
    active: { id: 'active', label: 'DAGGERHEART.CONFIG.ArmorInteraction.active.label' },
    inactive: { id: 'inactive', label: 'DAGGERHEART.CONFIG.ArmorInteraction.inactive.label' }
};

export const activeEffectDurations = {
    temporary: {
        id: 'temporary',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.temporary'
    },
    act: {
        id: 'act',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.act'
    },
    scene: {
        id: 'scene',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.scene'
    },
    shortRest: {
        id: 'shortRest',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.shortRest'
    },
    longRest: {
        id: 'longRest',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.longRest'
    },
    session: {
        id: 'session',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.session'
    },
    custom: {
        id: 'custom',
        label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.custom'
    }
};

export const fallAndCollisionDamage = {
    veryClose: {
        id: 'veryClose',
        label: 'DAGGERHEART.CONFIG.fallAndCollision.veryClose.label',
        chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.veryClose.chatTitle',
        damageFormula: '1d10 + 3'
    },
    close: {
        id: 'veryClose',
        label: 'DAGGERHEART.CONFIG.fallAndCollision.close.label',
        chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.close.chatTitle',
        damageFormula: '1d20 + 5'
    },
    far: {
        id: 'veryClose',
        label: 'DAGGERHEART.CONFIG.fallAndCollision.far.label',
        chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.far.chatTitle',
        damageFormula: '1d100 + 15'
    },
    collision: {
        id: 'veryClose',
        label: 'DAGGERHEART.CONFIG.fallAndCollision.collision.label',
        chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.collision.chatTitle',
        damageFormula: '1d20 + 5'
    }
};

export const simpleDispositions = {
    [-1]: {
        id: -1,
        label: 'TOKEN.DISPOSITION.HOSTILE'
    },
    [0]: {
        id: 0,
        label: 'TOKEN.DISPOSITION.NEUTRAL'
    },
    [1]: {
        id: 1,
        label: 'TOKEN.DISPOSITION.FRIENDLY'
    }
};
