// SPDX-FileCopyrightText: 2021 Johannes Loher
// SPDX-FileCopyrightText: 2021 Oliver Rümpelein
// SPDX-FileCopyrightText: 2021 Gesina Schwalbe
// SPDX-FileCopyrightText: 2021 Siegfried Krug
//
// SPDX-License-Identifier: MIT

import { DS4 } from "../../config";

import type { ModifiableDataBaseTotal, ResourceDataBaseTotalMax } from "../common/common-data";

export interface DS4ActorDataPropertiesDataBase {
  attributes: DS4ActorDataPropertiesDataAttributes;
  traits: DS4ActorDataPropertiesDataTraits;
  combatValues: DS4ActorDataPropertiesDataCombatValues;
  rolling: DS4ActorDataPropertiesDataRolling;
  checks: DS4ActorDataPropertiesDataChecks;
  armorValueSpellMalus: number;
}

type DS4ActorDataPropertiesDataAttributes = {
  [Key in keyof typeof DS4.i18n.attributes]: ModifiableDataBaseTotal<number>;
};

type DS4ActorDataPropertiesDataTraits = { [Key in keyof typeof DS4.i18n.traits]: ModifiableDataBaseTotal<number> };

type DS4ActorDataPropertiesDataCombatValues = {
  [Key in keyof typeof DS4.i18n.combatValues]: Key extends "hitPoints"
    ? ResourceDataBaseTotalMax<number>
    : ModifiableDataBaseTotal<number>;
};

interface DS4ActorDataPropertiesDataRolling {
  maximumCoupResult: number;
  minimumFumbleResult: number;
}

type DS4ActorDataPropertiesDataChecks = {
  [key in Check]: number;
};

export type Check = keyof typeof DS4.i18n.checks;

export function isCheck(value: string): value is Check {
  return Object.keys(DS4.i18n.checks).includes(value);
}
