2021-03-22 10:18:43 +01:00
|
|
|
import { ModifiableData, ModifiableDataBase, ResourceData, UsableResource } from "../common/common-data";
|
2021-02-05 03:42:42 +01:00
|
|
|
import { DS4 } from "../config";
|
2021-01-26 03:55:18 +01:00
|
|
|
import { DS4ItemData } from "../item/item-data";
|
2021-01-09 22:51:46 +01:00
|
|
|
|
2021-02-05 03:42:42 +01:00
|
|
|
export type DS4ActorData = DS4CharacterData | DS4CreatureData;
|
2021-01-26 03:55:18 +01:00
|
|
|
|
2021-02-05 03:42:42 +01:00
|
|
|
type ActorType = keyof typeof DS4.i18n.actorTypes;
|
2020-12-29 22:44:56 +01:00
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4ActorDataHelper<T, U extends ActorType> extends Actor.Data<T, DS4ItemData> {
|
2021-02-05 03:42:42 +01:00
|
|
|
type: U;
|
2020-12-28 15:51:00 +01:00
|
|
|
}
|
|
|
|
|
2021-02-05 03:42:42 +01:00
|
|
|
type DS4CharacterData = DS4ActorDataHelper<DS4CharacterDataData, "character">;
|
|
|
|
type DS4CreatureData = DS4ActorDataHelper<DS4CreatureDataData, "creature">;
|
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
// templates
|
|
|
|
|
2021-02-05 03:42:42 +01:00
|
|
|
interface DS4ActorDataDataBase {
|
|
|
|
attributes: DS4ActorDataDataAttributes;
|
|
|
|
traits: DS4ActorDataDataTraits;
|
|
|
|
combatValues: DS4ActorDataDataCombatValues;
|
|
|
|
}
|
|
|
|
|
2021-05-13 22:03:32 +02:00
|
|
|
type DS4ActorDataDataAttributes = { [Key in keyof typeof DS4.i18n.attributes]: ModifiableDataBase<number> };
|
|
|
|
|
|
|
|
type Attribute = keyof DS4ActorDataDataAttributes;
|
|
|
|
|
|
|
|
export function isAttribute(value: unknown): value is Attribute {
|
|
|
|
return (Object.keys(DS4.i18n.attributes) as Array<unknown>).includes(value);
|
2020-12-28 15:51:00 +01:00
|
|
|
}
|
|
|
|
|
2021-05-13 22:03:32 +02:00
|
|
|
type DS4ActorDataDataTraits = { [Key in keyof typeof DS4.i18n.traits]: ModifiableDataBase<number> };
|
|
|
|
|
|
|
|
type Trait = keyof DS4ActorDataDataTraits;
|
|
|
|
|
|
|
|
export function isTrait(value: unknown): value is Trait {
|
|
|
|
return (Object.keys(DS4.i18n.traits) as Array<unknown>).includes(value);
|
2020-12-29 22:44:56 +01:00
|
|
|
}
|
|
|
|
|
2021-05-13 22:03:32 +02:00
|
|
|
type DS4ActorDataDataCombatValues = {
|
|
|
|
[Key in keyof typeof DS4.i18n.combatValues]: Key extends "hitPoints"
|
|
|
|
? ResourceData<number>
|
|
|
|
: ModifiableData<number>;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CombatValue = keyof DS4ActorDataDataCombatValues;
|
|
|
|
|
|
|
|
export function isCombatValue(value: string): value is CombatValue {
|
|
|
|
return (Object.keys(DS4.i18n.combatValues) as Array<unknown>).includes(value);
|
2020-12-29 22:44:56 +01:00
|
|
|
}
|
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
// types
|
2021-03-04 00:41:57 +01:00
|
|
|
|
2021-02-05 03:42:42 +01:00
|
|
|
interface DS4CharacterDataData extends DS4ActorDataDataBase {
|
|
|
|
baseInfo: DS4CharacterDataDataBaseInfo;
|
|
|
|
progression: DS4CharacterDataDataProgression;
|
|
|
|
language: DS4CharacterDataDataLanguage;
|
|
|
|
profile: DS4CharacterDataDataProfile;
|
|
|
|
currency: DS4CharacterDataDataCurrency;
|
2021-05-13 15:41:00 +02:00
|
|
|
slayerPoints: DS4CharacterDataDataSlayerPoints;
|
2021-01-09 22:51:46 +01:00
|
|
|
}
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4CharacterDataDataBaseInfo {
|
2020-12-29 22:44:56 +01:00
|
|
|
race: string;
|
|
|
|
class: string;
|
|
|
|
heroClass: string;
|
2021-01-03 20:37:30 +01:00
|
|
|
culture: string;
|
2020-12-29 22:44:56 +01:00
|
|
|
}
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4CharacterDataDataProgression {
|
2020-12-29 22:44:56 +01:00
|
|
|
level: number;
|
|
|
|
experiencePoints: number;
|
2020-12-30 21:34:12 +01:00
|
|
|
talentPoints: UsableResource<number>;
|
2020-12-29 22:44:56 +01:00
|
|
|
progressPoints: UsableResource<number>;
|
2020-12-28 15:51:00 +01:00
|
|
|
}
|
2021-01-03 20:37:30 +01:00
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4CharacterDataDataLanguage {
|
2021-01-03 20:37:30 +01:00
|
|
|
languages: string;
|
|
|
|
alphabets: string;
|
|
|
|
}
|
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4CharacterDataDataProfile {
|
2021-01-10 02:05:30 +01:00
|
|
|
biography: string;
|
2021-01-03 20:37:30 +01:00
|
|
|
gender: string;
|
|
|
|
birthday: string;
|
|
|
|
birthplace: string;
|
|
|
|
age: number;
|
|
|
|
height: number;
|
|
|
|
hairColor: string;
|
|
|
|
weight: number;
|
|
|
|
eyeColor: string;
|
|
|
|
specialCharacteristics: string;
|
|
|
|
}
|
2021-01-10 19:32:10 +01:00
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4CharacterDataDataCurrency {
|
2021-01-10 19:32:10 +01:00
|
|
|
gold: number;
|
|
|
|
silver: number;
|
|
|
|
copper: number;
|
|
|
|
}
|
2021-01-18 19:48:07 +01:00
|
|
|
|
2021-05-13 15:41:00 +02:00
|
|
|
export interface DS4CharacterDataDataSlayerPoints {
|
|
|
|
value: number;
|
|
|
|
}
|
|
|
|
|
2021-02-05 03:42:42 +01:00
|
|
|
interface DS4CreatureDataData extends DS4ActorDataDataBase {
|
|
|
|
baseInfo: DS4CreatureDataDataBaseInfo;
|
2021-01-09 22:51:46 +01:00
|
|
|
}
|
|
|
|
|
2021-03-22 10:18:43 +01:00
|
|
|
export interface DS4CreatureDataDataBaseInfo {
|
2021-01-09 22:51:46 +01:00
|
|
|
loot: string;
|
|
|
|
foeFactor: number;
|
|
|
|
creatureType: CreatureType;
|
|
|
|
sizeCategory: SizeCategory;
|
|
|
|
experiencePoints: number;
|
2021-01-10 02:05:30 +01:00
|
|
|
description: string;
|
2021-01-09 22:51:46 +01:00
|
|
|
}
|
2021-03-22 10:18:43 +01:00
|
|
|
|
2021-05-13 19:59:44 +02:00
|
|
|
type CreatureType = keyof typeof DS4.i18n.creatureTypes;
|
2021-03-22 10:18:43 +01:00
|
|
|
|
2021-05-13 19:59:44 +02:00
|
|
|
type SizeCategory = keyof typeof DS4.i18n.creatureSizeCategories;
|