2021-06-30 03:53:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
// SPDX-FileCopyrightText: 2021 Oliver Rümpelein
|
|
|
|
// SPDX-FileCopyrightText: 2021 Gesina Schwalbe
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
import { ModifiableDataBaseMax } from "../common/common-data";
|
|
|
|
import { DS4 } from "../config";
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface SourceConfig {
|
|
|
|
Item: DS4ItemDataSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ItemType = keyof typeof DS4.i18n.itemTypes;
|
|
|
|
|
|
|
|
export type DS4ItemDataSource =
|
|
|
|
| DS4WeaponDataSource
|
|
|
|
| DS4ArmorDataSource
|
|
|
|
| DS4ShieldDataSource
|
|
|
|
| DS4SpellDataSource
|
|
|
|
| DS4EquipmentDataSource
|
|
|
|
| DS4LootDataSource
|
|
|
|
| DS4TalentDataSource
|
|
|
|
| DS4RacialAbilityDataSource
|
|
|
|
| DS4LanguageDataSource
|
|
|
|
| DS4AlphabetDataSource
|
|
|
|
| DS4SpecialCreatureAbilityDataSource;
|
|
|
|
|
|
|
|
interface DS4WeaponDataSource {
|
|
|
|
type: "weapon";
|
|
|
|
data: DS4WeaponDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4ArmorDataSource {
|
|
|
|
type: "armor";
|
|
|
|
data: DS4ArmorDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4ShieldDataSource {
|
|
|
|
type: "shield";
|
|
|
|
data: DS4ShieldDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4SpellDataSource {
|
|
|
|
type: "spell";
|
|
|
|
data: DS4SpellDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4EquipmentDataSource {
|
|
|
|
type: "equipment";
|
|
|
|
data: DS4EquipmentDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4LootDataSource {
|
|
|
|
type: "loot";
|
|
|
|
data: DS4LootDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4TalentDataSource {
|
|
|
|
type: "talent";
|
|
|
|
data: DS4TalentDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4RacialAbilityDataSource {
|
|
|
|
type: "racialAbility";
|
|
|
|
data: DS4RacialAbilityDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4LanguageDataSource {
|
|
|
|
type: "language";
|
|
|
|
data: DS4LanguageDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4AlphabetDataSource {
|
|
|
|
type: "alphabet";
|
|
|
|
data: DS4AlphabetDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4SpecialCreatureAbilityDataSource {
|
|
|
|
type: "specialCreatureAbility";
|
|
|
|
data: DS4SpecialCreatureAbilityDataSourceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
// templates
|
|
|
|
|
|
|
|
interface DS4ItemDataSourceDataBase {
|
|
|
|
description: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4ItemDataSourceDataPhysical {
|
|
|
|
quantity: number;
|
|
|
|
price: number;
|
|
|
|
availability: keyof typeof DS4.i18n.itemAvailabilities;
|
|
|
|
storageLocation: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isDS4ItemDataTypePhysical(input: foundry.data.ItemData["data"]): boolean {
|
|
|
|
return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4ItemDataSourceDataEquipable {
|
|
|
|
equipped: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DS4ItemDataSourceDataProtective {
|
|
|
|
armorValue: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// types
|
|
|
|
|
|
|
|
export interface DS4WeaponDataSourceData
|
|
|
|
extends DS4ItemDataSourceDataBase,
|
|
|
|
DS4ItemDataSourceDataPhysical,
|
|
|
|
DS4ItemDataSourceDataEquipable {
|
|
|
|
attackType: AttackType;
|
|
|
|
weaponBonus: number;
|
|
|
|
opponentDefense: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type AttackType = keyof typeof DS4.i18n.attackTypes;
|
|
|
|
|
|
|
|
export interface DS4ArmorDataSourceData
|
|
|
|
extends DS4ItemDataSourceDataBase,
|
|
|
|
DS4ItemDataSourceDataPhysical,
|
|
|
|
DS4ItemDataSourceDataEquipable,
|
|
|
|
DS4ItemDataSourceDataProtective {
|
|
|
|
armorMaterialType: keyof typeof DS4.i18n.armorMaterialTypes;
|
|
|
|
armorType: keyof typeof DS4.i18n.armorTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DS4ShieldDataSourceData
|
|
|
|
extends DS4ItemDataSourceDataBase,
|
|
|
|
DS4ItemDataSourceDataPhysical,
|
|
|
|
DS4ItemDataSourceDataEquipable,
|
|
|
|
DS4ItemDataSourceDataProtective {}
|
|
|
|
|
2022-02-14 00:58:23 +01:00
|
|
|
export type CooldownDuration = keyof typeof DS4.i18n.cooldownDurations;
|
|
|
|
|
2021-06-30 03:53:52 +02:00
|
|
|
export interface DS4SpellDataSourceData extends DS4ItemDataSourceDataBase, DS4ItemDataSourceDataEquipable {
|
|
|
|
spellType: keyof typeof DS4.i18n.spellTypes;
|
|
|
|
bonus: string;
|
|
|
|
spellCategory: keyof typeof DS4.i18n.spellCategories;
|
|
|
|
maxDistance: UnitData<DistanceUnit>;
|
|
|
|
effectRadius: UnitData<DistanceUnit>;
|
2022-02-14 00:58:23 +01:00
|
|
|
duration: UnitData<TemporalUnit>;
|
|
|
|
cooldownDuration: CooldownDuration;
|
2021-06-30 03:53:52 +02:00
|
|
|
minimumLevels: {
|
|
|
|
healer: number | null;
|
|
|
|
wizard: number | null;
|
|
|
|
sorcerer: number | null;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UnitData<UnitType> {
|
|
|
|
value: string;
|
|
|
|
unit: UnitType;
|
|
|
|
}
|
|
|
|
|
|
|
|
type DistanceUnit = keyof typeof DS4.i18n.distanceUnits;
|
|
|
|
|
2022-02-14 00:58:23 +01:00
|
|
|
type TemporalUnit = keyof typeof DS4.i18n.temporalUnits;
|
2021-06-30 03:53:52 +02:00
|
|
|
|
|
|
|
export interface DS4EquipmentDataSourceData
|
|
|
|
extends DS4ItemDataSourceDataBase,
|
|
|
|
DS4ItemDataSourceDataPhysical,
|
|
|
|
DS4ItemDataSourceDataEquipable {}
|
|
|
|
|
|
|
|
export interface DS4LootDataSourceData extends DS4ItemDataSourceDataBase, DS4ItemDataSourceDataPhysical {}
|
|
|
|
|
|
|
|
export interface DS4TalentDataSourceData extends DS4ItemDataSourceDataBase {
|
|
|
|
rank: ModifiableDataBaseMax<number>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type DS4RacialAbilityDataSourceData = DS4ItemDataSourceDataBase;
|
|
|
|
|
|
|
|
export type DS4LanguageDataSourceData = DS4ItemDataSourceDataBase;
|
|
|
|
|
|
|
|
export type DS4AlphabetDataSourceData = DS4ItemDataSourceDataBase;
|
|
|
|
|
|
|
|
export interface DS4SpecialCreatureAbilityDataSourceData extends DS4ItemDataSourceDataBase {
|
|
|
|
experiencePoints: number;
|
|
|
|
}
|