44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
|
// 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 { ModifiableData, ModifiableDataBase, ResourceData } from "../common/common-data";
|
||
|
import { DS4 } from "../config";
|
||
|
|
||
|
export interface DS4ActorDataSourceDataBase {
|
||
|
attributes: DS4ActorDataSourceDataAttributes;
|
||
|
traits: DS4ActorDataSourceDataTraits;
|
||
|
combatValues: DS4ActorDataSourceDataCombatValues;
|
||
|
}
|
||
|
|
||
|
type DS4ActorDataSourceDataAttributes = { [Key in keyof typeof DS4.i18n.attributes]: ModifiableDataBase<number> };
|
||
|
|
||
|
type Attribute = keyof DS4ActorDataSourceDataAttributes;
|
||
|
|
||
|
export function isAttribute(value: unknown): value is Attribute {
|
||
|
return (Object.keys(DS4.i18n.attributes) as Array<unknown>).includes(value);
|
||
|
}
|
||
|
|
||
|
type DS4ActorDataSourceDataTraits = { [Key in keyof typeof DS4.i18n.traits]: ModifiableDataBase<number> };
|
||
|
|
||
|
type Trait = keyof DS4ActorDataSourceDataTraits;
|
||
|
|
||
|
export function isTrait(value: unknown): value is Trait {
|
||
|
return (Object.keys(DS4.i18n.traits) as Array<unknown>).includes(value);
|
||
|
}
|
||
|
|
||
|
type DS4ActorDataSourceDataCombatValues = {
|
||
|
[Key in keyof typeof DS4.i18n.combatValues]: Key extends "hitPoints"
|
||
|
? ResourceData<number>
|
||
|
: ModifiableData<number>;
|
||
|
};
|
||
|
|
||
|
type CombatValue = keyof DS4ActorDataSourceDataCombatValues;
|
||
|
|
||
|
export function isCombatValue(value: string): value is CombatValue {
|
||
|
return (Object.keys(DS4.i18n.combatValues) as Array<unknown>).includes(value);
|
||
|
}
|