2022-02-16 13:32:04 +01:00
|
|
|
// 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
|
|
|
|
|
2022-11-04 21:47:18 +01:00
|
|
|
import { DS4 } from "../../config";
|
2022-02-16 13:32:04 +01:00
|
|
|
|
2022-02-17 00:55:22 +01:00
|
|
|
import type { ModifiableData, ModifiableDataBase, ResourceData } from "../common/common-data";
|
|
|
|
|
2022-02-16 13:32:04 +01:00
|
|
|
export interface DS4ActorDataSourceDataBase {
|
2023-07-10 22:23:13 +02:00
|
|
|
attributes: DS4ActorDataSourceDataAttributes;
|
|
|
|
traits: DS4ActorDataSourceDataTraits;
|
|
|
|
combatValues: DS4ActorDataSourceDataCombatValues;
|
2022-02-16 13:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type DS4ActorDataSourceDataAttributes = { [Key in keyof typeof DS4.i18n.attributes]: ModifiableDataBase<number> };
|
|
|
|
|
|
|
|
type Attribute = keyof DS4ActorDataSourceDataAttributes;
|
|
|
|
|
|
|
|
export function isAttribute(value: unknown): value is Attribute {
|
2023-07-10 22:23:13 +02:00
|
|
|
return (Object.keys(DS4.i18n.attributes) as Array<unknown>).includes(value);
|
2022-02-16 13:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type DS4ActorDataSourceDataTraits = { [Key in keyof typeof DS4.i18n.traits]: ModifiableDataBase<number> };
|
|
|
|
|
|
|
|
type Trait = keyof DS4ActorDataSourceDataTraits;
|
|
|
|
|
|
|
|
export function isTrait(value: unknown): value is Trait {
|
2023-07-10 22:23:13 +02:00
|
|
|
return (Object.keys(DS4.i18n.traits) as Array<unknown>).includes(value);
|
2022-02-16 13:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type DS4ActorDataSourceDataCombatValues = {
|
2023-07-10 22:23:13 +02:00
|
|
|
[Key in keyof typeof DS4.i18n.combatValues]: Key extends "hitPoints" ? ResourceData<number> : ModifiableData<number>;
|
2022-02-16 13:32:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
type CombatValue = keyof DS4ActorDataSourceDataCombatValues;
|
|
|
|
|
|
|
|
export function isCombatValue(value: string): value is CombatValue {
|
2023-07-10 22:23:13 +02:00
|
|
|
return (Object.keys(DS4.i18n.combatValues) as Array<unknown>).includes(value);
|
2022-02-16 13:32:04 +01:00
|
|
|
}
|