// 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 {} export interface DS4SpellDataSourceData extends DS4ItemDataSourceDataBase, DS4ItemDataSourceDataEquipable { spellType: keyof typeof DS4.i18n.spellTypes; bonus: string; spellCategory: keyof typeof DS4.i18n.spellCategories; maxDistance: UnitData; effectRadius: UnitData; duration: UnitData; cooldownDuration: UnitData; minimumLevels: { healer: number | null; wizard: number | null; sorcerer: number | null; }; } export interface UnitData { value: string; unit: UnitType; } type DistanceUnit = keyof typeof DS4.i18n.distanceUnits; type CustomTemporalUnit = keyof typeof DS4.i18n.customTemporalUnits; export type TemporalUnit = keyof typeof DS4.i18n.temporalUnits; export interface DS4EquipmentDataSourceData extends DS4ItemDataSourceDataBase, DS4ItemDataSourceDataPhysical, DS4ItemDataSourceDataEquipable {} export interface DS4LootDataSourceData extends DS4ItemDataSourceDataBase, DS4ItemDataSourceDataPhysical {} export interface DS4TalentDataSourceData extends DS4ItemDataSourceDataBase { rank: ModifiableDataBaseMax; } export type DS4RacialAbilityDataSourceData = DS4ItemDataSourceDataBase; export type DS4LanguageDataSourceData = DS4ItemDataSourceDataBase; export type DS4AlphabetDataSourceData = DS4ItemDataSourceDataBase; export interface DS4SpecialCreatureAbilityDataSourceData extends DS4ItemDataSourceDataBase { experiencePoints: number; }