diff --git a/src/main/typescript/data/actor/character/leveling/properties.ts b/src/main/typescript/data/actor/character/leveling/properties.ts index 34f0d03b..27b8c927 100644 --- a/src/main/typescript/data/actor/character/leveling/properties.ts +++ b/src/main/typescript/data/actor/character/leveling/properties.ts @@ -1,11 +1,20 @@ +import type { SkillName } from "../../../../constants.js"; +import type { SkillInfo } from "../../common/skills/properties.js"; import LevelingSource from "./source.js"; -export default class LevelingProperties extends LevelingSource { +export default class LevelingProperties + extends LevelingSource + implements SkillInfo +{ constructor(source: LevelingSource) { super(); foundry.utils.mergeObject(this, source); } + getValue(skill: SkillName): number { + return this.skillRanks[skill]; + } + /** The current level of the character */ get level(): number { return Math.floor((1 + Math.sqrt(this.experience / 12.5 + 1)) / 2); diff --git a/src/main/typescript/data/actor/character/properties.ts b/src/main/typescript/data/actor/character/properties.ts index 590a43d3..ee50e553 100644 --- a/src/main/typescript/data/actor/character/properties.ts +++ b/src/main/typescript/data/actor/character/properties.ts @@ -6,8 +6,8 @@ import LevelingProperties from "./leveling/properties.js"; import MagicProperties from "./magic/properties.js"; import SkillsProperties from "./skills/properties.js"; import { CharacterDataSourceData } from "./source.js"; -import SpecialsProperties, { Special } from "./specials/properties.js"; -import VitalsProperties from "./vitals/properties.js"; +import SpecialsProperties, { Special } from "../common/specials/properties.js"; +import VitalsProperties from "../common/vitals/properties.js"; export default interface CharacterDataProperties { type: typeof TYPES.ACTOR.CHARACTER; diff --git a/src/main/typescript/data/actor/character/skills/properties.ts b/src/main/typescript/data/actor/character/skills/properties.ts index e74adb2d..7b82a47d 100644 --- a/src/main/typescript/data/actor/character/skills/properties.ts +++ b/src/main/typescript/data/actor/character/skills/properties.ts @@ -5,83 +5,11 @@ import { } from "../../../../constants.js"; import { CompositeNumber } from "../../../common.js"; import type LevelingProperties from "../leveling/properties.js"; -import type SpecialsProperties from "../specials/properties.js"; +import type SpecialsProperties from "../../common/specials/properties.js"; +import BaseSkillsProperties from "../../common/skills/properties.js"; -export default class SkillsProperties - implements Record -{ - /** The Barter skill of the character */ - barter = new CompositeNumber(); - - /** The Diplomacy skill of the character */ - diplomacy = new CompositeNumber(); - - /** The Explosives skill of the character */ - explosives = new CompositeNumber(); - - /** The Firearms skill of the character */ - firearms = new CompositeNumber(); - - /** The Intimidation skill of the character */ - intimidation = new CompositeNumber(); - - /** The Lockpick skill of the character */ - lockpick = new CompositeNumber(); - - /** The Magical Energy Weapons skill of the character */ - magicalEnergyWeapons = new CompositeNumber(); - - /** The Mechanics skill of the character */ - mechanics = new CompositeNumber(); - - /** The Medicine skill of the character */ - medicine = new CompositeNumber(); - - /** The Melee skill of the character */ - melee = new CompositeNumber(); - - /** The Science skill of the character */ - science = new CompositeNumber(); - - /** The Sleight skill of the character */ - sleight = new CompositeNumber(); - - /** The Sneak skill of the character */ - sneak = new CompositeNumber(); - - /** The Survival skill of the character */ - survival = new CompositeNumber(); - - /** The Thaumaturgy skill of the character */ - thaumaturgy = new CompositeNumber(); - - /** The Unarmed skill of the character */ - unarmed = new CompositeNumber(); - - /** Set the base values and skill points for all skills. */ - setBaseValues( - specials: SpecialsProperties, - thaumSpecial: ThaumaturgySpecial, - leveling: LevelingProperties - ) { - let skill: SkillName; - for (skill in CONSTANTS.skillSpecials) { - this[skill] = this.computeBaseSkill( - skill, - specials, - thaumSpecial, - leveling - ); - } - this["thaumaturgy"] = this.computeBaseSkill( - "thaumaturgy", - specials, - thaumSpecial, - leveling - ); - } - - private computeBaseSkill( +export default class SkillsProperties extends BaseSkillsProperties { + override computeBaseSkill( skill: SkillName, specials: SpecialsProperties, thaumSpecial: ThaumaturgySpecial, diff --git a/src/main/typescript/data/actor/character/source.ts b/src/main/typescript/data/actor/character/source.ts index 3f4f466c..0c49382b 100644 --- a/src/main/typescript/data/actor/character/source.ts +++ b/src/main/typescript/data/actor/character/source.ts @@ -6,7 +6,7 @@ import BackgroundSource, { import EquipmentSource, { EQUIPMENT_JSON_SCHEMA } from "./equipment/source.js"; import LevelingSource, { LEVELING_JSON_SCHEMA } from "./leveling/source.js"; import MagicSource, { MAGIC_JSON_SCHEMA } from "./magic/source.js"; -import VitalsSource, { VITALS_JSON_SCHEMA } from "./vitals/source.js"; +import VitalsSource, { VITALS_JSON_SCHEMA } from "../common/vitals/source.js"; export default interface CharacterDataSource { type: typeof TYPES.ACTOR.CHARACTER; diff --git a/src/main/typescript/data/actor/common/skills/properties.ts b/src/main/typescript/data/actor/common/skills/properties.ts new file mode 100644 index 00000000..dbdb9a7a --- /dev/null +++ b/src/main/typescript/data/actor/common/skills/properties.ts @@ -0,0 +1,101 @@ +import { + CONSTANTS, + SkillName, + ThaumaturgySpecial +} from "../../../../constants.js"; +import { CompositeNumber } from "../../../common.js"; +import type SpecialsProperties from "../specials/properties.js"; + +export default class SkillsProperties + implements Record +{ + /** The Barter skill of the character */ + barter = new CompositeNumber(); + + /** The Diplomacy skill of the character */ + diplomacy = new CompositeNumber(); + + /** The Explosives skill of the character */ + explosives = new CompositeNumber(); + + /** The Firearms skill of the character */ + firearms = new CompositeNumber(); + + /** The Intimidation skill of the character */ + intimidation = new CompositeNumber(); + + /** The Lockpick skill of the character */ + lockpick = new CompositeNumber(); + + /** The Magical Energy Weapons skill of the character */ + magicalEnergyWeapons = new CompositeNumber(); + + /** The Mechanics skill of the character */ + mechanics = new CompositeNumber(); + + /** The Medicine skill of the character */ + medicine = new CompositeNumber(); + + /** The Melee skill of the character */ + melee = new CompositeNumber(); + + /** The Science skill of the character */ + science = new CompositeNumber(); + + /** The Sleight skill of the character */ + sleight = new CompositeNumber(); + + /** The Sneak skill of the character */ + sneak = new CompositeNumber(); + + /** The Survival skill of the character */ + survival = new CompositeNumber(); + + /** The Thaumaturgy skill of the character */ + thaumaturgy = new CompositeNumber(); + + /** The Unarmed skill of the character */ + unarmed = new CompositeNumber(); + + /** Set the base values and skill points for all skills. */ + setBaseValues( + specials: SpecialsProperties, + thaumSpecial: ThaumaturgySpecial, + skillInfo: SkillInfo + ) { + let skill: SkillName; + for (skill in CONSTANTS.skillSpecials) { + this[skill] = this.computeBaseSkill( + skill, + specials, + thaumSpecial, + skillInfo + ); + } + this["thaumaturgy"] = this.computeBaseSkill( + "thaumaturgy", + specials, + thaumSpecial, + skillInfo + ); + } + + protected computeBaseSkill( + skill: SkillName, + _specials: SpecialsProperties, + _thaumSpecial: ThaumaturgySpecial, + skillInfo: SkillInfo + ): CompositeNumber { + const baseSkill = 0; + const composite = new CompositeNumber(baseSkill, { min: 0, max: 85 }); + composite.add({ + value: skillInfo.getValue(skill), + labelComponents: [{ key: "wv.rules.skills.points.short" }] + }); + return composite; + } +} + +export interface SkillInfo { + getValue(skill: SkillName): number; +} diff --git a/src/main/typescript/data/actor/character/specials/properties.ts b/src/main/typescript/data/actor/common/specials/properties.ts similarity index 100% rename from src/main/typescript/data/actor/character/specials/properties.ts rename to src/main/typescript/data/actor/common/specials/properties.ts diff --git a/src/main/typescript/data/actor/character/vitals/properties.ts b/src/main/typescript/data/actor/common/vitals/properties.ts similarity index 100% rename from src/main/typescript/data/actor/character/vitals/properties.ts rename to src/main/typescript/data/actor/common/vitals/properties.ts diff --git a/src/main/typescript/data/actor/character/vitals/source.ts b/src/main/typescript/data/actor/common/vitals/source.ts similarity index 100% rename from src/main/typescript/data/actor/character/vitals/source.ts rename to src/main/typescript/data/actor/common/vitals/source.ts diff --git a/src/main/typescript/data/actor/npc/source.ts b/src/main/typescript/data/actor/npc/source.ts index f494f61d..aa2d927a 100644 --- a/src/main/typescript/data/actor/npc/source.ts +++ b/src/main/typescript/data/actor/npc/source.ts @@ -1,8 +1,12 @@ import type { TYPES } from "../../../constants.js"; +import VitalsSource from "../common/vitals/source.js"; export default interface NpcDataSource { type: typeof TYPES.ACTOR.NPC; data: NpcDataSourceData; } -export class NpcDataSourceData {} +export class NpcDataSourceData { + /** The vitals of the NPC */ + vitals = new VitalsSource(); +} diff --git a/src/main/typescript/data/item/weapon/ranges/properties.ts b/src/main/typescript/data/item/weapon/ranges/properties.ts index 504dab27..ec1f83c5 100644 --- a/src/main/typescript/data/item/weapon/ranges/properties.ts +++ b/src/main/typescript/data/item/weapon/ranges/properties.ts @@ -1,6 +1,6 @@ import type WvActor from "../../../../actor/wvActor.js"; import { CONSTANTS, RangeBracket, TAGS } from "../../../../constants.js"; -import type SpecialsProperties from "../../../actor/character/specials/properties.js"; +import type SpecialsProperties from "../../../actor/common/specials/properties.js"; import { CompositeNumber } from "../../../common.js"; import RangesSource, { DistanceSource, RangeSource } from "./source.js"; diff --git a/src/main/typescript/ruleEngine/ruleElements/permSpecialComponent.ts b/src/main/typescript/ruleEngine/ruleElements/permSpecialComponent.ts index 23fbad87..c8a5e034 100644 --- a/src/main/typescript/ruleEngine/ruleElements/permSpecialComponent.ts +++ b/src/main/typescript/ruleEngine/ruleElements/permSpecialComponent.ts @@ -1,6 +1,6 @@ import type WvActor from "../../actor/wvActor.js"; import { isSpecialName } from "../../constants.js"; -import { Special } from "../../data/actor/character/specials/properties.js"; +import { Special } from "../../data/actor/common/specials/properties.js"; import type WvItem from "../../item/wvItem.js"; import NotActorMessage from "../messages/notActorMessage.js"; import WrongSpecialNameMessage from "../messages/wrongSpecialNameMessage.js"; diff --git a/src/main/typescript/ruleEngine/ruleElements/tempSpecialComponent.ts b/src/main/typescript/ruleEngine/ruleElements/tempSpecialComponent.ts index 5c6e0817..e20bc670 100644 --- a/src/main/typescript/ruleEngine/ruleElements/tempSpecialComponent.ts +++ b/src/main/typescript/ruleEngine/ruleElements/tempSpecialComponent.ts @@ -1,6 +1,6 @@ import type WvActor from "../../actor/wvActor.js"; import { isSpecialName } from "../../constants.js"; -import { Special } from "../../data/actor/character/specials/properties.js"; +import { Special } from "../../data/actor/common/specials/properties.js"; import type WvItem from "../../item/wvItem.js"; import NotActorMessage from "../messages/notActorMessage.js"; import WrongSpecialNameMessage from "../messages/wrongSpecialNameMessage.js";